libmount and findmnt(8)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'd like to merge libmount and findmnt(8) into util-linux-ng in next
days. Currently, this stuff is at:

   git://git.kernel.org/pub/scm/utils/util-linux-ng/kzak/libmount.git

The libmount library is designed to be used in low-level utils like
mount(8) and /sbin/mount.<type> helpers as well as in some other
projects (for example autofs and systemd come to mind).

The library API is still officially unstable and my plan is to keep it
unstable for the next util-linux-ng release.

The existing utils like mount(8) or umount(8) won't be linked against
the library in the next release (plan is to have 2.18-rc1 this week).
This invasive change is planned for util-linux-ng-2.19 (October/November).

Features (already implemented):

   * allows to set/get/remove mount options from a string
   * simple mount options parser
   * high-level extensible mount options parser
     - mount options are described by "mount options maps" and it's
       possible to create FS specific map; built-in are maps with
       userspace mount options and kernel FS independent options
     - this parser allows to generate data and flags for mount(2)
   * fstab, mtab and /proc/self/mountinfo parser
   * allows to search in parsed fstab, mtab and mountinfo files
     - these functions cover all possibilities like LABEL vs. UUID vs. devname, 
       canonicalized vs. non-canonicalized paths, etc.
     - all LABEL/UUID operations are hidden, the library uses libblkid
       for tags evaluation
   * old mtab locking methods (necessary for backward compatibility)
   * utils for fstype and mount options matching (see -t and -O in mount.8)
   
Planned features (near future -- 2.19):

   * support /etc/fstab.d/
   * support systems without /etc/mtab
     - one API for work with mtab on systems with or without /etc/mtab
     - maintain userspace specific mount options in /var/run/libmount
   * monitor VFS changes (poll(/proc/self/mountinfo)), something like
     $ findmnt --monitor /home/foo
   * hing-level API for mount(2) to avoid exec(/bin/mount) in some programs
     

The findmnt(8) is a new util linked against libmount. This util is a
command line interface for all look-up functionality in the library. It's 
designed to be used in init scripts or from command line (use grep(1) is 
a bad idea). See below for examples.

 Comments & wishes & suggestions?

	Karel


$ findmnt
TARGET                       SOURCE                FSTYPE   OPTIONS
/                            /dev/sda4             ext3     rw,noatime,errors=co
├─/proc                      /proc                 proc     rw,relatime
│ ├─/proc/bus/usb            /proc/bus/usb         usbfs    rw,relatime
│ └─/proc/sys/fs/binfmt_misc none                  binfmt_m rw,relatime
├─/sys                       /sys                  sysfs    rw,relatime
├─/dev                       udev                  devtmpfs rw,relatime,size=197
│ ├─/dev/pts                 devpts                devpts   rw,relatime,gid=5,mo
│ └─/dev/shm                 tmpfs                 tmpfs    rw,relatime
├─/boot                      /dev/sda1             ext3     rw,noatime,errors=co
├─/home/kzak                 /dev/mapper/kzak-home ext4     rw,noatime,barrier=1
│ └─/home/kzak/.gvfs         gvfs-fuse-daemon      fuse.gvf rw,nosuid,nodev,rela
└─/var/lib/nfs/rpc_pipefs    sunrpc                rpc_pipe rw,relatime


$ findmnt --fstab -t ext3
TARGET SOURCE                                    FSTYPE OPTIONS
/      UUID=d3a8f783-df75-4dc8-9163-975a891052c0 ext3   noatime,defaults
/boot  UUID=f1cd38fa-c887-4ab8-834b-c8ee659b97fe ext3   noatime,defaults


$ findmnt --fstab --evaluate -t ext3
TARGET SOURCE    FSTYPE OPTIONS
/      /dev/sda4 ext3   noatime,defaults
/boot  /dev/sda1 ext3   noatime,defaults


$ findmnt --help

Usage:
 findmnt [options]
 findmnt [options] <device> | <mountpoint>
 findmnt [options] <device> <mountpoint>
 findmnt [options] [--source <device>] [--target <mountpoint>]

Options:
 -s, --fstab            search in static table of filesystems
 -m, --mtab             search in table of mounted filesystems
 -k, --kernel           search in kernel table of mounted 
                        filesystems (default)

 -c, --canonicalize     canonicalize printed paths
 -d, --direction <word> search direction - 'forward' or 'backward'
 -e, --evaluate         print all TAGs (LABEL/UUID) evaluated
 -f, --first-only       print the first found filesystem only
 -h, --help             print this help
 -i, --invert           invert sense of matching
 -l, --list             use list format ouput
 -n, --noheadings       don't print headings
 -u, --notruncate       don't truncate text in columns
 -O, --options <list>   limit the set of filesystems by mount options
 -o, --output <list>    output columns
 -r, --raw              use raw format output
 -a, --ascii            use ascii chars for tree formatting
 -t, --types <list>     limit the set of filesystem by FS types
 -S, --source <string>  device, LABEL= or UUID=device
 -T, --target <string>  mountpoint

For more information see findmnt(1).

-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux