fsetflags.c (fsetflags), fgetflags.c (fgetflags): Save

errno if the ioctl fails, and restore it just before we
	return.
This commit is contained in:
Theodore Ts'o 2002-07-14 16:13:55 -04:00
parent 50cd7e06e2
commit a8a813ee33
3 changed files with 14 additions and 6 deletions

View File

@ -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

View File

@ -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;

View File

@ -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;