Skip to content
This repository was archived by the owner on Jun 9, 2020. It is now read-only.

Commit 8dee88d

Browse files
authored
Merge pull request #65 from kazumi007/impl-pr-set-name
Add PR_SET_NAME cmd in prctl()
2 parents 2e570f7 + e02e6b9 commit 8dee88d

2 files changed

Lines changed: 63 additions & 4 deletions

File tree

include/linux/futex.h

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,51 @@ struct linux_robust_list_head {
9292
l_uintptr_t pending_list;
9393
};
9494

95+
#define LINUX_PR_SET_PDEATHSIG 1
96+
#define LINUX_PR_GET_PDEATHSIG 2
97+
#define LINUX_PR_GET_DUMPABLE 3
98+
#define LINUX_PR_SET_DUMPABLE 4
99+
#define LINUX_PR_GET_UNALIGN 5
100+
#define LINUX_PR_SET_UNALIGN 6
101+
#define LINUX_PR_GET_KEEPCAPS 7
102+
#define LINUX_PR_SET_KEEPCAPS 8
103+
#define LINUX_PR_GET_FPEMU 9
104+
#define LINUX_PR_SET_FPEMU 10
105+
#define LINUX_PR_GET_FPEXC 11
106+
#define LINUX_PR_SET_FPEXC 12
107+
#define LINUX_PR_GET_TIMING 13
108+
#define LINUX_PR_SET_TIMING 14
109+
#define LINUX_PR_SET_NAME 15
110+
#define LINUX_PR_GET_NAME 16
111+
112+
#define LINIX_PR_GET_ENDIAN 19
113+
#define LINIX_PR_SET_ENDIAN 20
114+
#define LINIX_PR_GET_SECCOMP 21
115+
#define LINIX_PR_SET_SECCOMP 22
116+
#define LINIX_PR_CAPBSET_READ 23
117+
#define LINIX_PR_CAPBSET_DROP 24
118+
#define LINIX_PR_GET_TSC 25
119+
#define LINIX_PR_SET_TSC 26
120+
#define LINIX_PR_GET_SECUREBITS 27
121+
#define LINIX_PR_SET_SECUREBITS 28
122+
#define LINIX_PR_SET_TIMERSLACK 29
123+
#define LINIX_PR_GET_TIMERSLACK 30
124+
#define LINIX_PR_TASK_PERF_EVENTS_DISABLE 31
125+
#define LINIX_PR_TASK_PERF_EVENTS_ENABLE 32
126+
#define LINIX_PR_MCE_KILL 33
127+
#define LINIX_PR_MCE_KILL_GET 34
128+
#define LINIX_PR_SET_MM 35
129+
#define LINIX_PR_SET_CHILD_SUBREAPER 36
130+
#define LINIX_PR_GET_CHILD_SUBREAPER 37
131+
#define LINIX_PR_SET_NO_NEW_PRIVS 38
132+
#define LINIX_PR_GET_NO_NEW_PRIVS 39
133+
#define LINIX_PR_GET_TID_ADDRESS 40
134+
#define LINIX_PR_SET_THP_DISABLE 41
135+
#define LINIX_PR_GET_THP_DISABLE 42
136+
#define LINIX_PR_MPX_ENABLE_MANAGEMENT 43
137+
#define LINIX_PR_MPX_DISABLE_MANAGEMENT 44
138+
#define LINIX_PR_SET_FP_MODE 45
139+
#define LINIX_PR_GET_FP_MODE 46
140+
#define LINIX_PR_CAP_AMBIENT 47
141+
95142
#endif /* !_LINUX_FUTEX_H */

src/proc/process.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -413,11 +413,23 @@ DEFINE_SYSCALL(uname, gaddr_t, buf_ptr)
413413
return 0;
414414
}
415415

416-
DEFINE_SYSCALL(prctl, int, option)
416+
DEFINE_SYSCALL(prctl, int, option, unsigned long, arg1, unsigned long, arg2, unsigned long, arg3, unsigned long, arg4, unsigned long, arg5)
417417
{
418-
/* FIXME */
419-
printk("prctl is not implemented yet\n");
420-
return -ENOSYS;
418+
switch (option) {
419+
case LINUX_PR_SET_NAME: {
420+
char buf[16];
421+
if (copy_from_user(buf, (gaddr_t)arg1, sizeof(buf))) {
422+
return -LINUX_EFAULT;
423+
}
424+
// trancate if the legnth of arg1 exceeds 16byte.
425+
buf[15] = '\0';
426+
pthread_setname_np(buf);
427+
return 0;
428+
}
429+
default:
430+
warnk("unkown prctl cmd: %d\n", option);
431+
return -LINUX_EINVAL;
432+
}
421433
}
422434

423435
DEFINE_SYSCALL(arch_prctl, int, code, gaddr_t, addr)

0 commit comments

Comments
 (0)