diff options
author | Theodore Ts'o <tytso@mit.edu> | 2002-07-14 16:13:55 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2002-07-14 16:13:55 -0400 |
commit | a8a813ee3321f3d8986a88c83903b933f1b35e8e (patch) | |
tree | 2d9c488d167c32877c32d17c38822dc6b0a78c3d /lib/e2p/fsetflags.c | |
parent | 50cd7e06e26d8cb232819b3d94b67e37ade80c0f (diff) | |
download | e2fsprogs-a8a813ee3321f3d8986a88c83903b933f1b35e8e.tar.gz |
fsetflags.c (fsetflags), fgetflags.c (fgetflags): Save
errno if the ioctl fails, and restore it just before we
return.
Diffstat (limited to 'lib/e2p/fsetflags.c')
-rw-r--r-- | lib/e2p/fsetflags.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/e2p/fsetflags.c b/lib/e2p/fsetflags.c index 35266dcd..6942c045 100644 --- a/lib/e2p/fsetflags.c +++ b/lib/e2p/fsetflags.c @@ -59,14 +59,18 @@ int fsetflags (const char * name, unsigned long flags) return chflags (name, bsd_flags); #else #if HAVE_EXT2_IOCTLS - int fd, r, f; + int fd, r, f, save_errno = 0; fd = open (name, OPEN_FLAGS); if (fd == -1) return -1; f = (int) flags; r = ioctl (fd, EXT2_IOC_SETFLAGS, &f); + if (r == -1) + save_errno = errno; close (fd); + if (save_errno) + errno = save_errno; return r; #else /* ! HAVE_EXT2_IOCTLS */ extern int errno; |