Latest LQ Deal: Latest LQ Deals
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 02-12-2007, 11:39 PM   #1
LQ Newbie
Registered: Feb 2007
Posts: 5

Rep: Reputation: 0
Question 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?
Old 02-13-2007, 04:18 PM   #2
LQ Newbie
Registered: Sep 2003
Distribution: RHEL 4, 5; Gentoo
Posts: 20

Rep: Reputation: 0
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:
mount [[device] or [mount-location]]
umount [[device] or [mount-location]]
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 [] a simple guide that might be of help.

Just curious, what type of file system are you trying to mount?


Last edited by ColinAnderson; 02-13-2007 at 04:22 PM. Reason: Spelling
Old 02-13-2007, 11:42 PM   #3
LQ Newbie
Registered: Feb 2007
Posts: 5

Original Poster
Rep: Reputation: 0
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".


filesystem, fstab, mount, umount

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
function defn inside a function in C...!!! arunka Programming 1 02-05-2006 02:08 AM
what are the Hexadecimal function and ASCII function in Perl Bassam Programming 1 06-03-2004 02:44 AM
A main can be changed by a function local without passing anything to the function? ananthbv Programming 10 05-04-2004 02:31 PM
Is the wait function is the same as the sleep function ? Linh Programming 3 04-28-2004 01:39 PM
Perl exec function in linux (and system-function) nazula Programming 1 04-19-2004 01:21 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:27 PM.

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