[Tfug] yasq - how to mount a usb stick - vfat

jblais joe.blais at pti-instruments.com
Wed Dec 5 11:29:16 MST 2007


more stoopid questions today..

generally when I stick a usb memory stick into the Fedora 5 Linux box, it
automagically gets done.  I looked into fstab, it doesn't mention anything
about it.  Apparently FC5, or gnome, or whatever, does it's magic in a
Winderseque way.

So now I made an application that does the mount, because I used udev to
always put special device in a known place.  When I look at dev, the stick
may show us as sda, or sdb, or...  depending on if it was unmounted
correctly (who knows what a user may do), or which plug it was pushed into,
or the phase of the moon (more windersesque).  I disabled autobrowse,
because I want my app to look like an instrument, not a desktop.  Anyway,
without auto browse, I needed a udev rule to put whatever new sd*1 into a
known place depending on the actual usb port.  But doing so, only mounts the
special device, and my app now needs ot mount the file system.

So, without a good example from fstab, or from seeing what the automagic
mount is really doing (which seems OK), I now need to know what parameters
are best.  I do not want is the automagic renaming of files - that is names
like HELLO.TXT should not be changed to hello.txt and
ThisIsAStoopidlyLargeNameThatSomePeopleInsistOn.abc being changed to
THIS~024.TXT or some other stuff that causes me a headache when I try to
re-locate a file once written to a stick.

Anyway, I'm currently using something like:
        uid_t tUserID = getuid() ;
        gid_t tGroupID = getgid() ;
        char szUserInfo[128] ;
        sprintf( szUserInfo, "uid=%d,gid=%d,umask=0000,shortname=winnt",
(int)tUserID, (int)tGroupID ) ;
        if ( mount( "/dev/myPort1, //udev rules do this for me
                    "/home/user500/Stick1",  //I expect file system here
                    szUserInfo  ) )

this should be the same as:
  $ mount -t vfat  -o uid=500,gid=500,umaks=0000,shortname=winnt
/dev/myPort1 /home/user500/Stick1

It seems to work.  the /dev/myPort1 symlink set by udev rules seems to be
reliable enough.  My program always knows to check /home/user500/Stick1 --
and it seems to work
BUT, I've had enough problems getting all this figured out an working, so I
just thought to ask y'all if anyone knows of or uses some better mount



More information about the tfug mailing list