dist_man_MANS += findmnt.8
findmnt_LDADD = $(ul_libmount_la)
findmnt_CFLAGS = $(AM_CFLAGS) -I$(ul_libmount_incdir)
-findmnt_SOURCES = findmnt.c $(top_srcdir)/lib/tt.c $(top_srcdir)/lib/mbsalign.c
+findmnt_SOURCES = findmnt.c \
+ $(top_srcdir)/lib/tt.c \
+ $(top_srcdir)/lib/mbsalign.c \
+ $(top_srcdir)/lib/strutils.c
+
if !HAVE_LANGINFO
findmnt_SOURCES += $(top_srcdir)/lib/langinfo.c
endif
#include "nls.h"
#include "c.h"
#include "tt.h"
+#include "strutils.h"
/* flags */
enum {
x = poll(fds, 1, timeout);
if (x == 0)
- goto done; /* timeout ? */
+ break; /* timeout */
if (x < 0) {
warn(_("poll() failed"));
goto done;
" -k, --kernel search in kernel table of mounted \n"
" filesystems (default)\n\n"
- " -p, --poll monitor changes in table of mounted filesystems\n\n"
+ " -p, --poll monitor changes in table of mounted filesystems\n"
+ " -w, --timeout <num> upper limit in millisecods which --poll will block\n\n"
" -c, --canonicalize canonicalize printed paths\n"
" -d, --direction <word> search direction - 'forward' or 'backward'\n"
struct libmnt_table *tb = NULL;
char *tabfile = NULL;
int direction = MNT_ITER_FORWARD;
- int i, c, rc = -1;
+ int i, c, rc = -1, timeout = -1;
/* table.h */
struct tt *tt = NULL;
{ "submounts", 0, 0, 'R' },
{ "source", 1, 0, 'S' },
{ "target", 1, 0, 'T' },
+ { "timeout", 1, 0, 'w' },
{ NULL, 0, 0, 0 }
};
tt_flags |= TT_FL_TREE;
while ((c = getopt_long(argc, argv,
- "acd:ehifo:O:pklmnrst:uvRS:T:", longopts, NULL)) != -1) {
+ "acd:ehifo:O:pklmnrst:uvRS:T:w:", longopts, NULL)) != -1) {
switch(c) {
case 'a':
tt_flags |= TT_FL_ASCII;
set_match(COL_TARGET, optarg);
flags |= FL_NOSWAPMATCH;
break;
+ case 'w':
+ timeout = strtol_or_err(optarg,
+ _("failed to parse timeout"));
+ break;
default:
usage(stderr);
break;
*/
if (flags & FL_POLL)
/* poll mode */
- poll_table(tb, tabfile, -1, tt, direction);
+ rc = poll_table(tb, tabfile, timeout, tt, direction);
else if ((tt_flags & TT_FL_TREE) && is_listall_mode())
/* whole tree */