diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2011-01-04 19:54:36 +0700 |
---|---|---|
committer | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2011-01-04 19:54:36 +0700 |
commit | 47a20f7daf954c90bbc77d2c108cb366171c650f (patch) | |
tree | 06ed9ed8cb4f7cea8dfa75de197f54b9bc18ca67 | |
parent | 8cef222175855ae08f3768a5586b00650240403d (diff) | |
parent | 6722737ece4b8db3e30b53aef8f981f53db1621e (diff) | |
download | busybox-w32-47a20f7daf954c90bbc77d2c108cb366171c650f.tar.gz busybox-w32-47a20f7daf954c90bbc77d2c108cb366171c650f.tar.bz2 busybox-w32-47a20f7daf954c90bbc77d2c108cb366171c650f.zip |
Merge commit '6722737ece4b8db3e30b53aef8f981f53db1621e'
Conflicts:
coreutils/dos2unix.c
-rw-r--r-- | coreutils/dos2unix.c | 10 | ||||
-rw-r--r-- | editors/diff.c | 5 | ||||
-rw-r--r-- | editors/patch.c | 3 | ||||
-rw-r--r-- | editors/sed.c | 4 | ||||
-rw-r--r-- | include/libbb.h | 1 | ||||
-rw-r--r-- | libbb/xfuncs_printf.c | 8 | ||||
-rw-r--r-- | printutils/lpr.c | 4 |
7 files changed, 17 insertions, 18 deletions
diff --git a/coreutils/dos2unix.c b/coreutils/dos2unix.c index 8aa1d93b5..35fa11247 100644 --- a/coreutils/dos2unix.c +++ b/coreutils/dos2unix.c | |||
@@ -41,14 +41,10 @@ static void convert(char *fn, int conv_type) | |||
41 | fstat(fileno(in), &st); | 41 | fstat(fileno(in), &st); |
42 | 42 | ||
43 | temp_fn = xasprintf("%sXXXXXX", resolved_fn); | 43 | temp_fn = xasprintf("%sXXXXXX", resolved_fn); |
44 | i = mkstemp(temp_fn); | 44 | i = xmkstemp(temp_fn); |
45 | if (i == -1 | 45 | if (!ENABLE_PLATFORM_MINGW32 && fchmod(i, st.st_mode) == -1) |
46 | #if !ENABLE_PLATFORM_MINGW32 | ||
47 | || fchmod(i, st.st_mode) == -1 | ||
48 | #endif | ||
49 | ) { | ||
50 | bb_simple_perror_msg_and_die(temp_fn); | 46 | bb_simple_perror_msg_and_die(temp_fn); |
51 | } | 47 | |
52 | out = xfdopen_for_write(i); | 48 | out = xfdopen_for_write(i); |
53 | } | 49 | } |
54 | 50 | ||
diff --git a/editors/diff.c b/editors/diff.c index 83de52753..d9d709db6 100644 --- a/editors/diff.c +++ b/editors/diff.c | |||
@@ -685,9 +685,8 @@ static int diffreg(char *file[2]) | |||
685 | */ | 685 | */ |
686 | if (lseek(fd, 0, SEEK_SET) == -1 && errno == ESPIPE) { | 686 | if (lseek(fd, 0, SEEK_SET) == -1 && errno == ESPIPE) { |
687 | char name[] = "/tmp/difXXXXXX"; | 687 | char name[] = "/tmp/difXXXXXX"; |
688 | int fd_tmp = mkstemp(name); | 688 | int fd_tmp = xmkstemp(name); |
689 | if (fd_tmp < 0) | 689 | |
690 | bb_perror_msg_and_die("mkstemp"); | ||
691 | unlink(name); | 690 | unlink(name); |
692 | if (bb_copyfd_eof(fd, fd_tmp) < 0) | 691 | if (bb_copyfd_eof(fd, fd_tmp) < 0) |
693 | xfunc_die(); | 692 | xfunc_die(); |
diff --git a/editors/patch.c b/editors/patch.c index fff06907f..33ff8b569 100644 --- a/editors/patch.c +++ b/editors/patch.c | |||
@@ -200,8 +200,7 @@ int copy_tempfile(int fdin, char *name, char **tempname) | |||
200 | int fd; | 200 | int fd; |
201 | 201 | ||
202 | *tempname = xasprintf("%sXXXXXX", name); | 202 | *tempname = xasprintf("%sXXXXXX", name); |
203 | fd = mkstemp(*tempname); | 203 | fd = xmkstemp(*tempname); |
204 | if(-1 == fd) bb_perror_msg_and_die("no temp file"); | ||
205 | 204 | ||
206 | // Set permissions of output file | 205 | // Set permissions of output file |
207 | fstat(fdin, &statbuf); | 206 | fstat(fdin, &statbuf); |
diff --git a/editors/sed.c b/editors/sed.c index 8d9f7b25b..964d0405e 100644 --- a/editors/sed.c +++ b/editors/sed.c | |||
@@ -1370,9 +1370,7 @@ int sed_main(int argc UNUSED_PARAM, char **argv) | |||
1370 | } | 1370 | } |
1371 | 1371 | ||
1372 | G.outname = xasprintf("%sXXXXXX", argv[i]); | 1372 | G.outname = xasprintf("%sXXXXXX", argv[i]); |
1373 | nonstdoutfd = mkstemp(G.outname); | 1373 | nonstdoutfd = xmkstemp(G.outname); |
1374 | if (-1 == nonstdoutfd) | ||
1375 | bb_perror_msg_and_die("can't create temp file %s", G.outname); | ||
1376 | G.nonstdout = xfdopen_for_write(nonstdoutfd); | 1374 | G.nonstdout = xfdopen_for_write(nonstdoutfd); |
1377 | 1375 | ||
1378 | /* Set permissions/owner of output file */ | 1376 | /* Set permissions/owner of output file */ |
diff --git a/include/libbb.h b/include/libbb.h index 99bfe085c..325aae2a3 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -436,6 +436,7 @@ int xopen_stdin(const char *pathname) FAST_FUNC; | |||
436 | void xrename(const char *oldpath, const char *newpath) FAST_FUNC; | 436 | void xrename(const char *oldpath, const char *newpath) FAST_FUNC; |
437 | int rename_or_warn(const char *oldpath, const char *newpath) FAST_FUNC; | 437 | int rename_or_warn(const char *oldpath, const char *newpath) FAST_FUNC; |
438 | off_t xlseek(int fd, off_t offset, int whence) FAST_FUNC; | 438 | off_t xlseek(int fd, off_t offset, int whence) FAST_FUNC; |
439 | int xmkstemp(char *template) FAST_FUNC; | ||
439 | off_t fdlength(int fd) FAST_FUNC; | 440 | off_t fdlength(int fd) FAST_FUNC; |
440 | 441 | ||
441 | uoff_t FAST_FUNC get_volume_size_in_bytes(int fd, | 442 | uoff_t FAST_FUNC get_volume_size_in_bytes(int fd, |
diff --git a/libbb/xfuncs_printf.c b/libbb/xfuncs_printf.c index 8e60e2165..8a6d7e1d1 100644 --- a/libbb/xfuncs_printf.c +++ b/libbb/xfuncs_printf.c | |||
@@ -240,6 +240,14 @@ off_t FAST_FUNC xlseek(int fd, off_t offset, int whence) | |||
240 | return off; | 240 | return off; |
241 | } | 241 | } |
242 | 242 | ||
243 | int FAST_FUNC xmkstemp(char *template) | ||
244 | { | ||
245 | int fd = mkstemp(template); | ||
246 | if (fd < 0) | ||
247 | bb_perror_msg_and_die("can't create temp file '%s'", template); | ||
248 | return fd; | ||
249 | } | ||
250 | |||
243 | // Die with supplied filename if this FILE* has ferror set. | 251 | // Die with supplied filename if this FILE* has ferror set. |
244 | void FAST_FUNC die_if_ferror(FILE *fp, const char *fn) | 252 | void FAST_FUNC die_if_ferror(FILE *fp, const char *fn) |
245 | { | 253 | { |
diff --git a/printutils/lpr.c b/printutils/lpr.c index fb7860d41..284917926 100644 --- a/printutils/lpr.c +++ b/printutils/lpr.c | |||
@@ -159,9 +159,7 @@ int lpqr_main(int argc UNUSED_PARAM, char *argv[]) | |||
159 | // if data file is stdin, we need to dump it first | 159 | // if data file is stdin, we need to dump it first |
160 | if (LONE_DASH(*argv)) { | 160 | if (LONE_DASH(*argv)) { |
161 | strcpy(tempfile, "/tmp/lprXXXXXX"); | 161 | strcpy(tempfile, "/tmp/lprXXXXXX"); |
162 | dfd = mkstemp(tempfile); | 162 | dfd = xmkstemp(tempfile); |
163 | if (dfd < 0) | ||
164 | bb_perror_msg_and_die("mkstemp"); | ||
165 | bb_copyfd_eof(STDIN_FILENO, dfd); | 163 | bb_copyfd_eof(STDIN_FILENO, dfd); |
166 | xlseek(dfd, 0, SEEK_SET); | 164 | xlseek(dfd, 0, SEEK_SET); |
167 | *argv = (char*)bb_msg_standard_input; | 165 | *argv = (char*)bb_msg_standard_input; |