Mount from C code with --no-mtab?


 
Thread Tools Search this Thread
Top Forums Programming Mount from C code with --no-mtab?
# 1  
Old 01-02-2014
Mount from C code with --no-mtab?

Hi all,
I am writing a mount/umount procedure for CD rom and getting into the problem that /etc/mtab is not in sync with /proc/mounts.
Then I am ending up with a bunch of dangling /etc/mtab entries that are not valid anymore.
Reading through mount(8) I see a -n switch (--no-mtab) which would not write into mtab, but I can't see a flag to the mount C-function call (in mount(2) or googling) that would do this.
Does anyone know how could I get this behavior?
Thank you!
Miro
# 2  
Old 01-10-2014
Have you tried using the MS_READONLY flag to the mount syscall and below is an excerpt from the mount syscall manpage...
Code:
The mountflags argument may have the magic number 0xC0ED (MS_MGC_VAL) in the top 16 bits
(this was required in kernel versions prior to 2.4, but is no longer required  and  ignored
if specified), and various mount flags (as defined in <linux/fs.h> for libc4 and libc5 and in 
<sys/mount.h> for glibc2) in the low order 16 bits:
       .
       .
       .
       MS_RDONLY
              Mount file system read-only.

# 3  
Old 01-10-2014
Quote:
Originally Posted by mirni
Reading through mount(8) I see a -n switch (--no-mtab) which would not write into mtab, but I can't see a flag to the mount C-function call (in mount(2) or googling) that would do this.
The mount sytem-call doesn't update /etc/mtab, the mount utility does.

How to fix your problem depends on what your procedure is.

Last edited by Corona688; 01-10-2014 at 12:30 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to create a new mount point with 600GB and add 350 GBexisting mount point? IN AIX

How to create a new mount point with 600GB and add 350 GBexisting mount point Best if there step that i can follow or execute before i mount or add diskspace IN AIX Thanks (2 Replies)
Discussion started by: Thilagarajan
2 Replies

2. Shell Programming and Scripting

Script to mount nas-share using generated credentials (mount EC 13,32)

Heyas At home i have 1 nas with 3 shares, of which i used to mount 2 of them using a script with hardcoded password and username in it. EDIT: Turns out, its not the script, but 'how i access' the nas share.. (-o user=XY,password=... VS. -o credentials=...). Figured about credential files,... (0 Replies)
Discussion started by: sea
0 Replies

3. IP Networking

Can't see home folder on one NFS mount but can in another mount on another share

Hello, I have a few Ubuntu 9.10 laptops I'm trying to learn NFS sharing with. I am just experimenting on this right now, so no harsh words about the security of what I'm playing with, please ;) Below are the configs /etc/exports on host /home/woodnt/Homeschool... (2 Replies)
Discussion started by: Narnie
2 Replies

4. UNIX for Advanced & Expert Users

mount -t cifs permission denied by mount -t smbfs works fine

I am having trouble mounting with cifs, but mounting the exact same command with smbfs works fine. The share is on another samba server and is set to full public guest access. # mount -t cifs //servername/sharename /mnt/temp -o password="" mount error 13 = Permission denied Refer to the... (3 Replies)
Discussion started by: humbletech99
3 Replies

5. UNIX for Dummies Questions & Answers

mount

hi can some in layman terms plz xplain me d use n implementation of mount command ......m confused..:(:( (1 Reply)
Discussion started by: jaini
1 Replies

6. UNIX for Dummies Questions & Answers

mount -o llock -F nfs vs mount -F nfs

Hi, We encountered NFS issue (solaris) especially running on Oracle application. Problem such as forms hang when close button is click, concurrent job shows running status all time. Understand we need to use mount -o llock -F nfs instead of mount -F nfs to eliminate? this problem.. Can... (1 Reply)
Discussion started by: KhawHL
1 Replies

7. UNIX for Dummies Questions & Answers

Mount

Hey, need to mount the following below, and new ish to unix.. what is the process.. thanks :b: # format Searching for disks...done AVAILABLE DISK SELECTIONS: 0. c1t0d0 <SEAGATE-ST973401LC-0001 cyl 51057 alt 2 hd 4 sec 702> /pci@1d,700000/scsi@4/sd@0,0 (5 Replies)
Discussion started by: blb
5 Replies

8. Programming

code mount in c language

HI All: Where I can find out the mount lib or function to view because I think about using c to mount a file system without shell command. Thanks (7 Replies)
Discussion started by: jeter
7 Replies

9. UNIX for Dummies Questions & Answers

editing mtab

Hi all and Happy New Year!! I'm teaching myself Unix on two Linux boxes (one Red Hat, one SuSE). Anyway, I downloaded and installed patches and fixes for my SuSE box and now I can't mount my cdrom as a user. An error pops up: Could not mount mount according to mtab, /dev/hdc is mounted on... (1 Reply)
Discussion started by: SeCBerm
1 Replies

10. UNIX for Dummies Questions & Answers

how to mount a hotswap scsi drive on a solaris 2.6 netra box using the mount command?

Hi... question is this: How do I mount an LVD hotswap scsi drive in bay #2 on a netra using the mount command? volmgt doesn't seem to mount it and/or I don't know how to view the drives data if it's formatted which it may not be. This drive is not new out of the box so I'm not sure. ... (4 Replies)
Discussion started by: soulshaker
4 Replies
Login or Register to Ask a Question