LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   How to use the mount function (https://www.linuxquestions.org/questions/linux-software-2/how-to-use-the-mount-function-528506/)

ChiefGuo 02-12-2007 10:39 PM

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?

ColinAnderson 02-13-2007 03:18 PM

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]]
and
Code:

umount [[device] or [mount-location]]
So
Code:

mount /dev/sda /mnt -o offset=32256
should technically work, barring any incorrect parameters.

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):
  • Make sure you have privileges to mount volumes (I believe there is an option that can be used in /etc/fstab along the lines of 'user' or 'nouser'), or
  • mount the volume as root
  • Make sure the the desired mount point exists (e.g. if you want to mount at /mnt/music, make sure that the 'music' folder exists in the '/mnt' directory).

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

ChiefGuo 02-13-2007 10:42 PM

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.