4 * Copyright (C) 2010,2011 Red Hat, Inc. All rights reserved.
5 * Written by Karel Zak <kzak@redhat.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it would be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software Foundation,
19 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #ifdef HAVE_SYS_IOCTL_H
29 #include <sys/ioctl.h>
34 #define USE_UNSTABLE_LIBMOUNT_API
37 #include "pathnames.h"
45 FL_EVALUATE
= (1 << 1),
46 FL_CANONICALIZE
= (1 << 2),
47 FL_FIRSTONLY
= (1 << 3),
49 FL_NOSWAPMATCH
= (1 << 6),
50 FL_NOFSROOT
= (1 << 7),
51 FL_SUBMOUNTS
= (1 << 8),
75 const char *name
; /* header */
76 double whint
; /* width hint (N < 1 is in percent of termwidth) */
77 int flags
; /* tt flags */
78 const char *match
; /* pattern for match_func() */
81 /* columns descriptions */
82 struct colinfo infos
[__NCOLUMNS
] = {
83 [COL_SOURCE
] = { "SOURCE", 0.25 },
84 [COL_TARGET
] = { "TARGET", 0.30, TT_FL_TREE
},
85 [COL_FSTYPE
] = { "FSTYPE", 0.10, TT_FL_TRUNC
},
86 [COL_OPTIONS
] = { "OPTIONS", 0.10, TT_FL_TRUNC
},
87 [COL_VFS_OPTIONS
] = { "VFS-OPTIONS", 0.20, TT_FL_TRUNC
},
88 [COL_FS_OPTIONS
] = { "FS-OPTIONS", 0.10, TT_FL_TRUNC
},
89 [COL_LABEL
] = { "LABEL", 0.10 },
90 [COL_UUID
] = { "UUID", 36 },
91 [COL_MAJMIN
] = { "MAJ:MIN", 6 },
92 [COL_ACTION
] = { "ACTION", 10, TT_FL_STRICTWIDTH
},
93 [COL_OLD_OPTIONS
] = { "OLD-OPTIONS", 0.10, TT_FL_TRUNC
},
94 [COL_OLD_TARGET
] = { "OLD-TARGET", 0.30 },
101 /* array with IDs of enabled columns */
102 int columns
[__NCOLUMNS
];
106 struct libmnt_cache
*cache
;
108 static int get_column_id(int num
)
110 assert(num
< ncolumns
);
111 assert(columns
[num
] < __NCOLUMNS
);
115 static struct colinfo
*get_column_info(int num
)
117 return &infos
[ get_column_id(num
) ];
120 static const char *column_id_to_name(int id
)
122 assert(id
< __NCOLUMNS
);
123 return infos
[id
].name
;
126 static const char *get_column_name(int num
)
128 return get_column_info(num
)->name
;
131 static float get_column_whint(int num
)
133 return get_column_info(num
)->whint
;
136 static int get_column_flags(int num
)
138 return get_column_info(num
)->flags
;
141 static const char *get_match(int id
)
143 assert(id
< __NCOLUMNS
);
144 return infos
[id
].match
;
147 static void set_match(int id
, const char *match
)
149 assert(id
< __NCOLUMNS
);
150 infos
[id
].match
= match
;
153 static int is_tabdiff_column(int id
)
155 assert(id
< __NCOLUMNS
);
160 case COL_OLD_OPTIONS
:
169 * "findmnt" without any filter
171 static int is_listall_mode(void)
173 return (!get_match(COL_SOURCE
) &&
174 !get_match(COL_TARGET
) &&
175 !get_match(COL_FSTYPE
) &&
176 !get_match(COL_OPTIONS
));
180 * findmnt --first-only <devname|TAG=|mountpoint>
182 * ... it works like "mount <devname|TAG=|mountpoint>"
184 static int is_mount_compatible_mode(void)
186 if (!get_match(COL_SOURCE
))
187 return 0; /* <devname|TAG=|mountpoint> is required */
188 if (get_match(COL_FSTYPE
) || get_match(COL_OPTIONS
))
189 return 0; /* cannot be restricted by -t or -O */
190 if (!(flags
& FL_FIRSTONLY
))
191 return 0; /* we have to return the first entry only */
196 static void disable_columns_truncate(void)
200 for (i
= 0; i
< __NCOLUMNS
; i
++)
201 infos
[i
].flags
&= ~TT_FL_TRUNC
;
205 * converts @name to column ID
207 static int column_name_to_id(const char *name
, size_t namesz
)
211 for (i
= 0; i
< __NCOLUMNS
; i
++) {
212 const char *cn
= column_id_to_name(i
);
214 if (!strncasecmp(name
, cn
, namesz
) && !*(cn
+ namesz
))
217 warnx(_("unknown column: %s"), name
);
221 /* Returns LABEL or UUID */
222 static const char *get_tag(struct libmnt_fs
*fs
, const char *tagname
)
224 const char *t
, *v
, *res
;
226 if (!mnt_fs_get_tag(fs
, &t
, &v
) && !strcmp(t
, tagname
))
229 res
= mnt_fs_get_source(fs
);
231 res
= mnt_resolve_spec(res
, cache
);
233 res
= mnt_cache_find_tag_value(cache
, res
, tagname
);
239 /* reads FS data from libmount
240 * TODO: add function that will deallocate data allocated by get_data()
242 static const char *get_data(struct libmnt_fs
*fs
, int num
)
244 const char *str
= NULL
;
246 switch(get_column_id(num
)) {
249 const char *root
= mnt_fs_get_root(fs
);
251 str
= mnt_fs_get_srcpath(fs
);
253 if (str
&& (flags
& FL_CANONICALIZE
))
254 str
= mnt_resolve_path(str
, cache
);
256 str
= mnt_fs_get_source(fs
);
258 if (str
&& (flags
& FL_EVALUATE
))
259 str
= mnt_resolve_spec(str
, cache
);
261 if (root
&& str
&& !(flags
& FL_NOFSROOT
) && strcmp(root
, "/")) {
264 if (asprintf(&tmp
, "%s[%s]", str
, root
) > 0)
270 str
= mnt_fs_get_target(fs
);
273 str
= mnt_fs_get_fstype(fs
);
276 str
= mnt_fs_strdup_options(fs
);
278 case COL_VFS_OPTIONS
:
279 str
= mnt_fs_get_vfs_options(fs
);
282 str
= mnt_fs_get_fs_options(fs
);
285 str
= get_tag(fs
, "UUID");
288 str
= get_tag(fs
, "LABEL");
292 dev_t devno
= mnt_fs_get_devno(fs
);
296 if (tt_flags
& TT_FL_RAW
)
297 rc
= asprintf(&tmp
, "%u:%u",
298 major(devno
), minor(devno
));
300 rc
= asprintf(&tmp
, "%3u:%-3u",
301 major(devno
), minor(devno
));
312 static const char *get_tabdiff_data(struct libmnt_fs
*old_fs
,
313 struct libmnt_fs
*new_fs
,
317 const char *str
= NULL
;
319 switch (get_column_id(num
)) {
322 case MNT_TABDIFF_MOUNT
:
325 case MNT_TABDIFF_UMOUNT
:
328 case MNT_TABDIFF_REMOUNT
:
331 case MNT_TABDIFF_MOVE
:
339 case COL_OLD_OPTIONS
:
341 str
= mnt_fs_get_options(old_fs
);
345 str
= mnt_fs_get_target(old_fs
);
349 str
= get_data(new_fs
, num
);
351 str
= get_data(old_fs
, num
);
357 /* adds one line to the output @tab */
358 static struct tt_line
*add_line(struct tt
*tt
, struct libmnt_fs
*fs
,
359 struct tt_line
*parent
)
362 struct tt_line
*line
= tt_add_line(tt
, parent
);
365 warn(_("failed to add line to output"));
368 for (i
= 0; i
< ncolumns
; i
++)
369 tt_line_set_data(line
, i
, get_data(fs
, i
));
371 tt_line_set_userdata(line
, fs
);
375 static struct tt_line
*add_tabdiff_line(struct tt
*tt
, struct libmnt_fs
*new_fs
,
376 struct libmnt_fs
*old_fs
, int change
)
379 struct tt_line
*line
= tt_add_line(tt
, NULL
);
382 warn(_("failed to add line to output"));
385 for (i
= 0; i
< ncolumns
; i
++)
386 tt_line_set_data(line
, i
,
387 get_tabdiff_data(old_fs
, new_fs
, change
, i
));
392 static int has_line(struct tt
*tt
, struct libmnt_fs
*fs
)
396 list_for_each(p
, &tt
->tb_lines
) {
397 struct tt_line
*ln
= list_entry(p
, struct tt_line
, ln_lines
);
398 if ((struct libmnt_fs
*) ln
->userdata
== fs
)
404 /* reads filesystems from @tb (libmount) and fillin @tt (output table) */
405 static int create_treenode(struct tt
*tt
, struct libmnt_table
*tb
,
406 struct libmnt_fs
*fs
, struct tt_line
*parent_line
)
408 struct libmnt_fs
*chld
= NULL
;
409 struct libmnt_iter
*itr
= NULL
;
410 struct tt_line
*line
;
414 /* first call, get root FS */
415 if (mnt_table_get_root_fs(tb
, &fs
))
419 } else if ((flags
& FL_SUBMOUNTS
) && has_line(tt
, fs
))
422 itr
= mnt_new_iter(MNT_ITER_FORWARD
);
426 line
= add_line(tt
, fs
, parent_line
);
431 * add all children to the output table
433 while(mnt_table_next_child_fs(tb
, itr
, fs
, &chld
) == 0) {
434 if (create_treenode(tt
, tb
, chld
, line
))
444 static int parser_errcb(struct libmnt_table
*tb
, const char *filename
, int line
)
446 warn(_("%s: parse error at line %d"), filename
, line
);
450 /* calls libmount fstab/mtab/mountinfo parser */
451 static struct libmnt_table
*parse_tabfile(const char *path
)
454 struct libmnt_table
*tb
= mnt_new_table();
457 warn(_("failed to initialize libmount table"));
461 mnt_table_set_parser_errcb(tb
, parser_errcb
);
463 if (!strcmp(path
, _PATH_MNTTAB
))
464 rc
= mnt_table_parse_fstab(tb
, NULL
);
465 else if (!strcmp(path
, _PATH_MOUNTED
))
466 rc
= mnt_table_parse_mtab(tb
, NULL
);
468 rc
= mnt_table_parse_file(tb
, path
);
472 warn(_("can't read %s"), path
);
478 /* filter function for libmount (mnt_table_find_next_fs()) */
479 static int match_func(struct libmnt_fs
*fs
, void *data
)
481 int rc
= flags
& FL_INVERT
? 1 : 0;
484 m
= get_match(COL_TARGET
);
485 if (m
&& !mnt_fs_match_target(fs
, m
, cache
))
488 m
= get_match(COL_SOURCE
);
489 if (m
&& !mnt_fs_match_source(fs
, m
, cache
))
492 m
= get_match(COL_FSTYPE
);
493 if (m
&& !mnt_fs_match_fstype(fs
, m
))
496 m
= get_match(COL_OPTIONS
);
497 if (m
&& !mnt_fs_match_options(fs
, m
))
503 /* iterate over filesystems in @tb */
504 static struct libmnt_fs
*get_next_fs(struct libmnt_table
*tb
,
505 struct libmnt_iter
*itr
)
507 struct libmnt_fs
*fs
= NULL
;
509 if (is_listall_mode()) {
513 if (mnt_table_next_fs(tb
, itr
, &fs
) != 0)
516 } else if (is_mount_compatible_mode()) {
518 * Look up for FS in the same way how mount(8) searchs in fstab
522 fs
= mnt_table_find_source(tb
, get_match(COL_SOURCE
),
523 mnt_iter_get_direction(itr
));
525 if (!fs
&& !(flags
& FL_NOSWAPMATCH
))
526 fs
= mnt_table_find_target(tb
, get_match(COL_SOURCE
),
527 mnt_iter_get_direction(itr
));
530 * Look up for all matching entries
532 * findmnt [-l] <source> <target> [-O <options>] [-t <types>]
533 * findmnt [-l] <spec> [-O <options>] [-t <types>]
536 mnt_table_find_next_fs(tb
, itr
, match_func
, NULL
, &fs
);
539 !(flags
& FL_NOSWAPMATCH
) &&
540 !get_match(COL_TARGET
) && get_match(COL_SOURCE
)) {
542 /* swap 'spec' and target. */
543 set_match(COL_TARGET
, get_match(COL_SOURCE
));
544 set_match(COL_SOURCE
, NULL
);
545 mnt_reset_iter(itr
, -1);
554 static int add_matching_lines(struct libmnt_table
*tb
,
555 struct tt
*tt
, int direction
)
557 struct libmnt_iter
*itr
= NULL
;
558 struct libmnt_fs
*fs
;
559 int nlines
= 0, rc
= -1;
561 itr
= mnt_new_iter(direction
);
563 warn(_("failed to initialize libmount iterator"));
567 while((fs
= get_next_fs(tb
, itr
))) {
568 if ((tt_flags
& TT_FL_TREE
) || (flags
& FL_SUBMOUNTS
))
569 rc
= create_treenode(tt
, tb
, fs
, NULL
);
571 rc
= !add_line(tt
, fs
, NULL
);
575 if (flags
& FL_FIRSTONLY
)
577 flags
|= FL_NOSWAPMATCH
;
587 static int poll_table(struct libmnt_table
*tb
, const char *tabfile
,
588 int timeout
, struct tt
*tt
, int direction
)
592 struct libmnt_iter
*itr
= NULL
;
593 struct libmnt_table
*tb_new
= NULL
;
594 struct libmnt_tabdiff
*diff
= NULL
;
595 struct pollfd fds
[1];
597 tb_new
= mnt_new_table();
599 warn(_("failed to initialize libmount table"));
603 itr
= mnt_new_iter(direction
);
605 warn(_("failed to initialize libmount iterator"));
609 diff
= mnt_new_tabdiff();
611 warn(_("failed to initialize libmount tabdiff"));
615 /* cache is unnecessary to detect changes */
616 mnt_table_set_cache(tb
, NULL
);
617 mnt_table_set_cache(tb_new
, NULL
);
619 f
= fopen(tabfile
, "r");
621 warn(_("%s: open failed"), tabfile
);
625 mnt_table_set_parser_errcb(tb_new
, parser_errcb
);
627 fds
[0].fd
= fileno(f
);
628 fds
[0].events
= POLLPRI
;
631 struct libmnt_table
*tmp
;
632 struct libmnt_fs
*old
, *new;
635 x
= poll(fds
, 1, timeout
);
639 warn(_("poll() failed"));
644 rc
= mnt_table_parse_stream(tb_new
, f
, tabfile
);
646 rc
= mnt_diff_tables(diff
, tb
, tb_new
);
650 mnt_reset_iter(itr
, direction
);
651 while(mnt_tabdiff_next_change(
652 diff
, itr
, &old
, &new, &change
) == 0) {
654 rc
= !add_tabdiff_line(tt
, new, old
, change
);
657 if (flags
& FL_FIRSTONLY
)
661 rc
= tt_print_table(tt
);
671 mnt_reset_table(tb_new
);
676 mnt_free_table(tb_new
);
677 mnt_free_tabdiff(diff
);
682 static void __attribute__((__noreturn__
)) usage(FILE *out
)
689 " %1$s [options] <device> | <mountpoint>\n"
690 " %1$s [options] <device> <mountpoint>\n"
691 " %1$s [options] [--source <device>] [--target <mountpoint>]\n"),
692 program_invocation_short_name
);
696 " -s, --fstab search in static table of filesystems\n"
697 " -m, --mtab search in table of mounted filesystems\n"
698 " -k, --kernel search in kernel table of mounted \n"
699 " filesystems (default)\n\n"
701 " -p, --poll monitor changes in table of mounted filesystems\n"
702 " -w, --timeout <num> upper limit in millisecods which --poll will block\n\n"
704 " -c, --canonicalize canonicalize printed paths\n"
705 " -d, --direction <word> search direction - 'forward' or 'backward'\n"
706 " -e, --evaluate print all TAGs (LABEL/UUID) evaluated\n"
707 " -f, --first-only print the first found filesystem only\n"
708 " -h, --help print this help\n"
709 " -i, --invert invert sense of matching\n"
710 " -l, --list use list format output\n"
711 " -n, --noheadings don't print headings\n"
712 " -u, --notruncate don't truncate text in columns\n"
713 " -O, --options <list> limit the set of filesystems by mount options\n"
714 " -o, --output <list> output columns\n"
715 " -r, --raw use raw format output\n"
716 " -a, --ascii use ascii chars for tree formatting\n"
717 " -t, --types <list> limit the set of filesystem by FS types\n"
718 " -v, --nofsroot don't print [/dir] for bind or btrfs mounts\n"
719 " -R, --submounts print all submount for the matching filesystems\n"
720 " -S, --source <string> device, LABEL= or UUID=device\n"
721 " -T, --target <string> mountpoint\n\n"));
724 fprintf(out
, _("\nAvailable columns:\n"));
726 for (i
= 0; i
< __NCOLUMNS
; i
++) {
728 fprintf(out
, " %-12s", infos
[i
].name
);
729 if (i
&& !((i
+1) % 3))
734 fprintf(out
, _("\nFor more information see findmnt(1).\n"));
736 exit(out
== stderr
? EXIT_FAILURE
: EXIT_SUCCESS
);
739 static void __attribute__((__noreturn__
))
740 errx_mutually_exclusive(const char *opts
)
742 errx(EXIT_FAILURE
, "%s %s", opts
, _("options are mutually exclusive"));
745 int main(int argc
, char *argv
[])
748 struct libmnt_table
*tb
= NULL
;
749 char *tabfile
= NULL
;
750 int direction
= MNT_ITER_FORWARD
;
751 int i
, c
, rc
= -1, timeout
= -1;
754 struct tt
*tt
= NULL
;
756 static const struct option longopts
[] = {
757 { "ascii", 0, 0, 'a' },
758 { "canonicalize", 0, 0, 'c' },
759 { "direction", 1, 0, 'd' },
760 { "evaluate", 0, 0, 'e' },
761 { "first-only", 0, 0, 'f' },
762 { "fstab", 0, 0, 's' },
763 { "help", 0, 0, 'h' },
764 { "invert", 0, 0, 'i' },
765 { "kernel", 0, 0, 'k' },
766 { "list", 0, 0, 'l' },
767 { "mtab", 0, 0, 'm' },
768 { "noheadings", 0, 0, 'n' },
769 { "notruncate", 0, 0, 'u' },
770 { "options", 1, 0, 'O' },
771 { "output", 1, 0, 'o' },
772 { "poll", 0, 0, 'p' },
773 { "raw", 0, 0, 'r' },
774 { "types", 1, 0, 't' },
775 { "fsroot", 0, 0, 'v' },
776 { "submounts", 0, 0, 'R' },
777 { "source", 1, 0, 'S' },
778 { "target", 1, 0, 'T' },
779 { "timeout", 1, 0, 'w' },
784 assert(ARRAY_SIZE(columns
) == __NCOLUMNS
);
786 setlocale(LC_ALL
, "");
787 bindtextdomain(PACKAGE
, LOCALEDIR
);
790 /* default output format */
791 tt_flags
|= TT_FL_TREE
;
793 while ((c
= getopt_long(argc
, argv
,
794 "acd:ehifo:O:pklmnrst:uvRS:T:w:", longopts
, NULL
)) != -1) {
797 tt_flags
|= TT_FL_ASCII
;
800 flags
|= FL_CANONICALIZE
;
803 if (!strcmp(optarg
, "forward"))
804 direction
= MNT_ITER_FORWARD
;
805 else if (!strcmp(optarg
, "backward"))
806 direction
= MNT_ITER_BACKWARD
;
809 _("unknown direction '%s'"), optarg
);
812 flags
|= FL_EVALUATE
;
821 flags
|= FL_FIRSTONLY
;
824 disable_columns_truncate();
827 if (tt_parse_columns_list(optarg
, columns
, &ncolumns
,
832 set_match(COL_OPTIONS
, optarg
);
836 tt_flags
&= ~TT_FL_TREE
;
840 errx_mutually_exclusive("--{fstab,mtab,kernel}");
841 tabfile
= _PATH_MOUNTED
;
842 tt_flags
&= ~TT_FL_TREE
;
844 case 's': /* fstab */
846 errx_mutually_exclusive("--{fstab,mtab,kernel}");
847 tabfile
= _PATH_MNTTAB
;
848 tt_flags
&= ~TT_FL_TREE
;
850 case 'k': /* kernel (mountinfo) */
852 errx_mutually_exclusive("--{fstab,mtab,kernel}");
853 tabfile
= _PATH_PROC_MOUNTINFO
;
856 set_match(COL_FSTYPE
, optarg
);
859 tt_flags
&= ~TT_FL_TREE
; /* disable the default */
860 tt_flags
|= TT_FL_RAW
; /* enable raw */
863 if (tt_flags
& TT_FL_RAW
)
864 errx_mutually_exclusive("--{raw,list}");
866 tt_flags
&= ~TT_FL_TREE
; /* disable the default */
869 tt_flags
|= TT_FL_NOHEADINGS
;
872 flags
|= FL_NOFSROOT
;
875 flags
|= FL_SUBMOUNTS
;
878 set_match(COL_SOURCE
, optarg
);
879 flags
|= FL_NOSWAPMATCH
;
882 set_match(COL_TARGET
, optarg
);
883 flags
|= FL_NOSWAPMATCH
;
886 timeout
= strtol_or_err(optarg
,
887 _("failed to parse timeout"));
895 /* default columns */
898 columns
[ncolumns
++] = COL_ACTION
;
900 columns
[ncolumns
++] = COL_TARGET
;
901 columns
[ncolumns
++] = COL_SOURCE
;
902 columns
[ncolumns
++] = COL_FSTYPE
;
903 columns
[ncolumns
++] = COL_OPTIONS
;
907 tabfile
= _PATH_PROC_MOUNTINFO
;
909 if (access(tabfile
, R_OK
)) { /* old kernel? */
910 tabfile
= _PATH_PROC_MOUNTS
;
911 tt_flags
&= ~TT_FL_TREE
;
915 if (optind
< argc
&& (get_match(COL_SOURCE
) || get_match(COL_TARGET
)))
916 errx(EXIT_FAILURE
, _(
917 "options --target and --source can't be used together "
918 "with command line element that is not an option"));
921 set_match(COL_SOURCE
, argv
[optind
++]); /* dev/tag/mountpoint */
923 set_match(COL_TARGET
, argv
[optind
++]); /* mountpoint */
925 if ((flags
& FL_SUBMOUNTS
) && is_listall_mode())
926 /* don't care about submounts if list all mounts */
927 flags
&= ~FL_SUBMOUNTS
;
929 if (!(flags
& FL_SUBMOUNTS
) &&
930 (!is_listall_mode() || (flags
& FL_FIRSTONLY
)))
931 tt_flags
&= ~TT_FL_TREE
;
933 if (!(flags
& FL_NOSWAPMATCH
) &&
934 !get_match(COL_TARGET
) && get_match(COL_SOURCE
)) {
936 * Check if we can swap source and target, it's
937 * not possible if the source is LABEL=/UUID=
939 const char *x
= get_match(COL_SOURCE
);
941 if (!strncmp(x
, "LABEL=", 6) || !strncmp(x
, "UUID=", 5))
942 flags
|= FL_NOSWAPMATCH
;
946 * initialize libmount
950 tb
= parse_tabfile(tabfile
);
954 cache
= mnt_new_cache();
956 warn(_("failed to initialize libmount cache"));
959 mnt_table_set_cache(tb
, cache
);
962 * initialize output formatting (tt.h)
964 tt
= tt_new_table(tt_flags
);
966 warn(_("failed to initialize output table"));
970 for (i
= 0; i
< ncolumns
; i
++) {
971 int fl
= get_column_flags(i
);
972 int id
= get_column_id(i
);
974 if (!(tt_flags
& TT_FL_TREE
))
977 if (!(flags
& FL_POLL
) && is_tabdiff_column(id
)) {
978 warn(_("%s column is requested, but --poll "
979 "is not enabled"), get_column_name(i
));
983 if (!tt_define_column(tt
, get_column_name(i
),
984 get_column_whint(i
), fl
)) {
985 warn(_("failed to initialize output column"));
991 * Fill in data to the output table
995 rc
= poll_table(tb
, tabfile
, timeout
, tt
, direction
);
997 else if ((tt_flags
& TT_FL_TREE
) && is_listall_mode())
999 rc
= create_treenode(tt
, tb
, NULL
, NULL
);
1001 /* whole lits of sub-tree */
1002 rc
= add_matching_lines(tb
, tt
, direction
);
1005 * Print the output table for non-poll modes
1007 if (!rc
&& !(flags
& FL_POLL
))
1013 mnt_free_cache(cache
);
1015 return rc
? EXIT_FAILURE
: EXIT_SUCCESS
;