Hi all, I am looking for a way to detect the file system a certain file lives and next whether this file system is mounted/accessible as writable. [1] As stat(1) is helping me out to found out the proper device name/number of a certain file with the command `stat -f "%d" /etc/motd`, but next will be the mapping from this device number (st_dev) to the proper partion/mount point. Which handy shell utility program will help me doing this? Or even better what are the proper search terms to find this answer, as mine attempts on the mailing archives, man pages and Google where not very successful Thanks a lot! /Rick [1] Part of getting rid of the annoying motd update failure message, when /etc is not writable. I know setting update_motd=NO in /etc/rc.conf will do the trick as well, but I would like to see him detecting it auto-magically ;-)
Hi, On Wed, Mar 05, 2008 at 11:07:28AM +0100, Rick van der Zwet wrote:> Which handy shell utility program will help me doing this?I think you can use statfs(2) to look up the f_fsid, this should be equal to the st_dev, judging from the code in kern/vfs_syscalls.c. There doesn't appear to be a shell utility to statfs(2), but you may be able to hack something up in perl or simular. Regards, -- Rink P.W. Springer - http://rink.nu "Anyway boys, this is America. Just because you get more votes doesn't mean you win." - Fox Mulder
On Wed, Mar 05, 2008 at 11:07:28AM +0100, Rick van der Zwet wrote:> Hi all, > > I am looking for a way to detect the file system a certain file lives > and next whether this file system is mounted/accessible as writable. [1] > > As stat(1) is helping me out to found out the proper device name/number > of a certain file with the command `stat -f "%d" /etc/motd`, but next > will be the mapping from this device number (st_dev) to the proper > partion/mount point. > > Which handy shell utility program will help me doing this?fstat(1) sounds like it might be of help here. If you're writing a C program for this, the source code is in src/usr.bin/fstat.> [1] Part of getting rid of the annoying motd update failure message, > when /etc is not writable. I know setting update_motd=NO in > /etc/rc.conf will do the trick as well, but I would like to see him > detecting it auto-magically ;-)I haven't seen the "auto-updating motd" feature of FreeBSD since the 3.x days. Are you referring to the "annoyance" where during mergemaster(1), you can nuke your /etc/motd? If so, try IGNORE_MOTD=yes in /etc/mergemaster.rc. -- | Jeremy Chadwick jdc at parodius.com | | Parodius Networking http://www.parodius.com/ | | UNIX Systems Administrator Mountain View, CA, USA | | Making life hard for others since 1977. PGP: 4BD6C0CB |