use utimes() rather than obsolescent utime()
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
This commit is contained in:
parent
cc8b6871a7
commit
a307af1af6
@ -143,9 +143,9 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle)
|
|||||||
}
|
}
|
||||||
/* same for utime */
|
/* same for utime */
|
||||||
if (archive_handle->ah_flags & ARCHIVE_RESTORE_DATE) {
|
if (archive_handle->ah_flags & ARCHIVE_RESTORE_DATE) {
|
||||||
struct utimbuf t;
|
struct timeval t = {.tv_sec = file_header->mtime,
|
||||||
t.actime = t.modtime = file_header->mtime;
|
.tv_usec = 0};
|
||||||
utime(file_header->name, &t);
|
utimes(file_header->name, &t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,13 +49,13 @@ int touch_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
"date\0" Required_argument "d"
|
"date\0" Required_argument "d"
|
||||||
;
|
;
|
||||||
# endif
|
# endif
|
||||||
struct utimbuf timebuf;
|
struct timeval timebuf = {.tv_usec = 0};
|
||||||
char *reference_file = NULL;
|
char *reference_file = NULL;
|
||||||
char *date_str = NULL;
|
char *date_str = NULL;
|
||||||
#else
|
#else
|
||||||
# define reference_file NULL
|
# define reference_file NULL
|
||||||
# define date_str NULL
|
# define date_str NULL
|
||||||
# define timebuf (*(struct utimbuf*)NULL)
|
# define timebuf (*(struct timeval*)NULL)
|
||||||
#endif
|
#endif
|
||||||
int fd;
|
int fd;
|
||||||
int status = EXIT_SUCCESS;
|
int status = EXIT_SUCCESS;
|
||||||
@ -83,8 +83,7 @@ int touch_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
if (reference_file) {
|
if (reference_file) {
|
||||||
struct stat stbuf;
|
struct stat stbuf;
|
||||||
xstat(reference_file, &stbuf);
|
xstat(reference_file, &stbuf);
|
||||||
timebuf.actime = stbuf.st_atime;
|
timebuf.tv_sec = stbuf.st_mtime;
|
||||||
timebuf.modtime = stbuf.st_mtime;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (date_str) {
|
if (date_str) {
|
||||||
@ -100,12 +99,11 @@ int touch_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
tm_time.tm_isdst = -1; /* Be sure to recheck dst */
|
tm_time.tm_isdst = -1; /* Be sure to recheck dst */
|
||||||
t = validate_tm_time(date_str, &tm_time);
|
t = validate_tm_time(date_str, &tm_time);
|
||||||
|
|
||||||
timebuf.actime = t;
|
timebuf.tv_sec = t;
|
||||||
timebuf.modtime = t;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (utime(*argv, reference_file ? &timebuf : NULL)) {
|
if (utimes(*argv, reference_file ? &timebuf : NULL)) {
|
||||||
if (errno == ENOENT) { /* no such file */
|
if (errno == ENOENT) { /* no such file */
|
||||||
if (opts) { /* creation is disabled, so ignore */
|
if (opts) { /* creation is disabled, so ignore */
|
||||||
continue;
|
continue;
|
||||||
@ -116,7 +114,7 @@ int touch_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
);
|
);
|
||||||
if ((fd >= 0) && !close(fd)) {
|
if ((fd >= 0) && !close(fd)) {
|
||||||
if (reference_file)
|
if (reference_file)
|
||||||
utime(*argv, &timebuf);
|
utimes(*argv, &timebuf);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -374,12 +374,10 @@ int FAST_FUNC copy_file(const char *source, const char *dest, int flags)
|
|||||||
/* Cannot happen: */
|
/* Cannot happen: */
|
||||||
/* && !(flags & (FILEUTILS_MAKE_SOFTLINK|FILEUTILS_MAKE_HARDLINK)) */
|
/* && !(flags & (FILEUTILS_MAKE_SOFTLINK|FILEUTILS_MAKE_HARDLINK)) */
|
||||||
) {
|
) {
|
||||||
struct utimbuf times;
|
struct timeval times = {.tv_sec = source_stat.st_mtime,
|
||||||
|
.tv_usec = 0};
|
||||||
times.actime = source_stat.st_atime;
|
|
||||||
times.modtime = source_stat.st_mtime;
|
|
||||||
/* BTW, utimes sets usec-precision time - just FYI */
|
/* BTW, utimes sets usec-precision time - just FYI */
|
||||||
if (utime(dest, ×) < 0)
|
if (utimes(dest, ×) < 0)
|
||||||
bb_perror_msg("can't preserve %s of '%s'", "times", dest);
|
bb_perror_msg("can't preserve %s of '%s'", "times", dest);
|
||||||
if (chown(dest, source_stat.st_uid, source_stat.st_gid) < 0) {
|
if (chown(dest, source_stat.st_uid, source_stat.st_gid) < 0) {
|
||||||
source_stat.st_mode &= ~(S_ISUID | S_ISGID);
|
source_stat.st_mode &= ~(S_ISUID | S_ISGID);
|
||||||
|
@ -73,7 +73,7 @@ rm -f src.typos
|
|||||||
# don't allow obsolete functions
|
# don't allow obsolete functions
|
||||||
#
|
#
|
||||||
find $srcdir/.. '(' -name '*.c' -o -name '*.h' ')' -print0 | xargs -0 \
|
find $srcdir/.. '(' -name '*.c' -o -name '*.h' ')' -print0 | xargs -0 \
|
||||||
grep -E -e '\<(bcmp|bcopy|bzero|getwd|index|mktemp|rindex|utimes|sigblock|siggetmask|sigsetmask)\>[[:space:]]*\(' \
|
grep -E -e '\<(bcmp|bcopy|bzero|getwd|index|mktemp|rindex|utime|sigblock|siggetmask|sigsetmask)\>[[:space:]]*\(' \
|
||||||
| sed -e "s:^$srcdir/\.\./::g" > src.obsolete.funcs
|
| sed -e "s:^$srcdir/\.\./::g" > src.obsolete.funcs
|
||||||
testing "Obsolete function usage" "cat src.obsolete.funcs" "" "" ""
|
testing "Obsolete function usage" "cat src.obsolete.funcs" "" "" ""
|
||||||
rm -f src.obsolete.funcs
|
rm -f src.obsolete.funcs
|
||||||
|
Loading…
Reference in New Issue
Block a user