be more careful about cleaning up
authorEric Andersen <andersen@codepoet.org>
Fri, 7 Mar 2003 18:09:06 +0000 (18:09 -0000)
committerEric Andersen <andersen@codepoet.org>
Fri, 7 Mar 2003 18:09:06 +0000 (18:09 -0000)
util-linux/fdflush.c
util-linux/freeramdisk.c

index a4245c7e3e677690aac7065f201a2c8f7b681e62..0756ddfbf5d8098d691f9192dedbfbcbb11f3382 100644 (file)
 
 extern int fdflush_main(int argc, char **argv)
 {
-       int fd;
+       int fd, result;
 
        if (argc <= 1)
                show_usage();
        if ((fd = open(*(++argv), 0)) < 0)
                goto die_the_death;
 
-       if (ioctl(fd, FDFLUSH, 0))
+       result = ioctl(fd, FDFLUSH, 0);
+#ifdef CONFIG_FEATURE_CLEAN_UP
+       close(fd);
+#endif
+       if (result) {
                goto die_the_death;
+       }
 
+       /* Don't bother closing.  Exit does
+        * that, so we can save a few bytes */
        return EXIT_SUCCESS;
 
 die_the_death:
index aabb5f98827641ed79ef3c6fa890f6a338c4158b..dd7700c06f5b4741cd9c04bca5fe093ffc2f4058 100644 (file)
 extern int
 freeramdisk_main(int argc, char **argv)
 {
+       int result;
        FILE *f;
 
-       if (argc != 2 || *argv[1] == '-') {
+       if (argc != 2) {
                show_usage();
        }
 
        f = xfopen(argv[1], "r+");
        
-       if (ioctl(fileno(f), BLKFLSBUF) < 0) {
+       result = ioctl(fileno(f), BLKFLSBUF);
+#ifdef CONFIG_FEATURE_CLEAN_UP
+       fclose(f);
+#endif
+       if (result < 0) {
                perror_msg_and_die("failed ioctl on %s", argv[1]);
        }
+
        /* Don't bother closing.  Exit does
         * that, so we can save a few bytes */
-       /* close(f); */
        return EXIT_SUCCESS;
 }