How to use the mount function
I want to use the mount function in my code, but I don't know how to finish the function such as "mount /dev/sda /mnt -o offset=32256". In my system(FC6), the mount function definition is "mount(const char *source, const char *target, const char *filesystem, unsigned long mountflags, const void *data)". I set the params as "mount("/dev/sda", "/mnt", "ext3", 0, "offset=32256" )", but it's wrong.
How can I use the function mount? |
Typically, one would define their mount points in the file-system table. On Linux systems, it exists almost universally as the /etc/fstab file, and entries in this file are usually mounted automatically via automount (if available).
Just append a new entry to this file with the proper device location, desired mount point, and the corresponding parameters with which you would like to mount the device. If you do not wish to have it automatically mounted, then you can ignore everything above. :P The basic syntax for mounting and unmounting are: Code:
mount [[device] or [mount-location]] Code:
umount [[device] or [mount-location]] Code:
mount /dev/sda /mnt -o offset=32256 You should create a folder inside your /mnt directory to act as the mount point (e.g. /mnt/sda or whatever you want to call it!) rather than mounting to /mnt directly. There are some small details you may be overlooking (not to sound condescending, but these things are easily overlooked):
Here's [tuxfiles.org] a simple guide that might be of help. Just curious, what type of file system are you trying to mount? .Colin |
Thank you for your replay, ColinAnderson.
But I can sure the command "mount /dev/sda /mnt -o offset=32256" is right. Because in terminal I press this command, and it's ok. I can find the file in the /mnt director. I only want to know how to use the function mount to finish the same result with the command "mount /dev/sda /mnt -o offset=32256". I use "man 2 mount" to get some infomation about the mount function, but there is not any descriptions about the param data, so I don't know how to use the mount function to finish the command "mount /dev/sda /mnt -o offset=32256". |
All times are GMT -5. The time now is 04:12 PM. |