summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1996-11-28 19:37:01 +0000
committerJim Meyering <jim@meyering.net>1996-11-28 19:37:01 +0000
commit4b7e5ff7e5a45e9dc06927b2e356484ae8249be5 (patch)
tree38956c91a6e534bda5c6365e3429f795c2f352a9
parent214a642720945dc7dd6d90111e65a916400de0c3 (diff)
downloadgnulib-4b7e5ff7e5a45e9dc06927b2e356484ae8249be5.tar.gz
(get_fs_usage): If DISK is 0 and we needed to use
it, return -1 with 0 in ERRNO. From Miles.
-rw-r--r--lib/fsusage.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/fsusage.c b/lib/fsusage.c
index d9d5234bd9..e90abf94d8 100644
--- a/lib/fsusage.c
+++ b/lib/fsusage.c
@@ -1,5 +1,5 @@
/* fsusage.c -- return space usage of mounted filesystems
- Copyright (C) 1991, 1992 Free Software Foundation, Inc.
+ Copyright (C) 1991, 1992, 1996 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -90,8 +90,9 @@ adjust_blocks (blocks, fromsize, tosize)
the filesystem on which PATH resides.
DISK is the device on which PATH is mounted, for space-getting
methods that need to know it.
- Return 0 if successful, -1 if not. */
-
+ Return 0 if successful, -1 if not. When returning -1, ensure that
+ ERRNO is either a system error value, or zero if DISK is NULL
+ on a system that requires a non-NULL value. */
int
get_fs_usage (path, disk, fsp)
const char *path;
@@ -133,6 +134,12 @@ get_fs_usage (path, disk, fsp)
struct filsys fsd;
int fd;
+ if (! disk)
+ {
+ errno = 0;
+ return -1;
+ }
+
fd = open (disk, O_RDONLY);
if (fd < 0)
return -1;