From 7abd640b41963e82361e180cdf04102b5983e543 Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Thu, 4 Jan 2018 10:42:24 +0300 Subject: [PATCH] Sync with gnulib 467061a2014d742a27eb8d4498e8d09fb3225d53. Remove SVR2 support SVR2 was obsolete by 1986 and is no longer supported by anybody, and its code was getting in the way of use of this module by Emacs, which has its own 'read' function anyway. * src/filemanager/mountlist.c: remove SVR2-specific code. * m4.include/fsusage.m4: do not test for sys/filsys.h or set STAT_READ_FILSYS. Signed-off-by: Andrew Borodin --- m4.include/fsusage.m4 | 17 ++---- src/filemanager/mountlist.c | 122 -------------------------------------------- 2 files changed, 3 insertions(+), 136 deletions(-) diff --git a/m4.include/fsusage.m4 b/m4.include/fsusage.m4 index 72472e2c8..1d6ad41cd 100644 --- a/m4.include/fsusage.m4 +++ b/m4.include/fsusage.m4 @@ -1,7 +1,7 @@ -# serial 31 +# serial 32 # Obtaining file system usage information. -# Copyright (C) 1997-1998, 2000-2001, 2003-2016 Free Software Foundation, Inc. +# Copyright (C) 1997-1998, 2000-2001, 2003-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -295,17 +295,6 @@ if test $ac_fsusage_space = no; then fi fi -if test $ac_fsusage_space = no; then - # SVR2 - # (AIX, HP-UX, OSF/1 already handled above.) - AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include - ]])], - [AC_DEFINE([STAT_READ_FILSYS], [1], - [Define if there is no specific function for reading file systems usage - information and you have the header file. (SVR2)]) - ac_fsusage_space=yes]) -fi - AS_IF([test $ac_fsusage_space = yes], [$1], [$2]) ]) @@ -342,6 +331,6 @@ choke -- this is a workaround for a Sun-specific problem # Prerequisites of lib/fsusage.c not done by gl_FILE_SYSTEM_USAGE. AC_DEFUN([gl_PREREQ_FSUSAGE_EXTRA], [ - AC_CHECK_HEADERS([dustat.h sys/fs/s5param.h sys/filsys.h sys/statfs.h]) + AC_CHECK_HEADERS([dustat.h sys/fs/s5param.h sys/statfs.h]) gl_STATFS_TRUNCATES ]) diff --git a/src/filemanager/mountlist.c b/src/filemanager/mountlist.c index 7f084cec9..12c5c264e 100644 --- a/src/filemanager/mountlist.c +++ b/src/filemanager/mountlist.c @@ -75,9 +75,6 @@ #ifdef HAVE_SYS_FS_S5PARAM_H /* Fujitsu UXP/V */ #include #endif -#if defined HAVE_SYS_FILSYS_H && !defined _CRAY -#include /* SVR2 */ -#endif #ifdef HAVE_SYS_STATFS_H #include #endif @@ -119,10 +116,6 @@ #include #endif -#ifdef MOUNTED_FREAD /* SVR2. */ -#include -#endif - #ifdef MOUNTED_FREAD_FSTYP /* SVR3. */ #include #include @@ -309,17 +302,6 @@ me_remote (char const *fs_name, char const *fs_type) #endif #endif -#ifdef STAT_READ_FILSYS /* SVR2 */ -/* Set errno to zero upon EOF. */ -#define ZERO_BYTE_TRANSFER_ERRNO 0 - -#ifdef EINTR -#define IS_EINTR(x) ((x) == EINTR) -#else -#define IS_EINTR(x) 0 -#endif -#endif /* STAT_READ_FILSYS */ - /*** file scope type declarations ****************************************************************/ /* A mount table entry. */ @@ -1406,76 +1388,6 @@ read_file_system_list (void) /* --------------------------------------------------------------------------------------------- */ -#ifdef STAT_READ_FILSYS /* SVR2 */ - -/* Read(write) up to COUNT bytes at BUF from(to) descriptor FD, retrying if - interrupted. Return the actual number of bytes read(written), zero for EOF, - or SAFE_READ_ERROR(SAFE_WRITE_ERROR) upon error. */ -static size_t -safe_read (int fd, void *buf, size_t count) -{ - /* Work around a bug in Tru64 5.1. Attempting to read more than - INT_MAX bytes fails with errno == EINVAL. See - . - When decreasing COUNT, keep it block-aligned. */ - /* *INDENT-OFF* */ - enum { BUGGY_READ_MAXIMUM = INT_MAX & ~8191 }; - /* *INDENT-ON* */ - - while (TRUE) - { - ssize_t result; - - result = read (fd, buf, count); - - if (0 <= result) - return result; - else if (IS_EINTR (errno)) - continue; - else if (errno == EINVAL && BUGGY_READ_MAXIMUM < count) - count = BUGGY_READ_MAXIMUM; - else - return result; - } -} - -/* --------------------------------------------------------------------------------------------- */ - -/* Read COUNT bytes at BUF to(from) descriptor FD, retrying if - interrupted or if a partial write(read) occurs. Return the number - of bytes transferred. - When writing, set errno if fewer than COUNT bytes are written. - When reading, if fewer than COUNT bytes are read, you must examine - errno to distinguish failure from EOF (errno == 0). */ - -static size_t -full_read (int fd, void *buf, size_t count) -{ - size_t total = 0; - char *ptr = (char *) buf; - - while (count > 0) - { - size_t n_rw = safe_read (fd, ptr, count); - if (n_rw == (size_t) (-1)) - break; - if (n_rw == 0) - { - errno = ZERO_BYTE_TRANSFER_ERRNO; - break; - } - total += n_rw; - ptr += n_rw; - count -= n_rw; - } - - return total; -} - -#endif /* STAT_READ_FILSYS */ - -/* --------------------------------------------------------------------------------------------- */ - #ifdef HAVE_INFOMOUNT /* Fill in the fields of FSP with information about space usage for the file system on which FILE resides. @@ -1541,40 +1453,6 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp) fsp->fsu_files = PROPAGATE_ALL_ONES (fsd.fd_req.gtot); fsp->fsu_ffree = PROPAGATE_ALL_ONES (fsd.fd_req.gfree); -#elif defined STAT_READ_FILSYS /* SVR2 */ -#ifndef SUPERBOFF -#define SUPERBOFF (SUPERB * 512) -#endif - - struct filsys fsd; - int fd; - - if (!disk) - { - errno = 0; - return -1; - } - - fd = open (disk, O_RDONLY); - if (fd < 0) - return -1; - lseek (fd, (off_t) SUPERBOFF, 0); - if (full_read (fd, (char *) &fsd, sizeof (fsd)) != sizeof (fsd)) - { - close (fd); - return -1; - } - close (fd); - - fsp->fsu_blocksize = (fsd.s_type == Fs2b ? 1024 : 512); - fsp->fsu_blocks = PROPAGATE_ALL_ONES (fsd.s_fsize); - fsp->fsu_bfree = PROPAGATE_ALL_ONES (fsd.s_tfree); - fsp->fsu_bavail = PROPAGATE_TOP_BIT (fsd.s_tfree); - fsp->fsu_bavail_top_bit_set = EXTRACT_TOP_BIT (fsd.s_tfree) != 0; - fsp->fsu_files = (fsd.s_isize == -1 - ? UINTMAX_MAX : (fsd.s_isize - 2) * INOPB * (fsd.s_type == Fs2b ? 2 : 1)); - fsp->fsu_ffree = PROPAGATE_ALL_ONES (fsd.s_tinode); - #elif defined STAT_STATFS3_OSF1 /* OSF/1 */ struct statfs fsd; -- 2.11.4.GIT