From 19c6a346c7d75954dd1314c064d9f76fe74324ed Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Tue, 13 Apr 1993 20:29:32 +0000 Subject: [PATCH] GNU file utilities --- lib/Makefile.in | 5 +++-- lib/fnmatch.h | 5 +++-- lib/fsusage.c | 12 ++++++++++++ lib/mountlist.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 60 insertions(+), 4 deletions(-) diff --git a/lib/Makefile.in b/lib/Makefile.in index fb21e13dc..affeea23d 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -78,12 +78,13 @@ libfu.a: $(OBJECTS) # is the only way to reliably do a parallel make. getdate.c: getdate.y @echo expect 9 shift/reduce conflicts - -bison -o getdate.c $(srcdir)/getdate.y || yacc $(srcdir)/getdate.y + -bison -o getdate.c $(srcdir)/getdate.y || $(YACC) $(srcdir)/getdate.y test ! -f y.tab.c || mv y.tab.c getdate.c # Make the rename atomic, in case sed is interrupted and later rerun. posixtm.c: posixtm.y - -bison -o posixtm.tab.c $(srcdir)/posixtm.y || yacc $(srcdir)/posixtm.y + -bison -o posixtm.tab.c $(srcdir)/posixtm.y \ + || $(YACC) $(srcdir)/posixtm.y test ! -f y.tab.c || mv y.tab.c posixtm.tab.c sed -e 's/yy/zz/g' posixtm.tab.c > tposixtm.c mv tposixtm.c posixtm.c diff --git a/lib/fnmatch.h b/lib/fnmatch.h index 2289f6345..5c94813f4 100644 --- a/lib/fnmatch.h +++ b/lib/fnmatch.h @@ -29,8 +29,9 @@ extern "C" { #else /* Not C++ or ANSI C. */ #undef __P #define __P(args) () -#undef const -#define const +/* We can get away without defining `const' here only because in this file + it is used only inside the prototype for `fnmatch', which is elided in + non-ANSI C where `const' is problematical. */ #endif /* C++ or ANSI C. */ /* Bits set in the FLAGS argument to `fnmatch'. */ diff --git a/lib/fsusage.c b/lib/fsusage.c index b43491343..2a1fe86c7 100644 --- a/lib/fsusage.c +++ b/lib/fsusage.c @@ -20,6 +20,10 @@ int statfs (); +#if defined (STATFS_OSF1) /* DEC Alpha running OSF/1 */ +# include +#endif + #if defined(STAT_STATFS2_BSIZE) && !defined(_IBMR2) /* 4.3BSD, SunOS 4, HP-UX, AIX PS/2. */ #include #endif @@ -80,6 +84,14 @@ get_fs_usage (path, disk, fsp) char *path, *disk; struct fs_usage *fsp; { +#if defined (STATFS_OSF1) + struct statfs fsd; + + if (statfs (path, &fsd, sizeof (struct statfs)) != 0) + return (-1); +#define convert_blocks(b) adjust_blocks ((b),fsd.f_fsize, 512) +#endif /* STATFS_OSF1 */ + #ifdef STAT_STATFS2_FS_DATA /* Ultrix. */ struct fs_data fsd; diff --git a/lib/mountlist.c b/lib/mountlist.c index 88fda7a61..1dc78c5ce 100644 --- a/lib/mountlist.c +++ b/lib/mountlist.c @@ -36,6 +36,11 @@ char *xrealloc (); char *xstrdup (); void error (); +#if defined (MOUNTED_GETFSSTAT) /* __alpha running OSF_1 */ +# include +# include +#endif /* MOUNTED_GETFSSTAT */ + #ifdef MOUNTED_GETMNTENT1 /* 4.3BSD, SunOS, HP-UX, Dynix, Irix. */ #include #if !defined(MOUNTED) @@ -268,6 +273,43 @@ read_filesystem_list (need_fs_type, all_fs) } #endif /* MOUNTED_GETMNT. */ +#if defined (MOUNTED_GETFSSTAT) /* __alpha running OSF_1 */ + { + int numsys, counter, bufsize; + struct statfs *stats; + + numsys = getfsstat ((struct statfs *)0, 0L, MNT_WAIT); + if (numsys < 0) + return (NULL); + + bufsize = (1 + numsys) * sizeof (struct statfs); + stats = (struct statfs *)xmalloc (bufsize); + numsys = getfsstat (stats, bufsize, MNT_WAIT); + + if (numsys < 0) + { + free (stats); + return (NULL); + } + + for (counter = 0; counter < numsys; counter++) + { + me = (struct mount_entry *) xmalloc (sizeof (struct mount_entry)); + me->me_devname = xstrdup (stats[counter].f_mntfromname); + me->me_mountdir = xstrdup (stats[counter].f_mntonname); + me->me_type = mnt_names[stats[counter].f_type]; + me->me_dev = -1; /* Magic; means not known yet. */ + me->me_next = NULL; + + /* Add to the linked list. */ + mtail->me_next = me; + mtail = me; + } + + free (stats); + } +#endif /* MOUNTED_GETFSSTAT */ + #if defined (MOUNTED_FREAD) || defined (MOUNTED_FREAD_FSTYP) /* SVR[23]. */ { struct mnttab mnt; -- 2.11.0