[BusyBox-cvs] busybox/util-linux fdflush.c,1.20,1.21 freeramdisk.c,1.19,1.20

Erik Andersen andersen at codepoet.org
Fri Mar 7 18:09:10 UTC 2003


Update of /var/cvs/busybox/util-linux
In directory winder:/tmp/cvs-serv18378

Modified Files:
	fdflush.c freeramdisk.c 
Log Message:
be more careful about cleaning up


Index: fdflush.c
===================================================================
RCS file: /var/cvs/busybox/util-linux/fdflush.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- fdflush.c	7 Mar 2003 18:03:02 -0000	1.20
+++ fdflush.c	7 Mar 2003 18:09:06 -0000	1.21
@@ -32,16 +32,23 @@
 
 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: freeramdisk.c
===================================================================
RCS file: /var/cvs/busybox/util-linux/freeramdisk.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- freeramdisk.c	5 Oct 2001 05:03:14 -0000	1.19
+++ freeramdisk.c	7 Mar 2003 18:09:06 -0000	1.20
@@ -37,20 +37,25 @@
 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;
 }
 




More information about the busybox-cvs mailing list