-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfcntl_GETPATH.patch
More file actions
56 lines (53 loc) · 1.55 KB
/
fcntl_GETPATH.patch
File metadata and controls
56 lines (53 loc) · 1.55 KB
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
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index 7e5e588443..493c8166f8 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -881,6 +881,16 @@ kern_fcntl(int fd, int cmd, union fcntl_dat *dat, struct ucred *cred)
error = VOP_ADVLOCK(vp, (caddr_t)p->p_leader, F_GETLK,
&dat->fc_flock, F_POSIX);
break;
+
+ case F_GETPATH:
+ if (fp->f_type != DTYPE_VNODE) {
+ error = EBADF;
+ break;
+ }
+ error = cache_fullpath(p, &fp->f_nchandle, NULL, &dat->fc_path.ptr,
+ &dat->fc_path.buf, 1);
+ break;
+
default:
error = EINVAL;
break;
@@ -948,6 +958,11 @@ sys_fcntl(struct sysmsg *sysmsg, const struct fcntl_args *uap)
error = copyout(&dat.fc_flock, (caddr_t)uap->arg,
sizeof(struct flock));
break;
+ case F_GETPATH:
+ error = copyout(dat.fc_path.ptr, (caddr_t)uap->arg,
+ strlen(dat.fc_path.ptr) + 1);
+ kfree(dat.fc_path.buf, M_TEMP);
+ break;
}
}
diff --git a/sys/sys/fcntl.h b/sys/sys/fcntl.h
index aa78973843..1fe4277b63 100644
--- a/sys/sys/fcntl.h
+++ b/sys/sys/fcntl.h
@@ -207,6 +207,7 @@
#endif
#if __BSD_VISIBLE
#define F_DUP2FD_CLOEXEC 18 /* Like F_DUP2FD with FD_CLOEXEC set */
+#define F_GETPATH 19 /* retrieve full path to file associated with fd */
#endif
/* file descriptor flags (F_GETFD, F_SETFD) */
@@ -243,6 +244,10 @@ union fcntl_dat {
int fc_flags; /* F_GETFL/F_SETFL */
int fc_owner; /* F_GETOWN/F_SETOWN */
struct flock fc_flock; /* F_GETLK/F_SETLK */
+ struct {
+ char *ptr;
+ char *buf;
+ } fc_path; /* F_GETPATH */
};
#endif /* _KERNEL */