aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2012-06-25 07:55:09 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-07-14 08:35:54 -0400
commit55e4def0a6e79e7eb53017c4935adfed76510cd7 (patch)
treee970472b64e95f32933ad49cb36d0ae814595e54 /fs
parentc3c4f69424db0760239762d36d0b1b6ae524008b (diff)
VFS: Make chown() and lchown() call fchownat()
Make the chown() and lchown() syscalls jump to the fchownat() syscall with the appropriate extra arguments. Signed-off-by: David Howells <dhowells@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r--fs/open.c41
1 files changed, 7 insertions, 34 deletions
diff --git a/fs/open.c b/fs/open.c
index 764cc9c201a5..75bea868ef8a 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -537,25 +537,6 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
537 return error; 537 return error;
538} 538}
539 539
540SYSCALL_DEFINE3(chown, const char __user *, filename, uid_t, user, gid_t, group)
541{
542 struct path path;
543 int error;
544
545 error = user_path(filename, &path);
546 if (error)
547 goto out;
548 error = mnt_want_write(path.mnt);
549 if (error)
550 goto out_release;
551 error = chown_common(&path, user, group);
552 mnt_drop_write(path.mnt);
553out_release:
554 path_put(&path);
555out:
556 return error;
557}
558
559SYSCALL_DEFINE5(fchownat, int, dfd, const char __user *, filename, uid_t, user, 540SYSCALL_DEFINE5(fchownat, int, dfd, const char __user *, filename, uid_t, user,
560 gid_t, group, int, flag) 541 gid_t, group, int, flag)
561{ 542{
@@ -583,23 +564,15 @@ out:
583 return error; 564 return error;
584} 565}
585 566
586SYSCALL_DEFINE3(lchown, const char __user *, filename, uid_t, user, gid_t, group) 567SYSCALL_DEFINE3(chown, const char __user *, filename, uid_t, user, gid_t, group)
587{ 568{
588 struct path path; 569 return sys_fchownat(AT_FDCWD, filename, user, group, 0);
589 int error; 570}
590 571
591 error = user_lpath(filename, &path); 572SYSCALL_DEFINE3(lchown, const char __user *, filename, uid_t, user, gid_t, group)
592 if (error) 573{
593 goto out; 574 return sys_fchownat(AT_FDCWD, filename, user, group,
594 error = mnt_want_write(path.mnt); 575 AT_SYMLINK_NOFOLLOW);
595 if (error)
596 goto out_release;
597 error = chown_common(&path, user, group);
598 mnt_drop_write(path.mnt);
599out_release:
600 path_put(&path);
601out:
602 return error;
603} 576}
604 577
605SYSCALL_DEFINE3(fchown, unsigned int, fd, uid_t, user, gid_t, group) 578SYSCALL_DEFINE3(fchown, unsigned int, fd, uid_t, user, gid_t, group)