Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
01-14-2002, 01:22 PM
|
#1
|
LQ Newbie
Registered: Jan 2002
Posts: 4
Rep:
|
writing a file to a FAT partition
I am trying to create and write to file in a FAT32 partition. (I need to be able to see the file on the WIN2K side as well as Linux.)
using the following code ex.
ofstream wfile;
wfile.open ("/dosd/CSE_Raw/Heartbeat.txt", ofstream:  ut | ofstream::app);
wfile << ....
dosd is the mount point for the FAT32 partition.
But the file open fails. Any ideas? I am running this code from my home directory not the FAT partition if that makes a difference.
|
|
|
01-15-2002, 03:14 PM
|
#2
|
LQ Newbie
Registered: Jan 2002
Location: Jacksonville, FL
Distribution: RedHat
Posts: 26
Rep:
|
Well, there's a couple of things you can try. Although FAT has minimal file attribute bits compared to Linux, you may be being denied access because the FAT filesystem is blocking you.
Try:
ls -l /
ls -l /dosd
ls -l /dosd/CSE_Raw
to make sure than none of the directories of the traversal path is forbidden.
Also, do a quick command-line check:
echo Hello >/dosd/CSE_Raw/Heartbeat.txt
cat /dosd/CSE_Raw/Heartbeat.txt
If all of these work, you've coded the program incorrectly.
|
|
|
01-17-2002, 08:47 AM
|
#3
|
LQ Newbie
Registered: Jan 2002
Posts: 4
Original Poster
Rep:
|
unable to chown, chmod
As root, the echo command works, and my program works. However when I try to chown the dosd (or anything under it) to my non-root account, I get a permission denied message. Same thing with chmod. I tried modifying the permissions through the WIN2K side but It won't allow me.
Is there anyway to be able to write to this directory not logged in as root? Or some other way to change the directory ownership or write permissions?
|
|
|
01-17-2002, 09:41 AM
|
#4
|
Senior Member
Registered: Apr 2001
Location: Plymouth, England.
Distribution: Mostly Debian based systems
Posts: 4,368
Rep:
|
Unfortunately none of the FAT types will allow you to have ownership. I think the only Windows compatible filesystem to have ownership is NTFS, which is not particularly well supported in Linux. If you want to be able to access r/w the files on the dos partition, you will need to look up the fstab properties for the mount-point (i.e. dosd).
man fstab.
I'm affraid I'm not at my Linux box at the mo and I can't remember the correct settings.
|
|
|
01-17-2002, 10:22 AM
|
#5
|
LQ Newbie
Registered: Jan 2002
Posts: 4
Original Poster
Rep:
|
specify owner in fstab?
can I set uid=# in the fstab to force my FAT partition to be owned by someone other than root? If so, how do I find out the uid? I tried whoami, but it only tells me the name, not the number.
|
|
|
01-17-2002, 10:42 AM
|
#6
|
Senior Member
Registered: Apr 2001
Location: Plymouth, England.
Distribution: Mostly Debian based systems
Posts: 4,368
Rep:
|
No, no, I think you misunderstood me. Because there is no such thing as ownership under Windows (except NTFS) the Linux system defaults to everything being owned by Root. If you edit your fstab file you can add the option of 'user' which means that not only can any-old-user mount the partition, but can also write to it (presuming you've set the rw option aswell). The files will still be owned by root, though. If you read the man pages for mount and fstab respectively you should get the idea.
|
|
|
01-17-2002, 10:42 AM
|
#7
|
Member
Registered: Oct 2001
Distribution: MD81 RH71
Posts: 555
Rep:
|
yeah, you can set it there, you can find the uid from looking at /etc/passwd. probably a command for it, but that's the text file it's stored in
|
|
|
01-17-2002, 11:17 AM
|
#8
|
LQ Newbie
Registered: Jan 2002
Posts: 4
Original Poster
Rep:
|
thanks to all
appreciate all the help. I added uid= and rw to the fstab for the FAT partition and now I can write to it the way I want. Thymox, understand what you were suggesting but I prefer the partition be owned by the user, not root.
Thanks again
|
|
|
09-21-2004, 04:25 PM
|
#9
|
LQ Newbie
Registered: Sep 2004
Posts: 1
Rep:
|
I think that is a weid way to make a FAT partition writeable.
Try adding umask=000 option this sets the default mask of permissions which are not present, thus allowing anyone to write, not just the owner. It is the same octal mask, it just does the opposite to chmod.
You can use fmask and dmask to separate rights for files and directories.
Check the man mount :-)
|
|
|
All times are GMT -5. The time now is 01:00 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|