mirror of
https://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git
synced 2025-01-09 18:13:34 +08:00
fsetflags.c (fsetflags), fgetflags.c (fgetflags): Save
errno if the ioctl fails, and restore it just before we return.
This commit is contained in:
parent
50cd7e06e2
commit
a8a813ee33
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user