mailing list of musl libc
 help / color / mirror / code / Atom feed
7b30d2a8dba5b38325c541bf57425ccc165d380b blob 1882 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
 
#define _GNU_SOURCE
#include <fcntl.h>
#include <stdarg.h>
#include <errno.h>
#include "syscall.h"
#include "libc.h"

int fcntl(int fd, int cmd, ...)
{
	long arg;
	va_list ap;

	va_start(ap, cmd);
	switch (cmd) {
	case F_DUPFD:
	case F_DUPFD_CLOEXEC:
	case F_SETFD:
	case F_SETFL:
	case F_SETOWN:
	case F_SETSIG:
	case F_SETLEASE:
	case F_NOTIFY:
	case F_SETPIPE_SZ:
		arg = va_arg(ap, int);
		break;
	case F_GETFD:
	case F_GETFL:
	case F_GETOWN:
	case F_GETSIG:
	case F_GETLEASE:
	case F_GETPIPE_SZ:
		arg = 0;
		break;
	case F_SETLK:
	case F_SETLKW:
	case F_GETLK:
		arg = (long)va_arg(ap, struct flock *);
		break;
	case F_GETOWN_EX:
	case F_SETOWN_EX:
		arg = (long)va_arg(ap, struct f_owner_ex *);
		break;
	default:
		arg = va_arg(ap, long);
	}
	va_end(ap);

	if (cmd == F_SETFL) arg |= O_LARGEFILE;
	if (cmd == F_SETLKW) return syscall_cp(SYS_fcntl, fd, cmd, (void *)arg);
	if (cmd == F_GETOWN) {
		struct f_owner_ex ex;
		int ret = __syscall(SYS_fcntl, fd, F_GETOWN_EX, &ex);
		if (ret == -EINVAL) return __syscall(SYS_fcntl, fd, cmd, (void *)arg);
		if (ret) return __syscall_ret(ret);
		return ex.type == F_OWNER_PGRP ? -ex.pid : ex.pid;
	}
	if (cmd == F_DUPFD_CLOEXEC) {
		int ret = __syscall(SYS_fcntl, fd, F_DUPFD_CLOEXEC, arg);
		if (ret != -EINVAL) {
			if (ret >= 0)
				__syscall(SYS_fcntl, ret, F_SETFD, FD_CLOEXEC);
			return __syscall_ret(ret);
		}
		ret = __syscall(SYS_fcntl, fd, F_DUPFD_CLOEXEC, 0);
		if (ret != -EINVAL) {
			if (ret >= 0) __syscall(SYS_close, ret);
			return __syscall_ret(-EINVAL);
		}
		ret = __syscall(SYS_fcntl, fd, F_DUPFD, arg);
		if (ret >= 0) __syscall(SYS_fcntl, ret, F_SETFD, FD_CLOEXEC);
		return __syscall_ret(ret);
	}
	switch (cmd) {
	case F_SETLK:
	case F_SETLKW:
	case F_GETLK:
	case F_GETOWN_EX:
	case F_SETOWN_EX:
		return syscall(SYS_fcntl, fd, cmd, (void *)arg);
	default:
		return syscall(SYS_fcntl, fd, cmd, arg);
	}
}
debug log:

solving 7b30d2a ...
found 7b30d2a in https://inbox.vuxu.org/musl/20170621010811.GC1627@brightrain.aerifal.cx/
found 4c34ba0 in https://git.vuxu.org/mirror/musl/
preparing index
index prepared:
100644 4c34ba04f9ad0736b3cbbc32b3e94005632f692e	src/fcntl/fcntl.c

applying [1/1] https://inbox.vuxu.org/musl/20170621010811.GC1627@brightrain.aerifal.cx/
diff --git a/src/fcntl/fcntl.c b/src/fcntl/fcntl.c
index 4c34ba0..7b30d2a 100644

Checking patch src/fcntl/fcntl.c...
Applied patch src/fcntl/fcntl.c cleanly.

index at:
100644 7b30d2a8dba5b38325c541bf57425ccc165d380b	src/fcntl/fcntl.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).