summaryrefslogtreecommitdiff
path: root/lib/e2p
diff options
context:
space:
mode:
Diffstat (limited to 'lib/e2p')
-rw-r--r--lib/e2p/ChangeLog7
-rw-r--r--lib/e2p/fgetflags.c7
-rw-r--r--lib/e2p/fsetflags.c6
3 files changed, 14 insertions, 6 deletions
diff --git a/lib/e2p/ChangeLog b/lib/e2p/ChangeLog
index 3a81898c..5dfc86d1 100644
--- a/lib/e2p/ChangeLog
+++ b/lib/e2p/ChangeLog
@@ -1,8 +1,9 @@
2002-07-14 Theodore Ts'o <tytso@mit.edu>
- * fsetversion.c (fsetversion), fgetversion.c, fgetversion.c: Save
- errno if the ioctl fails, and restore it just before we
- return.
+ * fsetflags.c (fsetflags), fgetflags.c (fgetflags,
+ fsetversion.c (fsetversion), fgetversion.c,
+ fgetversion.c: Save errno if the ioctl fails, and
+ restore it just before we return.
* iod.c (iterate_on_dir): Rewrite function to make it more
portable. We now make much fewer assumptions about nature
diff --git a/lib/e2p/fgetflags.c b/lib/e2p/fgetflags.c
index c9b4d1eb..ed4ade9d 100644
--- a/lib/e2p/fgetflags.c
+++ b/lib/e2p/fgetflags.c
@@ -63,15 +63,18 @@ int fgetflags (const char * name, unsigned long * flags)
return 0;
#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;
r = ioctl (fd, EXT2_IOC_GETFLAGS, &f);
+ if (r == -1)
+ save_errno = errno;
*flags = f;
-
close (fd);
+ if (save_errno)
+ errno = save_errno;
return r;
#else /* ! HAVE_EXT2_IOCTLS */
extern int errno;
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;