mirror of
https://github.com/sheumann/hush.git
synced 2024-09-12 00:55:11 +00:00
libbb: add xunlink()
patch: do not try to delete same file twice
This commit is contained in:
parent
9020d850bf
commit
1bb552b1d9
@ -105,8 +105,7 @@ int bbunpack(char **argv,
|
|||||||
if (new_name == filename)
|
if (new_name == filename)
|
||||||
filename[strlen(filename)] = '.';
|
filename[strlen(filename)] = '.';
|
||||||
}
|
}
|
||||||
if (unlink(del) < 0)
|
xunlink(del);
|
||||||
bb_perror_msg_and_die("cannot remove %s", del);
|
|
||||||
|
|
||||||
#if 0 /* Currently buggy - wrong name: "a.gz: 261% - replaced with a.gz" */
|
#if 0 /* Currently buggy - wrong name: "a.gz: 261% - replaced with a.gz" */
|
||||||
/* Extreme bloat for gunzip compat */
|
/* Extreme bloat for gunzip compat */
|
||||||
|
@ -260,12 +260,9 @@ int patch_main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
if ((dest_cur_line == 0) || (dest_beg_line == 0)) {
|
if ((dest_cur_line == 0) || (dest_beg_line == 0)) {
|
||||||
/* The new patched file is empty, remove it */
|
/* The new patched file is empty, remove it */
|
||||||
if (unlink(new_filename) == -1) {
|
xunlink(new_filename);
|
||||||
bb_perror_msg_and_die("cannot remove file %s", new_filename);
|
if (strcmp(new_filename, original_filename) != 0)
|
||||||
}
|
xunlink(original_filename);
|
||||||
if (unlink(original_filename) == -1) {
|
|
||||||
bb_perror_msg_and_die("cannot remove original file %s", new_filename);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -293,14 +293,15 @@ extern void sig_pause(void);
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern void xsetgid(gid_t gid);
|
void xsetgid(gid_t gid);
|
||||||
extern void xsetuid(uid_t uid);
|
void xsetuid(uid_t uid);
|
||||||
extern void xchdir(const char *path);
|
void xchdir(const char *path);
|
||||||
extern void xsetenv(const char *key, const char *value);
|
void xsetenv(const char *key, const char *value);
|
||||||
extern int xopen(const char *pathname, int flags);
|
void xunlink(const char *pathname);
|
||||||
extern int xopen3(const char *pathname, int flags, int mode);
|
int xopen(const char *pathname, int flags);
|
||||||
extern off_t xlseek(int fd, off_t offset, int whence);
|
int xopen3(const char *pathname, int flags, int mode);
|
||||||
extern off_t fdlength(int fd);
|
off_t xlseek(int fd, off_t offset, int whence);
|
||||||
|
off_t fdlength(int fd);
|
||||||
|
|
||||||
|
|
||||||
int xsocket(int domain, int type, int protocol);
|
int xsocket(int domain, int type, int protocol);
|
||||||
|
@ -122,6 +122,12 @@ int xopen3(const char *pathname, int flags, int mode)
|
|||||||
return ret;
|
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
|
// Turn on nonblocking I/O on a fd
|
||||||
int ndelay_on(int fd)
|
int ndelay_on(int fd)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user