All of lore.kernel.org
 help / color / mirror / Atom feed
* Remounting File Systems
@ 2003-11-20 16:41 Joseph D. Wagner
  2003-11-21  4:48 ` Glynn Clements
  2003-11-21 17:03 ` Jamie LeTual
  0 siblings, 2 replies; 14+ messages in thread
From: Joseph D. Wagner @ 2003-11-20 16:41 UTC (permalink / raw)
  To: linux-c-programming

I'm writing a program that has to remount a file system on the fly for the 
purpose of changing the mount flags.

Is there any system function that can tell me what the mount flags are for a 
currently mounted file system?

TIA.

Joseph D. Wagner


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Remounting File Systems
@ 2003-11-20 17:19 Joseph D. Wagner
  2003-11-21  6:08 ` Herbert Poetzl
  0 siblings, 1 reply; 14+ messages in thread
From: Joseph D. Wagner @ 2003-11-20 17:19 UTC (permalink / raw)
  To: linux-fsdevel

I'm writing a program that has to remount a file system on the fly for the 
purpose of changing the mount flags.

Is there any system function that can tell me what the mount flags are for a 
currently mounted file system?

TIA.

Joseph D. Wagner


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Remounting File Systems
  2003-11-21  4:48 ` Glynn Clements
@ 2003-11-20 18:03   ` Joseph D. Wagner
  2003-11-21  7:59     ` Glynn Clements
  0 siblings, 1 reply; 14+ messages in thread
From: Joseph D. Wagner @ 2003-11-20 18:03 UTC (permalink / raw)
  To: Glynn Clements; +Cc: linux-c-programming

> > I'm writing a program that has to remount a file system on the fly for
> > the purpose of changing the mount flags.
> >
> > Is there any system function that can tell me what the mount flags are
> > for a currently mounted file system?
>
> setmntent/getmntent/endmntent, possibly in conjunction with hasmntopt.

Nice try, but there's still the unlikely chance that /etc/fstab or /etc/mtab 
have not been updated to reflect the CURRENTLY MOUNTED file system.

Joseph D. Wagner


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Remounting File Systems
  2003-11-20 16:41 Remounting File Systems Joseph D. Wagner
@ 2003-11-21  4:48 ` Glynn Clements
  2003-11-20 18:03   ` Joseph D. Wagner
  2003-11-21 17:03 ` Jamie LeTual
  1 sibling, 1 reply; 14+ messages in thread
From: Glynn Clements @ 2003-11-21  4:48 UTC (permalink / raw)
  To: Joseph D. Wagner; +Cc: linux-c-programming


Joseph D. Wagner wrote:

> I'm writing a program that has to remount a file system on the fly for the 
> purpose of changing the mount flags.
> 
> Is there any system function that can tell me what the mount flags are for a 
> currently mounted file system?

setmntent/getmntent/endmntent, possibly in conjunction with hasmntopt.

-- 
Glynn Clements <glynn.clements@virgin.net>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Remounting File Systems
  2003-11-20 17:19 Joseph D. Wagner
@ 2003-11-21  6:08 ` Herbert Poetzl
  2003-11-21 19:25   ` Bryan Henderson
  0 siblings, 1 reply; 14+ messages in thread
From: Herbert Poetzl @ 2003-11-21  6:08 UTC (permalink / raw)
  To: Joseph D. Wagner; +Cc: linux-fsdevel

On Thu, Nov 20, 2003 at 11:19:23PM +0600, Joseph D. Wagner wrote:
> I'm writing a program that has to remount a file system on the fly for the 
> purpose of changing the mount flags.
> 
> Is there any system function that can tell me what the mount flags are for a 
> currently mounted file system?

no, but with a little luck, you can get this
information from /etc/mtab (luck means /etc/mtab
exists is writeable, and was used by mount ...)

HTH,
Herbert

> TIA.
> 
> Joseph D. Wagner
> 
> -
> To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Remounting File Systems
  2003-11-20 18:03   ` Joseph D. Wagner
@ 2003-11-21  7:59     ` Glynn Clements
  0 siblings, 0 replies; 14+ messages in thread
From: Glynn Clements @ 2003-11-21  7:59 UTC (permalink / raw)
  To: Joseph D. Wagner; +Cc: linux-c-programming


Joseph D. Wagner wrote:

> > > I'm writing a program that has to remount a file system on the fly for
> > > the purpose of changing the mount flags.
> > >
> > > Is there any system function that can tell me what the mount flags are
> > > for a currently mounted file system?
> >
> > setmntent/getmntent/endmntent, possibly in conjunction with hasmntopt.
> 
> Nice try, but there's still the unlikely chance that /etc/fstab or /etc/mtab 
> have not been updated to reflect the CURRENTLY MOUNTED file system.

In which case, I think that you're stuffed; /proc/mounts doesn't list
the mount flags (apart from ro/rw), [f]statfs() doesn't provide this
information, and I can't see any plausible-looking ioctl()s.

-- 
Glynn Clements <glynn.clements@virgin.net>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Remounting File Systems
  2003-11-20 16:41 Remounting File Systems Joseph D. Wagner
  2003-11-21  4:48 ` Glynn Clements
@ 2003-11-21 17:03 ` Jamie LeTual
  1 sibling, 0 replies; 14+ messages in thread
From: Jamie LeTual @ 2003-11-21 17:03 UTC (permalink / raw)
  To: Joseph D. Wagner; +Cc: linux-c-programming

Use the Source, Luke!

I would look at the source code for mount(8)

Peace,
Jamie

Joseph D. Wagner wrote:

>I'm writing a program that has to remount a file system on the fly for the 
>purpose of changing the mount flags.
>
>Is there any system function that can tell me what the mount flags are for a 
>currently mounted file system?
>
>TIA.
>
>Joseph D. Wagner
>
>-
>To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html
>  
>




^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Remounting File Systems
  2003-11-21  6:08 ` Herbert Poetzl
@ 2003-11-21 19:25   ` Bryan Henderson
  2003-11-21 19:40     ` Pat LaVarre
  2003-11-21 19:55     ` Herbert Poetzl
  0 siblings, 2 replies; 14+ messages in thread
From: Bryan Henderson @ 2003-11-21 19:25 UTC (permalink / raw)
  To: Herbert Poetzl; +Cc: linux-fsdevel, Joseph D. Wagner

>> Is there any system function that can tell me what the mount flags are 
for a 
>> currently mounted file system?

>with a little luck, you can get this
>information from /etc/mtab

With less luck, you can get some of the information directly from the 
kernel via /proc/mounts.

/etc/mtab tells you about past invocations of mount/unmount programs, 
whereas /proc/mounts tells you about what mounts presently exist.  So the 
information is a little different.

(/etc/mtab is a sloppy way of doing what it does, and at one time there 
were hopes of replacing it with /proc/mounts.  I use it that way -- my 
/etc/mtab is a symlink to /proc/mounts.  But I don't think that's very 
common).


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Remounting File Systems
  2003-11-21 19:25   ` Bryan Henderson
@ 2003-11-21 19:40     ` Pat LaVarre
  2003-11-22  3:36       ` Greg KH
  2003-11-21 19:55     ` Herbert Poetzl
  1 sibling, 1 reply; 14+ messages in thread
From: Pat LaVarre @ 2003-11-21 19:40 UTC (permalink / raw)
  To: hbryan; +Cc: linux-fsdevel, herbert, theman

> > > > what the mount flags are 
> > > > for a currently mounted file system?
> 
> > with a little luck, you can get this
> > information from /etc/mtab
> 
> With less luck, ... some ... info... from via /proc/mounts.
> 
> /etc/mtab tells you about past invocations of mount/unmount programs, 
> whereas /proc/mounts tells you about what mounts presently exist ...

/proc/mounts isn't going away with the change over to sysfs?

Yours in breathtaking ignorance, Pat LaVarre



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Remounting File Systems
  2003-11-21 19:25   ` Bryan Henderson
  2003-11-21 19:40     ` Pat LaVarre
@ 2003-11-21 19:55     ` Herbert Poetzl
  2003-11-21 21:14       ` Bryan Henderson
  2003-11-22 20:35       ` Eric Sandeen
  1 sibling, 2 replies; 14+ messages in thread
