mirror of
https://github.com/sheumann/hush.git
synced 2024-08-20 04:28:57 +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)
|
||||
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 */
|
||||
|
@ -260,12 +260,9 @@ int patch_main(int argc, char **argv)
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -293,14 +293,15 @@ extern void sig_pause(void);
|
||||
|
||||
|
||||
|
||||
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);
|
||||
|
@ -122,6 +122,12 @@ int xopen3(const char *pathname, int flags, int mode)
|
||||
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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user