Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 131313 - unix2dos unable to convert files on usb drive
Summary: unix2dos unable to convert files on usb drive
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: High minor (vote)
Assignee: Gentoo Shell Tools project
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-04-26 03:36 UTC by Doan Vu
Modified: 2007-09-29 07:27 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
The EXDEV workaround. (unix2dos-2.2-workaround-rename-EXDEV.patch,1.33 KB, patch)
2007-09-26 21:19 UTC, Dominique PRUNIER
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Doan Vu 2006-04-26 03:36:47 UTC
a) I created a plain text file using vim on my usb key, which is mounted on /mnt/usbkey and is vfat format.
b) I used unix2dos to convert the file from unix to dos format.
c) It spat this out:

millpark munky # cp file.txt /mnt/usbkey/
millpark munky # unix2dos /mnt/usbkey/file.txt
unix2dos: converting file /mnt/usbkey/file.txt to DOS format ...
unix2dos: problems renaming './u2dtmpVJosSl' to '/mnt/usbkey/file.txt'
          output file remains in './u2dtmpVJosSl'
unix2dos: problems converting file /mnt/usbkey/file.txt


d) The text file is removed from the usbkey, but as you can tell from the message above, unix2dos has successfully converted the file and placed on the harddrive as "./u2dtmpVJosSl".

All I have to do is "mv ./u2dtmpVJosSl /mnt/usbkey/file.xt", but that's just a workaround, not a fix. So why doesn't unix2dos work on my usbkey? It works for files on the harddrive.

"man unix2dos" will tell you:

DIAGNOSTICS
BUGS
The program does not work properly under MSDOS in stdio processing mode. If you know why is that so, please tell me.

I am using the unix2dos 2.2

millpark ~ # emerge --info
>>> cfg-update-1.8.0-r3 : Building checksum index... (takes a few seconds)  done!
Portage 2.0.54 (default-linux/amd64/2006.0, gcc-4.0.2, glibc-2.3.6-r3, 2.6.15-gentoo-r7 x86_64)
=================================================================
System uname: 2.6.15-gentoo-r7 x86_64 AMD Athlon(tm) 64 Processor 3200+
Gentoo Base System version 1.6.14
dev-lang/python:     2.3.5-r2, 2.4.2
sys-apps/sandbox:    1.2.12
sys-devel/autoconf:  2.13, 2.59-r7
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r1
sys-devel/binutils:  2.16.1
sys-devel/libtool:   1.5.22
virtual/os-headers:  2.6.11-r2
ACCEPT_KEYWORDS="amd64"
AUTOCLEAN="yes"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=athlon64 -pipe -O2"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/2/share/config /usr/kde/3/share/config /usr/lib/X11/xkb /usr/share/config /var/qmail/control"
CONFIG_PROTECT_MASK="/etc/eselect/compiler /etc/gconf /etc/terminfo /etc/env.d"
CXXFLAGS="-march=athlon64 -pipe -O2"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoconfig distlocks sandbox sfperms strict"
GENTOO_MIRRORS="ftp://mirror.pacific.net.au/linux/Gentoo ftp://ftp.swin.edu.au/gentoo ftp://mirror.aarnet.edu.au/pub/gentoo ftp://mirror.isp.net.au/pub/gentoo/ ftp://ftp.planetmirror.com/pub/gentoo/"
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.au.gentoo.org/gentoo-portage"
USE="amd64 X alsa audiofile avi bash-completion berkdb bitmap-fonts bzip2 cdr cli crypt cups dri dvd eds emboss encode esd exif expat foomaticdb fortran gif glut gmp gpm gstreamer gtk gtk2 imagemagick imlib ipv6 isdnlog java jpeg lcms lzw lzw-tiff mad mng mp3 mpeg ncurses nls nptl nvidia offensive ogg opengl pam pcre pdflib perl png pppd python quicktime readline reflection sdl session spell spl ssl tcpd tiff truetype truetype-fonts type1-fonts udev usb vorbis xine xml2 xmms xorg xpm xv zlib userland_GNU kernel_linux elibc_glibc"
Unset:  ASFLAGS, CTARGET, INSTALL_MASK, LANG, LC_ALL, LDFLAGS, LINGUAS


I'm not sure if this has anything to do with my problem. I am using amd64, but I doubt this is an arch-specific problem.

Thanks in advance.
Comment 1 Sylvain Demers 2006-12-27 15:30:04 UTC
I can see from your example that you are running unix2dos from your home directory, trying to convert a file on another partition (the USB key).

The problem is right there. unix2dos uses the rename function of stdio.h, which doesn't work across partitions, and unix2dos creates a temp file in the current directory (which is another problem if you don't have write rights in the current directory).

Possible solutions:
1) cd in the destination directory first.

or

2) unix2dos -n /mnt/usbkey/file.txt u2d_tempfile && mv u2d_tempfile /mnt/usbkey/file.txt

I don't think the bug in the man page applies because it speaks of running on MSDOS, not about using an MSDOS/VFAT filesystem.

I tried writing a patch, but my C skill are... lacking! :)
Comment 2 Peter Volkov (RETIRED) gentoo-dev 2007-09-12 14:54:55 UTC
Seems very similar to bug 33119. I'll take care.
Comment 3 Dominique PRUNIER 2007-09-26 21:18:01 UTC
This is the same bug that was impacting unix2dos a while ago but has been corrected in dos2unix-3.1-r2 (see bug 174776).

I have applied the same patch and it seems to work pretty well.
Comment 4 Dominique PRUNIER 2007-09-26 21:19:26 UTC
Created attachment 131971 [details, diff]
The EXDEV workaround.
Comment 5 Peter Volkov (RETIRED) gentoo-dev 2007-09-29 07:27:19 UTC
(In reply to comment #3)
> This is the same bug that was impacting unix2dos a while ago but has been
> corrected in dos2unix-3.1-r2 (see bug 174776).

Yes. That was cut&paste error of course I meant bug 174776. This bug is fixed in unix2dos-2.2-r1.ebuild.

Thank you all, and enjoy :)