if (!fs)
fprintf(stderr, "%s: not found %s '%s'\n", file, find, what);
else {
- const char *s = mnt_fs_get_srcpath(fs);
- if (s)
- printf("%s", s);
- else {
- const char *tag, *val;
- mnt_fs_get_tag(fs, &tag, &val);
- printf("%s=%s", tag, val);
- }
- printf("|%s|%s\n", mnt_fs_get_target(fs),
- mnt_fs_get_optstr(fs));
+ mnt_fs_print_debug(fs, stdout);
rc = 0;
}
done:
-top_builddir=@top_builddir@
-top_srcdir=@top_srcdir@
+top_builddir=@abs_top_builddir@
+top_srcdir=@abs_top_srcdir@
# Misc settings
TS_TESTUSER=${TS_TESTUSER:-"test"}
TS_HELPER_STRTOSIZE="$top_builddir/lib/test_strtosize"
TS_HELPER_CPUSET="$top_builddir/lib/test_cpuset"
+# libmount
TS_HELPER_OPTSTR="$top_builddir/shlibs/mount/src/test_optstr"
+TS_HELPER_TABFILES="$top_builddir/shlibs/mount/src/test_tab"
# TODO: use partx
TS_HELPER_PARTITIONS="$top_builddir/shlibs/blkid/samples/partitions"
--- /dev/null
+ORIGINAL:
+------ fs:
+source: UUID=d3a8f783-df75-4dc8-9163-975a891052c0
+target: /
+fstype: ext3
+optstr: noatime,defaults
+freq: 1
+pass: 1
+COPY:
+------ fs:
+source: UUID=d3a8f783-df75-4dc8-9163-975a891052c0
+target: /
+fstype: ext3
+optstr: noatime,defaults
+freq: 1
+pass: 1
--- /dev/null
+------ fs:
+source: UUID=fef7ccb3-821c-4de8-88dc-71472be5946f
+target: /boot
+fstype: ext3
+optstr: noatime,defaults
+freq: 1
+pass: 2
--- /dev/null
+------ fs:
+source: /dev/mapper/foo
+target: /home/foo
+fstype: ext4
+optstr: noatime,defaults
--- /dev/null
+------ fs:
+source: UUID=d3a8f783-df75-4dc8-9163-975a891052c0
+target: /
+fstype: ext3
+optstr: noatime,defaults
+freq: 1
+pass: 1
+------ fs:
+source: UUID=fef7ccb3-821c-4de8-88dc-71472be5946f
+target: /boot
+fstype: ext3
+optstr: noatime,defaults
+freq: 1
+pass: 2
+------ fs:
+source: UUID=1f2aa318-9c34-462e-8d29-260819ffd657
+target: swap
+fstype: swap
+optstr: defaults
+------ fs:
+source: tmpfs
+target: /dev/shm
+fstype: tmpfs
+optstr: defaults
+------ fs:
+source: devpts
+target: /dev/pts
+fstype: devpts
+optstr: gid=5,mode=620
+------ fs:
+source: sysfs
+target: /sys
+fstype: sysfs
+optstr: defaults
+------ fs:
+source: proc
+target: /proc
+fstype: proc
+optstr: defaults
+------ fs:
+source: /dev/mapper/foo
+target: /home/foo
+fstype: ext4
+optstr: noatime,defaults
+------ fs:
+source: foo.com:/mnt/share
+target: /mnt/remote
+fstype: nfs
+optstr: noauto
+------ fs:
+source: //bar.com/gogogo
+target: /mnt/gogogo
+fstype: cifs
+optstr: user=SRGROUP/baby,noauto
--- /dev/null
+
+
+------ fs:
+source: UUID=d3a8f783-df75-4dc8-9163-975a891052c0
+target: /
+fstype: ext3
+optstr: noatime,defaults
+freq: 1
+pass: 1
+------ fs:
+source: UUID=fef7ccb3-821c-4de8-88dc-71472be5946f
+target: /boot
+fstype: ext3
+optstr: noatime,defaults
+freq: 1
+pass: 2
+------ fs:
+source: UUID=1f2aa318-9c34-462e-8d29-260819ffd657
+target: swap
+fstype: swap
+optstr: defaults
+------ fs:
+source: tmpfs
+target: /dev/shm
+fstype: tmpfs
+optstr: defaults
+------ fs:
+source: devpts
+target: /dev/pts
+fstype: devpts
+optstr: gid=5,mode=620
+------ fs:
+source: sysfs
+target: /sys
+fstype: sysfs
+optstr: defaults
+------ fs:
+source: proc
+target: /proc
+fstype: proc
+optstr: defaults
+------ fs:
+source: /dev/mapper/foo
+target: /home/foo
+fstype: ext4
+optstr: noatime,defaults
+freq: 1
+------ fs:
+source: foo.com:/mnt/share
+target: /mnt/remote
+fstype: nfs
+optstr: noauto
+------ fs:
+source: //bar.com/gogogo
+target: /mnt/gogogo
+fstype: cifs
+optstr: user=SRGROUP/baby,noauto
--- /dev/null
+------ fs:
+source: /proc
+target: /proc
+fstype: proc
+optstr: rw,relatime
+id: 15
+parent: 20
+devno: 0:3
+------ fs:
+source: /sys
+target: /sys
+fstype: sysfs
+optstr: rw,relatime
+id: 16
+parent: 20
+devno: 0:15
+------ fs:
+source: udev
+target: /dev
+fstype: devtmpfs
+optstr: rw,relatime,size=1983516k,nr_inodes=495879,mode=755
+id: 17
+parent: 20
+devno: 0:5
+------ fs:
+source: devpts
+target: /dev/pts
+fstype: devpts
+optstr: rw,relatime,gid=5,mode=620,ptmxmode=000
+id: 18
+parent: 17
+devno: 0:10
+------ fs:
+source: tmpfs
+target: /dev/shm
+fstype: tmpfs
+optstr: rw,relatime
+id: 19
+parent: 17
+devno: 0:16
+------ fs:
+source: /dev/sda4
+target: /
+fstype: ext3
+optstr: rw,noatime,errors=continue,user_xattr,acl,barrier=0,data=ordered
+id: 20
+parent: 1
+devno: 8:4
+------ fs:
+source: tmpfs
+target: /sys/fs/cgroup
+fstype: tmpfs
+optstr: rw,nosuid,nodev,noexec,relatime,mode=755
+id: 21
+parent: 16
+devno: 0:17
+------ fs:
+source: cgroup
+target: /sys/fs/cgroup/systemd
+fstype: cgroup
+optstr: rw,nosuid,nodev,noexec,relatime,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd
+id: 22
+parent: 21
+devno: 0:18
+------ fs:
+source: cgroup
+target: /sys/fs/cgroup/cpuset
+fstype: cgroup
+optstr: rw,nosuid,nodev,noexec,relatime,cpuset
+id: 23
+parent: 21
+devno: 0:19
+------ fs:
+source: cgroup
+target: /sys/fs/cgroup/ns
+fstype: cgroup
+optstr: rw,nosuid,nodev,noexec,relatime,ns
+id: 24
+parent: 21
+devno: 0:20
+------ fs:
+source: cgroup
+target: /sys/fs/cgroup/cpu
+fstype: cgroup
+optstr: rw,nosuid,nodev,noexec,relatime,cpu
+id: 25
+parent: 21
+devno: 0:21
+------ fs:
+source: cgroup
+target: /sys/fs/cgroup/cpuacct
+fstype: cgroup
+optstr: rw,nosuid,nodev,noexec,relatime,cpuacct
+id: 26
+parent: 21
+devno: 0:22
+------ fs:
+source: cgroup
+target: /sys/fs/cgroup/memory
+fstype: cgroup
+optstr: rw,nosuid,nodev,noexec,relatime,memory
+id: 27
+parent: 21
+devno: 0:23
+------ fs:
+source: cgroup
+target: /sys/fs/cgroup/devices
+fstype: cgroup
+optstr: rw,nosuid,nodev,noexec,relatime,devices
+id: 28
+parent: 21
+devno: 0:24
+------ fs:
+source: cgroup
+target: /sys/fs/cgroup/freezer
+fstype: cgroup
+optstr: rw,nosuid,nodev,noexec,relatime,freezer
+id: 29
+parent: 21
+devno: 0:25
+------ fs:
+source: cgroup
+target: /sys/fs/cgroup/net_cls
+fstype: cgroup
+optstr: rw,nosuid,nodev,noexec,relatime,net_cls
+id: 30
+parent: 21
+devno: 0:26
+------ fs:
+source: cgroup
+target: /sys/fs/cgroup/blkio
+fstype: cgroup
+optstr: rw,nosuid,nodev,noexec,relatime,blkio
+id: 31
+parent: 21
+devno: 0:27
+------ fs:
+source: systemd-1
+target: /sys/kernel/security
+fstype: autofs
+optstr: rw,relatime,fd=22,pgrp=1,timeout=300,minproto=5,maxproto=5,direct
+id: 32
+parent: 16
+devno: 0:28
+------ fs:
+source: systemd-1
+target: /dev/hugepages
+fstype: autofs
+optstr: rw,relatime,fd=23,pgrp=1,timeout=300,minproto=5,maxproto=5,direct
+id: 33
+parent: 17
+devno: 0:29
+------ fs:
+source: systemd-1
+target: /sys/kernel/debug
+fstype: autofs
+optstr: rw,relatime,fd=24,pgrp=1,timeout=300,minproto=5,maxproto=5,direct
+id: 34
+parent: 16
+devno: 0:30
+------ fs:
+source: systemd-1
+target: /proc/sys/fs/binfmt_misc
+fstype: autofs
+optstr: rw,relatime,fd=25,pgrp=1,timeout=300,minproto=5,maxproto=5,direct
+id: 35
+parent: 15
+devno: 0:31
+------ fs:
+source: systemd-1
+target: /dev/mqueue
+fstype: autofs
+optstr: rw,relatime,fd=26,pgrp=1,timeout=300,minproto=5,maxproto=5,direct
+id: 36
+parent: 17
+devno: 0:32
+------ fs:
+source: /proc/bus/usb
+target: /proc/bus/usb
+fstype: usbfs
+optstr: rw,relatime
+id: 37
+parent: 15
+devno: 0:14
+------ fs:
+source: hugetlbfs
+target: /dev/hugepages
+fstype: hugetlbfs
+optstr: rw,relatime
+id: 38
+parent: 33
+devno: 0:33
+------ fs:
+source: mqueue
+target: /dev/mqueue
+fstype: mqueue
+optstr: rw,relatime
+id: 39
+parent: 36
+devno: 0:12
+------ fs:
+source: /dev/sda6
+target: /boot
+fstype: ext3
+optstr: rw,noatime,errors=continue,barrier=0,data=ordered
+id: 40
+parent: 20
+devno: 8:6
+------ fs:
+source: /dev/mapper/kzak-home
+target: /home/kzak
+fstype: ext4
+optstr: rw,noatime,barrier=1,data=ordered
+id: 41
+parent: 20
+devno: 253:0
+------ fs:
+source: (null)
+target: /proc/sys/fs/binfmt_misc
+fstype: binfmt_misc
+optstr: rw,relatime
+id: 42
+parent: 35
+devno: 0:34
+------ fs:
+source: fusectl
+target: /sys/fs/fuse/connections
+fstype: fusectl
+optstr: rw,relatime
+id: 43
+parent: 16
+devno: 0:35
+------ fs:
+source: gvfs-fuse-daemon
+target: /home/kzak/.gvfs
+fstype: fuse.gvfs-fuse-daemon
+optstr: rw,nosuid,nodev,relatime,user_id=500,group_id=500
+id: 44
+parent: 41
+devno: 0:36
+------ fs:
+source: sunrpc
+target: /var/lib/nfs/rpc_pipefs
+fstype: rpc_pipefs
+optstr: rw,relatime
+id: 45
+parent: 20
+devno: 0:37
+------ fs:
+source: //foo.home/bar/
+target: /mnt/sounds
+fstype: cifs
+optstr: rw,relatime,unc=\\foo.home\bar,username=kzak,domain=SRGROUP,uid=0,noforceuid,gid=0,noforcegid,addr=192.168.111.1,posixpaths,serverino,acl,rsize=16384,wsize=57344
+id: 47
+parent: 20
+devno: 0:38
--- /dev/null
+UUID=d3a8f783-df75-4dc8-9163-975a891052c0 / ext3 noatime,defaults 1 1
+UUID=fef7ccb3-821c-4de8-88dc-71472be5946f /boot ext3 noatime,defaults 1 2
+UUID=1f2aa318-9c34-462e-8d29-260819ffd657 swap swap defaults 0 0
+tmpfs /dev/shm tmpfs defaults 0 0
+devpts /dev/pts devpts gid=5,mode=620 0 0
+sysfs /sys sysfs defaults 0 0
+proc /proc proc defaults 0 0
+# this is comment
+/dev/mapper/foo /home/foo ext4 noatime,defaults 0 0
+
+foo.com:/mnt/share /mnt/remote nfs noauto
+//bar.com/gogogo /mnt/gogogo cifs user=SRGROUP/baby,noauto
--- /dev/null
+bug
+UUID=d3a8f783-df75-4dc8-9163-975a891052c0 / ext3 noatime,defaults 1 1
+UUID=fef7ccb3-821c-4de8-88dc-71472be5946f /boot ext3 noatime,defaults 1 2
+ UUID=1f2aa318-9c34-462e-8d29-260819ffd657 swap swap defaults 0 0
+tmpfs /dev/shm tmpfs defaults 0 0
+devpts /dev/pts devpts gid=5,mode=620
+ sysfs /sys sysfs defaults 0 0
+this is broken line with unexpected number of fields
+proc /proc proc defaults 0 0
+# this is comment
+/dev/mapper/foo /home/foo ext4 noatime,defaults 1
+
+foo.com:/mnt/share /mnt/remote nfs noauto
+//bar.com/gogogo /mnt/gogogo cifs user=SRGROUP/baby,noauto
--- /dev/null
+15 20 0:3 / /proc rw,relatime - proc /proc rw
+16 20 0:15 / /sys rw,relatime - sysfs /sys rw
+17 20 0:5 / /dev rw,relatime - devtmpfs udev rw,size=1983516k,nr_inodes=495879,mode=755
+18 17 0:10 / /dev/pts rw,relatime - devpts devpts rw,gid=5,mode=620,ptmxmode=000
+19 17 0:16 / /dev/shm rw,relatime - tmpfs tmpfs rw
+20 1 8:4 / / rw,noatime - ext3 /dev/sda4 rw,errors=continue,user_xattr,acl,barrier=0,data=ordered
+21 16 0:17 / /sys/fs/cgroup rw,nosuid,nodev,noexec,relatime - tmpfs tmpfs rw,mode=755
+22 21 0:18 / /sys/fs/cgroup/systemd rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd
+23 21 0:19 / /sys/fs/cgroup/cpuset rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,cpuset
+24 21 0:20 / /sys/fs/cgroup/ns rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,ns
+25 21 0:21 / /sys/fs/cgroup/cpu rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,cpu
+26 21 0:22 / /sys/fs/cgroup/cpuacct rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,cpuacct
+27 21 0:23 / /sys/fs/cgroup/memory rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,memory
+28 21 0:24 / /sys/fs/cgroup/devices rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,devices
+29 21 0:25 / /sys/fs/cgroup/freezer rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,freezer
+30 21 0:26 / /sys/fs/cgroup/net_cls rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,net_cls
+31 21 0:27 / /sys/fs/cgroup/blkio rw,nosuid,nodev,noexec,relatime - cgroup cgroup rw,blkio
+32 16 0:28 / /sys/kernel/security rw,relatime - autofs systemd-1 rw,fd=22,pgrp=1,timeout=300,minproto=5,maxproto=5,direct
+33 17 0:29 / /dev/hugepages rw,relatime - autofs systemd-1 rw,fd=23,pgrp=1,timeout=300,minproto=5,maxproto=5,direct
+34 16 0:30 / /sys/kernel/debug rw,relatime - autofs systemd-1 rw,fd=24,pgrp=1,timeout=300,minproto=5,maxproto=5,direct
+35 15 0:31 / /proc/sys/fs/binfmt_misc rw,relatime - autofs systemd-1 rw,fd=25,pgrp=1,timeout=300,minproto=5,maxproto=5,direct
+36 17 0:32 / /dev/mqueue rw,relatime - autofs systemd-1 rw,fd=26,pgrp=1,timeout=300,minproto=5,maxproto=5,direct
+37 15 0:14 / /proc/bus/usb rw,relatime - usbfs /proc/bus/usb rw
+38 33 0:33 / /dev/hugepages rw,relatime - hugetlbfs hugetlbfs rw
+39 36 0:12 / /dev/mqueue rw,relatime - mqueue mqueue rw
+40 20 8:6 / /boot rw,noatime - ext3 /dev/sda6 rw,errors=continue,barrier=0,data=ordered
+41 20 253:0 / /home/kzak rw,noatime - ext4 /dev/mapper/kzak-home rw,barrier=1,data=ordered
+42 35 0:34 / /proc/sys/fs/binfmt_misc rw,relatime - binfmt_misc none rw
+43 16 0:35 / /sys/fs/fuse/connections rw,relatime - fusectl fusectl rw
+44 41 0:36 / /home/kzak/.gvfs rw,nosuid,nodev,relatime - fuse.gvfs-fuse-daemon gvfs-fuse-daemon rw,user_id=500,group_id=500
+45 20 0:37 / /var/lib/nfs/rpc_pipefs rw,relatime - rpc_pipefs sunrpc rw
+47 20 0:38 / /mnt/sounds rw,relatime - cifs //foo.home/bar/ rw,unc=\\foo.home\bar,username=kzak,domain=SRGROUP,uid=0,noforceuid,gid=0,noforcegid,addr=192.168.111.1,posixpaths,serverino,acl,rsize=16384,wsize=57344
--- /dev/null
+#!/bin/bash
+
+# Copyright (C) 2010 Karel Zak <kzak@redhat.com>
+
+TS_TOPDIR="$(dirname $0)/../.."
+TS_DESC="tab files"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+TESTPROG="$TS_HELPER_TABFILES"
+
+ts_init_subtest "parse-fstab"
+$TESTPROG --parse "$TS_SELF/files/fstab" &> $TS_OUTPUT
+sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "parse-fstab-broken"
+$TESTPROG --parse "$TS_SELF/files/fstab.broken" &> $TS_OUTPUT
+sed -i -e 's/.*fstab.broken:[[:digit:]]*: parse error//g; s/fs: 0x.*/fs:/g' $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "parse-mountinfo"
+$TESTPROG --parse "$TS_SELF/files/mountinfo" &> $TS_OUTPUT
+sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "copy"
+$TESTPROG --copy-fs "$TS_SELF/files/fstab" &> $TS_OUTPUT
+sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "find-source"
+$TESTPROG --find-forward "$TS_SELF/files/fstab" source UUID=fef7ccb3-821c-4de8-88dc-71472be5946f &> $TS_OUTPUT
+sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "find-target"
+$TESTPROG --find-forward "$TS_SELF/files/fstab" target /home/foo &> $TS_OUTPUT
+sed -i -e 's/fs: 0x.*/fs:/g' $TS_OUTPUT
+ts_finalize_subtest
+
+ts_finalize