From: Herbert Poetzl @ 2003-11-21 19:55 UTC (permalink / raw)
  To: Bryan Henderson; +Cc: linux-fsdevel, Joseph D. Wagner

On Fri, Nov 21, 2003 at 11:25:08AM -0800, Bryan Henderson wrote:
> >> Is there any system function that can tell me what the mount flags are 
> for a 
> >> currently mounted file system?
> 
> >with a little luck, you can get this
> >information from /etc/mtab
> 
> With less luck, you can get some of the information directly from the 
> kernel via /proc/mounts.

well, I hate to disappoint people trying to help,
but if you take a look at the relevant sections
of the kernel (do_add_mount(), struct vfsmount,
mounts_open() and show_vfsmnt() for 2.4) you will 
see, that only a subset of the mount options is
stored and therefor can be retrieved from proc

just to make an example, the usrquota and grpquota
options passed on mount, will not be visible via
/proc but will be recorded in mtab

> /etc/mtab tells you about past invocations of mount/unmount programs, 
> whereas /proc/mounts tells you about what mounts presently exist.  So the 
> information is a little different.

agreed on that ;)

and it might be useful to check /proc/mounts if
/etc/mtab isn't present or does not contain useful
information about the mount in question.

> (/etc/mtab is a sloppy way of doing what it does, and at one time there 
> were hopes of replacing it with /proc/mounts.  I use it that way -- my 
> /etc/mtab is a symlink to /proc/mounts.  But I don't think that's very 
> common).

so for example, you will never be able to use 
ext2/3 with quota support, unless you hack the
tools to think quota is enabled ;)

best,
Herbert


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Remounting File Systems
  2003-11-21 19:55     ` Herbert Poetzl
@ 2003-11-21 21:14       ` Bryan Henderson
  2003-11-22 20:35       ` Eric Sandeen
  1 sibling, 0 replies; 14+ messages in thread
From: Bryan Henderson @ 2003-11-21 21:14 UTC (permalink / raw)
  To: Herbert Poetzl; +Cc: linux-fsdevel, Joseph D. Wagner

>>... my /etc/mtab is a symlink to /proc/mounts...
>
>so for example, you will never be able to use 
>ext2/3 with quota support, unless you hack the
>tools to think quota is enabled ;)

Actually, my strategy for such things is to hack the kernel to add the 
information to /proc/mounts.  I put a lot of effort into being righteous 
:).  However, it's all hypothetical now -- I haven't yet encountered (on 
my system) a case of such sophisticated use of /etc/mtab.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Remounting File Systems
  2003-11-21 19:40     ` Pat LaVarre
@ 2003-11-22  3:36       ` Greg KH
  2003-11-24  7:26         ` Christoph Hellwig
  0 siblings, 1 reply; 14+ messages in thread
From: Greg KH @ 2003-11-22  3:36 UTC (permalink / raw)
  To: Pat LaVarre; +Cc: hbryan, linux-fsdevel, herbert, theman

On Fri, Nov 21, 2003 at 12:40:16PM -0700, Pat LaVarre wrote:
> > > > > what the mount flags are 
> > > > > for a currently mounted file system?
> > 
> > > with a little luck, you can get this
> > > information from /etc/mtab
> > 
> > With less luck, ... some ... info... from via /proc/mounts.
> > 
> > /etc/mtab tells you about past invocations of mount/unmount programs, 
> > whereas /proc/mounts tells you about what mounts presently exist ...
> 
> /proc/mounts isn't going away with the change over to sysfs?

In 2.7, possibly.  For 2.6, no.

greg k-h

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Remounting File Systems
  2003-11-21 19:55     ` Herbert Poetzl
  2003-11-21 21:14       ` Bryan Henderson
@ 2003-11-22 20:35       ` Eric Sandeen
  1 sibling, 0 replies; 14+ messages in thread
From: Eric Sandeen @ 2003-11-22 20:35 UTC (permalink / raw)
  To: Herbert Poetzl; +Cc: Bryan Henderson, linux-fsdevel, Joseph D. Wagner

> well, I hate to disappoint people trying to help,
> but if you take a look at the relevant sections
> of the kernel (do_add_mount(), struct vfsmount,
> mounts_open() and show_vfsmnt() for 2.4) you will 
> see, that only a subset of the mount options is
> stored and therefor can be retrieved from proc
>
> just to make an example, the usrquota and grpquota
> options passed on mount, will not be visible via
> /proc but will be recorded in mtab

That depends  on whether the filesystem has hooked
up "show_options" in the superblock operations:

[root@lite root]# mount -t xfs -o usrquota /dev/sda1 /mnt/sda1
[root@lite root]# grep sda1 /proc/mounts
/dev/sda1 /mnt/sda1 xfs rw,usrquota 0 0
[root@lite root]# grep sda1 /etc/mtab
/dev/sda1 /mnt/sda1 xfs rw,usrquota 0 0

[root@lite root]# mount -t ext3 -o usrquota /dev/sda2 /mnt/sda2
[root@lite root]# grep sda2 /proc/mounts
/dev/sda2 /mnt/sda2 ext3 rw 0 0
[root@lite root]# grep sda2 /etc/mtab
/dev/sda2 /mnt/sda2 ext3 rw,usrquota 0 0


-Eric


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Remounting File Systems
  2003-11-22  3:36       ` Greg KH
@ 2003-11-24  7:26         ` Christoph Hellwig
  0 siblings, 0 replies; 14+ messages in thread
From: Christoph Hellwig @ 2003-11-24  7:26 UTC (permalink / raw)
  To: Greg KH; +Cc: Pat LaVarre, hbryan, linux-fsdevel, herbert, theman

On Fri, Nov 21, 2003 at 07:36:30PM -0800, Greg KH wrote:
> On Fri, Nov 21, 2003 at 12:40:16PM -0700, Pat LaVarre wrote:
> > > > > > what the mount flags are 
> > > > > > for a currently mounted file system?
> > > 
> > > > with a little luck, you can get this
> > > > information from /etc/mtab
> > > 
> > > With less luck, ... some ... info... from via /proc/mounts.
> > > 
> > > /etc/mtab tells you about past invocations of mount/unmount programs, 
> > > whereas /proc/mounts tells you about what mounts presently exist ...
> > 
> > /proc/mounts isn't going away with the change over to sysfs?
> 
> In 2.7, possibly.  For 2.6, no.

well, /proc/self/mounts certainly is not going away, because it's one of
the few proper procfs uses.  And just removing the copat symlink for the
sake of it doesn't sound like a really good idea to me..


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2003-11-24  7:26 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-11-20 16:41 Remounting File Systems Joseph D. Wagner
2003-11-21  4:48 ` Glynn Clements
2003-11-20 18:03   ` Joseph D. Wagner
2003-11-21  7:59     ` Glynn Clements
2003-11-21 17:03 ` Jamie LeTual
  -- strict thread matches above, loose matches on Subject: below --
2003-11-20 17:19 Joseph D. Wagner
2003-11-21  6:08 ` Herbert Poetzl
2003-11-21 19:25   ` Bryan Henderson
2003-11-21 19:40     ` Pat LaVarre
2003-11-22  3:36       ` Greg KH
2003-11-24  7:26         ` Christoph Hellwig
2003-11-21 19:55     ` Herbert Poetzl
2003-11-21 21:14       ` Bryan Henderson
2003-11-22 20:35       ` Eric Sandeen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.