LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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


Reply
  Search this Thread
Old 01-14-2002, 01:22 PM   #1
Cman
LQ Newbie
 
Registered: Jan 2002
Posts: 4

Rep: Reputation: 0
Question 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.
 
Old 01-15-2002, 03:14 PM   #2
mtsinc
LQ Newbie
 
Registered: Jan 2002
Location: Jacksonville, FL
Distribution: RedHat
Posts: 26

Rep: Reputation: 16
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.
 
Old 01-17-2002, 08:47 AM   #3
Cman
LQ Newbie
 
Registered: Jan 2002
Posts: 4

Original Poster
Rep: Reputation: 0
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?
 
Old 01-17-2002, 09:41 AM   #4
Thymox
Senior Member
 
Registered: Apr 2001
Location: Plymouth, England.
Distribution: Mostly Debian based systems
Posts: 4,368

Rep: Reputation: 64
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.
 
Old 01-17-2002, 10:22 AM   #5
Cman
LQ Newbie
 
Registered: Jan 2002
Posts: 4

Original Poster
Rep: Reputation: 0
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.
 
Old 01-17-2002, 10:42 AM   #6
Thymox
Senior Member
 
Registered: Apr 2001
Location: Plymouth, England.
Distribution: Mostly Debian based systems
Posts: 4,368

Rep: Reputation: 64
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.
 
Old 01-17-2002, 10:42 AM   #7
bluecadet
Member
 
Registered: Oct 2001
Distribution: MD81 RH71
Posts: 555

Rep: Reputation: 30
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
 
Old 01-17-2002, 11:17 AM   #8
Cman
LQ Newbie
 
Registered: Jan 2002
Posts: 4

Original Poster
Rep: Reputation: 0
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
 
Old 09-21-2004, 04:25 PM   #9
Gnomz
LQ Newbie
 
Registered: Sep 2004
Posts: 1

Rep: Reputation: 0
Post

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 :-)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Only limited writing access on FAT via NFS micha Linux - Networking 2 10-31-2005 02:37 AM
Is arrangement of file systems will differ if we copy a file from FAT 32 to ext 3 ? anindyanuri Linux - Software 2 02-20-2005 11:39 AM
cant modify a file on mounted FAT partition dwarf007 Linux - Newbie 7 09-24-2004 08:02 AM
Writing to my fat partition fuzzai Linux - General 6 04-20-2004 10:31 AM
i want to compile fat file system module and get fat.o working ramya272 Linux - Newbie 9 02-26-2004 11:41 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration