svn commit: trunk/busybox: archival editors include libbb

vda at busybox.net vda at busybox.net
Thu Apr 5 21:25:16 UTC 2007


Author: vda
Date: 2007-04-05 14:25:15 -0700 (Thu, 05 Apr 2007)
New Revision: 18342

Log:
libbb: add xunlink()
patch: do not try to delete same file twice


Modified:
   trunk/busybox/archival/bbunzip.c
   trunk/busybox/editors/patch.c
   trunk/busybox/include/libbb.h
   trunk/busybox/libbb/xfuncs.c


Changeset:
Modified: trunk/busybox/archival/bbunzip.c
===================================================================
--- trunk/busybox/archival/bbunzip.c	2007-04-05 21:14:29 UTC (rev 18341)
+++ trunk/busybox/archival/bbunzip.c	2007-04-05 21:25:15 UTC (rev 18342)
@@ -105,8 +105,7 @@
 				if (new_name == filename)
 					filename[strlen(filename)] = '.';
 			}
-			if (unlink(del) < 0)
-				bb_perror_msg_and_die("cannot remove %s", del);
+			xunlink(del);
 
 #if 0 /* Currently buggy - wrong name: "a.gz: 261% - replaced with a.gz" */
 			/* Extreme bloat for gunzip compat */

Modified: trunk/busybox/editors/patch.c
===================================================================
--- trunk/busybox/editors/patch.c	2007-04-05 21:14:29 UTC (rev 18341)
+++ trunk/busybox/editors/patch.c	2007-04-05 21:25:15 UTC (rev 18342)
@@ -260,12 +260,9 @@
 			}
 			if ((dest_cur_line == 0) || (dest_beg_line == 0)) {
 				/* The new patched file is empty, remove it */
-				if (unlink(new_filename) == -1) {
-					bb_perror_msg_and_die("cannot remove file %s", new_filename);
-				}
-				if (unlink(original_filename) == -1) {
-					bb_perror_msg_and_die("cannot remove original file %s", new_filename);
-				}
+				xunlink(new_filename);
+				if (strcmp(new_filename, original_filename) != 0)
+					xunlink(original_filename);
 			}
 		}
 	}

Modified: trunk/busybox/include/libbb.h
===================================================================
--- trunk/busybox/include/libbb.h	2007-04-05 21:14:29 UTC (rev 18341)
+++ trunk/busybox/include/libbb.h	2007-04-05 21:25:15 UTC (rev 18342)
@@ -293,14 +293,15 @@
 
 
 
-extern void xsetgid(gid_t gid);
-extern void xsetuid(uid_t uid);
-extern void xchdir(const char *path);
-extern void xsetenv(const char *key, const char *value);
-extern int xopen(const char *pathname, int flags);
-extern int xopen3(const char *pathname, int flags, int mode);
-extern off_t xlseek(int fd, off_t offset, int whence);
-extern off_t fdlength(int fd);
+void xsetgid(gid_t gid);
+void xsetuid(uid_t uid);
+void xchdir(const char *path);
+void xsetenv(const char *key, const char *value);
+void xunlink(const char *pathname);
+int xopen(const char *pathname, int flags);
+int xopen3(const char *pathname, int flags, int mode);
+off_t xlseek(int fd, off_t offset, int whence);
+off_t fdlength(int fd);
 
 
 int xsocket(int domain, int type, int protocol);

Modified: trunk/busybox/libbb/xfuncs.c
===================================================================
--- trunk/busybox/libbb/xfuncs.c	2007-04-05 21:14:29 UTC (rev 18341)
+++ trunk/busybox/libbb/xfuncs.c	2007-04-05 21:25:15 UTC (rev 18342)
@@ -122,6 +122,12 @@
 	return ret;
 }
 
+void xunlink(const char *pathname)
+{
+	if (unlink(pathname))
+		bb_perror_msg_and_die("cannot remove file '%s'", pathname);
+}
+
 // Turn on nonblocking I/O on a fd
 int ndelay_on(int fd)
 {




More information about the busybox-cvs mailing list