mailing list of musl libc
 help / color / mirror / code / Atom feed
e3fda06faa016fae9cb9e3e08aeb49c841188489 blob 1612 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
 
#include <sys/stat.h>
#include <sys/time.h>
#include <fcntl.h>
#include <errno.h>
#include "syscall.h"

#define IS32BIT(x) !((x)+0x80000000ULL>>32)
#define NS_SPECIAL(ns) ((ns)==UTIME_NOW || (ns)==UTIME_OMIT)

int utimensat(int fd, const char *path, const struct timespec times[2], int flags)
{
	int r;
	if (times && times[0].tv_nsec==UTIME_NOW && times[1].tv_nsec==UTIME_NOW)
		times = 0;
#ifdef SYS_utimensat_time64
	time_t s0=0, s1=0;
	long ns0=0, ns1=0;
	if (times) {
		ns0 = times[0].tv_nsec;
		ns1 = times[1].tv_nsec;
		if (!NS_SPECIAL(ns0)) s0 = times[0].tv_sec;
		if (!NS_SPECIAL(ns1)) s1 = times[1].tv_sec;
	}
	r = __syscall(SYS_utimensat_time64, fd, path, times ?
		((long long[]){s0, ns0, s1, ns1}) : 0, flags);
	if (SYS_utimensat == SYS_utimensat_time64 || r!=-ENOSYS)
		return __syscall_ret(r);
	if (!IS32BIT(s0) || !IS32BIT(s1))
		return __syscall_ret(-ENOTSUP);
	r = __syscall(SYS_utimensat, fd, path,
		times ? ((long[]){s0, ns0, s1, ns1}) : 0, flags);
#else
	r = __syscall(SYS_utimensat, fd, path, times, flags);
#endif

#ifdef SYS_futimesat
	if (r != -ENOSYS || flags) return __syscall_ret(r);
	long *tv=0, tmp[4];
	if (times) {
		int i;
		tv = tmp;
		for (i=0; i<2; i++) {
			if (times[i].tv_nsec >= 1000000000ULL) {
				if (NS_SPECIAL(times[i].tv_nsec))
					return __syscall_ret(-ENOSYS);
				return __syscall_ret(-EINVAL);
			}
			tmp[2*i+0] = times[i].tv_sec;
			tmp[2*i+1] = times[i].tv_nsec / 1000;
		}
	}

	r = __syscall(SYS_futimesat, fd, path, tv);
	if (r != -ENOSYS || fd != AT_FDCWD) return __syscall_ret(r);
	r = __syscall(SYS_utimes, path, tv);
#endif
	return __syscall_ret(r);
}
debug log:

solving e3fda06faa01 ...
found e3fda06faa01 in https://inbox.vuxu.org/musl/20201227184032.22413-10-alobakin@pm.me/
found 730723a9ea70 in https://git.vuxu.org/mirror/musl/
preparing index
index prepared:
100644 730723a9ea70d4f88e20155f1f7e33b366a2281e	src/stat/utimensat.c

applying [1/1] https://inbox.vuxu.org/musl/20201227184032.22413-10-alobakin@pm.me/
diff --git a/src/stat/utimensat.c b/src/stat/utimensat.c
index 730723a9ea70..e3fda06faa01 100644

Checking patch src/stat/utimensat.c...
Applied patch src/stat/utimensat.c cleanly.

index at:
100644 e3fda06faa016fae9cb9e3e08aeb49c841188489	src/stat/utimensat.c

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).