+2002-02-21 Theodore Tso <tytso@valinux.com>
+
+ * ismounted.c (is_swap_device): Fix file descriptor/memory leak;
+ we were missing an fclose().
+
2002-02-20 Theodore Tso <tytso@valinux.com>
* Makefile.in, inode_io.c, ext2fs.h, ext2_err.et.in: Add new io
abstraction interface which exports an ext2 inode.
- * fileio.c (ext2fs_file_flush): Export ext2fs_file_flush as a
- public interface.
+ * ext2fs.h, fileio.c (ext2fs_file_flush): Export ext2fs_file_flush
+ as a public interface. Change void * to const void * in
+ ext2fs_file_write's interface.
* test_io.c (test_close), unix_io.c (unix_close): Remove unneeded
conditional; save a few bytes.
char buf[1024], *cp;
dev_t file_dev;
struct stat st_buf;
+ int ret = 0;
file_dev = 0;
#ifndef __GNU__ /* The GNU hurd is broken with respect to stat devices */
file_dev = st_buf.st_rdev;
#endif
- f = fopen("/proc/swaps", "r");
- if (!f)
+ if (!(f = fopen("/proc/swaps", "r")))
return 0;
/* Skip the first line */
fgets(buf, sizeof(buf), f);
*cp = 0;
if ((cp = strchr(buf, '\t')) != NULL)
*cp = 0;
- if (strcmp(buf, file) == 0)
- return 1;
+ if (strcmp(buf, file) == 0) {
+ ret++;
+ break;
+ }
#ifndef __GNU__
if (file_dev && (stat(buf, &st_buf) == 0) &&
- file_dev == st_buf.st_rdev)
- return 1;
+ file_dev == st_buf.st_rdev) {
+ ret++;
+ break;
+ }
#endif
}
- return 0;
+ fclose(f);
+ return ret;
}
static errcode_t check_mntent(const char *file, int *mount_flags,