From 4c1e3817c469f491e007881e6345f8d0a3511fe3 Mon Sep 17 00:00:00 2001 From: Marcel Moolenaar Date: Tue, 16 Oct 2001 06:15:36 +0000 Subject: [PATCH] Implement linux_chown and linux_lchown. The fchown syscall maps directly to the native syscall, because no filename handling needs to be done. Tested by: Martin Blapp --- sys/alpha/linux/linux_dummy.c | 2 -- sys/compat/linux/linux_file.c | 42 ++++++++++++++++++++++++++++++++++ sys/i386/linux/linux_dummy.c | 3 --- sys/i386/linux/linux_proto.h | 20 ++++++---------- sys/i386/linux/linux_syscall.h | 3 +-- sys/i386/linux/linux_sysent.c | 4 ++-- 6 files changed, 52 insertions(+), 22 deletions(-) diff --git a/sys/alpha/linux/linux_dummy.c b/sys/alpha/linux/linux_dummy.c index 40456080a84a..c0cbed97a156 100644 --- a/sys/alpha/linux/linux_dummy.c +++ b/sys/alpha/linux/linux_dummy.c @@ -62,11 +62,9 @@ DUMMY(capget); DUMMY(capset); DUMMY(sendfile); -DUMMY(chown); DUMMY(getdtablesize); DUMMY(gethostname); DUMMY(getpagesize); -DUMMY(lchown); DUMMY(madvise); DUMMY(mincore); DUMMY(old_adjtimex); diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c index ed654ec011ed..4609a1b84b34 100644 --- a/sys/compat/linux/linux_file.c +++ b/sys/compat/linux/linux_file.c @@ -1127,3 +1127,45 @@ linux_fcntl64(struct thread *td, struct linux_fcntl64_args *args) return (fcntl_common(td, args)); } #endif /* __i386__ */ + +int +linux_chown(struct thread *td, struct linux_chown_args *args) +{ + struct chown_args bsd; + caddr_t sg; + + sg = stackgap_init(); + CHECKALTEXIST(td, &sg, args->path); + +#ifdef DEBUG + if (ldebug(chown)) + printf(ARGS(chown, "%s, %d, %d"), args->path, args->uid, + args->gid); +#endif + + bsd.path = args->path; + bsd.uid = args->uid; + bsd.gid = args->gid; + return (chown(td, &bsd)); +} + +int +linux_lchown(struct thread *td, struct linux_lchown_args *args) +{ + struct lchown_args bsd; + caddr_t sg; + + sg = stackgap_init(); + CHECKALTEXIST(td, &sg, args->path); + +#ifdef DEBUG + if (ldebug(lchown)) + printf(ARGS(lchown, "%s, %d, %d"), args->path, args->uid, + args->gid); +#endif + + bsd.path = args->path; + bsd.uid = args->uid; + bsd.gid = args->gid; + return (lchown(td, &bsd)); +} diff --git a/sys/i386/linux/linux_dummy.c b/sys/i386/linux/linux_dummy.c index f7bb58d12972..0e65fec7d901 100644 --- a/sys/i386/linux/linux_dummy.c +++ b/sys/i386/linux/linux_dummy.c @@ -67,9 +67,6 @@ DUMMY(sendfile); DUMMY(mmap2); DUMMY(truncate64); DUMMY(ftruncate64); -DUMMY(lchown); -DUMMY(fchown); -DUMMY(chown); DUMMY(setfsuid); DUMMY(setfsgid); DUMMY(pivot_root); diff --git a/sys/i386/linux/linux_proto.h b/sys/i386/linux/linux_proto.h index 597a452bb5f8..4919a3fae5bd 100644 --- a/sys/i386/linux/linux_proto.h +++ b/sys/i386/linux/linux_proto.h @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: src/sys/i386/linux/syscalls.master,v 1.44 2001/09/28 01:30:59 marcel Exp + * created from FreeBSD: src/sys/i386/linux/syscalls.master,v 1.45 2001/10/16 06:11:11 marcel Exp */ #ifndef _LINUX_SYSPROTO_H_ @@ -586,9 +586,9 @@ struct linux_fstat64_args { char flags_l_[PADL_(l_long)]; l_long flags; char flags_r_[PADR_(l_long)]; }; struct linux_lchown_args { - char filename_l_[PADL_(char *)]; char * filename; char filename_r_[PADR_(char *)]; - char user_l_[PADL_(l_uid_t)]; l_uid_t user; char user_r_[PADR_(l_uid_t)]; - char group_l_[PADL_(l_gid_t)]; l_gid_t group; char group_r_[PADR_(l_gid_t)]; + char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)]; + char uid_l_[PADL_(l_uid_t)]; l_uid_t uid; char uid_r_[PADR_(l_uid_t)]; + char gid_l_[PADL_(l_gid_t)]; l_gid_t gid; char gid_r_[PADR_(l_gid_t)]; }; struct linux_getuid_args { register_t dummy; @@ -604,15 +604,10 @@ struct linux_setgroups_args { char gidsetsize_l_[PADL_(l_int)]; l_int gidsetsize; char gidsetsize_r_[PADR_(l_int)]; char grouplist_l_[PADL_(l_gid_t *)]; l_gid_t * grouplist; char grouplist_r_[PADR_(l_gid_t *)]; }; -struct linux_fchown_args { - char fd_l_[PADL_(l_uint)]; l_uint fd; char fd_r_[PADR_(l_uint)]; - char user_l_[PADL_(l_uid_t)]; l_uid_t user; char user_r_[PADR_(l_uid_t)]; - char group_l_[PADL_(l_gid_t)]; l_gid_t group; char group_r_[PADR_(l_gid_t)]; -}; struct linux_chown_args { - char filename_l_[PADL_(char *)]; char * filename; char filename_r_[PADR_(char *)]; - char user_l_[PADL_(l_uid_t)]; l_uid_t user; char user_r_[PADR_(l_uid_t)]; - char group_l_[PADL_(l_gid_t)]; l_gid_t group; char group_r_[PADR_(l_gid_t)]; + char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)]; + char uid_l_[PADL_(l_uid_t)]; l_uid_t uid; char uid_r_[PADR_(l_uid_t)]; + char gid_l_[PADL_(l_gid_t)]; l_gid_t gid; char gid_r_[PADR_(l_gid_t)]; }; struct linux_setfsuid_args { char uid_l_[PADL_(l_uid_t)]; l_uid_t uid; char uid_r_[PADR_(l_uid_t)]; @@ -787,7 +782,6 @@ int linux_getuid __P((struct thread *, struct linux_getuid_args *)); int linux_getgid __P((struct thread *, struct linux_getgid_args *)); int linux_getgroups __P((struct thread *, struct linux_getgroups_args *)); int linux_setgroups __P((struct thread *, struct linux_setgroups_args *)); -int linux_fchown __P((struct thread *, struct linux_fchown_args *)); int linux_chown __P((struct thread *, struct linux_chown_args *)); int linux_setfsuid __P((struct thread *, struct linux_setfsuid_args *)); int linux_setfsgid __P((struct thread *, struct linux_setfsgid_args *)); diff --git a/sys/i386/linux/linux_syscall.h b/sys/i386/linux/linux_syscall.h index d4f497c6f668..bc166589201e 100644 --- a/sys/i386/linux/linux_syscall.h +++ b/sys/i386/linux/linux_syscall.h @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: src/sys/i386/linux/syscalls.master,v 1.44 2001/09/28 01:30:59 marcel Exp + * created from FreeBSD: src/sys/i386/linux/syscalls.master,v 1.45 2001/10/16 06:11:11 marcel Exp */ #define LINUX_SYS_exit 1 @@ -199,7 +199,6 @@ #define LINUX_SYS_setregid 204 #define LINUX_SYS_linux_getgroups 205 #define LINUX_SYS_linux_setgroups 206 -#define LINUX_SYS_linux_fchown 207 #define LINUX_SYS_setresuid 208 #define LINUX_SYS_getresuid 209 #define LINUX_SYS_setresgid 210 diff --git a/sys/i386/linux/linux_sysent.c b/sys/i386/linux/linux_sysent.c index ed7ee6ec8ea5..80bee2871ac1 100644 --- a/sys/i386/linux/linux_sysent.c +++ b/sys/i386/linux/linux_sysent.c @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: src/sys/i386/linux/syscalls.master,v 1.44 2001/09/28 01:30:59 marcel Exp + * created from FreeBSD: src/sys/i386/linux/syscalls.master,v 1.45 2001/10/16 06:11:11 marcel Exp */ #include "opt_compat.h" @@ -224,7 +224,7 @@ struct sysent linux_sysent[] = { { AS(setregid_args), (sy_call_t *)setregid }, /* 204 = setregid */ { AS(linux_getgroups_args), (sy_call_t *)linux_getgroups }, /* 205 = linux_getgroups */ { AS(linux_setgroups_args), (sy_call_t *)linux_setgroups }, /* 206 = linux_setgroups */ - { AS(linux_fchown_args), (sy_call_t *)linux_fchown }, /* 207 = linux_fchown */ + { AS(fchown_args), (sy_call_t *)fchown }, /* 207 = fchown */ { AS(setresuid_args), (sy_call_t *)setresuid }, /* 208 = setresuid */ { AS(getresuid_args), (sy_call_t *)getresuid }, /* 209 = getresuid */ { AS(setresgid_args), (sy_call_t *)setresgid }, /* 210 = setresgid */