LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 02-12-2007, 10:39 PM   #1
ChiefGuo
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, 03:18 PM   #2
ColinAnderson
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:
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

Last edited by ColinAnderson; 02-13-2007 at 03:22 PM. Reason: Spelling
 
Old 02-13-2007, 10:42 PM   #3
ChiefGuo
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".
 
  


Reply

Tags
filesystem, fstab, mount, umount



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:01 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