aboutsummaryrefslogtreecommitdiffstats
path: root/fs/open.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/open.c')
-rw-r--r--fs/open.c82
1 files changed, 49 insertions, 33 deletions
diff --git a/fs/open.c b/fs/open.c
index d882fd2351d6..a3a78ceb2a2b 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -122,7 +122,7 @@ static int vfs_statfs64(struct dentry *dentry, struct statfs64 *buf)
122 return 0; 122 return 0;
123} 123}
124 124
125asmlinkage long sys_statfs(const char __user *pathname, struct statfs __user * buf) 125SYSCALL_DEFINE2(statfs, const char __user *, pathname, struct statfs __user *, buf)
126{ 126{
127 struct path path; 127 struct path path;
128 int error; 128 int error;
@@ -138,8 +138,7 @@ asmlinkage long sys_statfs(const char __user *pathname, struct statfs __user * b
138 return error; 138 return error;
139} 139}
140 140
141 141SYSCALL_DEFINE3(statfs64, const char __user *, pathname, size_t, sz, struct statfs64 __user *, buf)
142asmlinkage long sys_statfs64(const char __user *pathname, size_t sz, struct statfs64 __user *buf)
143{ 142{
144 struct path path; 143 struct path path;
145 long error; 144 long error;
@@ -157,8 +156,7 @@ asmlinkage long sys_statfs64(const char __user *pathname, size_t sz, struct stat
157 return error; 156 return error;
158} 157}
159 158
160 159SYSCALL_DEFINE2(fstatfs, unsigned int, fd, struct statfs __user *, buf)
161asmlinkage long sys_fstatfs(unsigned int fd, struct statfs __user * buf)
162{ 160{
163 struct file * file; 161 struct file * file;
164 struct statfs tmp; 162 struct statfs tmp;
@@ -176,7 +174,7 @@ out:
176 return error; 174 return error;
177} 175}
178 176
179asmlinkage long sys_fstatfs64(unsigned int fd, size_t sz, struct statfs64 __user *buf) 177SYSCALL_DEFINE3(fstatfs64, unsigned int, fd, size_t, sz, struct statfs64 __user *, buf)
180{ 178{
181 struct file * file; 179 struct file * file;
182 struct statfs64 tmp; 180 struct statfs64 tmp;
@@ -289,7 +287,7 @@ out:
289 return error; 287 return error;
290} 288}
291 289
292asmlinkage long sys_truncate(const char __user * path, unsigned long length) 290SYSCALL_DEFINE2(truncate, const char __user *, path, unsigned long, length)
293{ 291{
294 /* on 32-bit boxen it will cut the range 2^31--2^32-1 off */ 292 /* on 32-bit boxen it will cut the range 2^31--2^32-1 off */
295 return do_sys_truncate(path, (long)length); 293 return do_sys_truncate(path, (long)length);
@@ -341,7 +339,7 @@ out:
341 return error; 339 return error;
342} 340}
343 341
344asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length) 342SYSCALL_DEFINE2(ftruncate, unsigned int, fd, unsigned long, length)
345{ 343{
346 long ret = do_sys_ftruncate(fd, length, 1); 344 long ret = do_sys_ftruncate(fd, length, 1);
347 /* avoid REGPARM breakage on x86: */ 345 /* avoid REGPARM breakage on x86: */
@@ -351,21 +349,35 @@ asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length)
351 349
352/* LFS versions of truncate are only needed on 32 bit machines */ 350/* LFS versions of truncate are only needed on 32 bit machines */
353#if BITS_PER_LONG == 32 351#if BITS_PER_LONG == 32
354asmlinkage long sys_truncate64(const char __user * path, loff_t length) 352SYSCALL_DEFINE(truncate64)(const char __user * path, loff_t length)
355{ 353{
356 return do_sys_truncate(path, length); 354 return do_sys_truncate(path, length);
357} 355}
356#ifdef CONFIG_HAVE_SYSCALL_WRAPPERS
357asmlinkage long SyS_truncate64(long path, loff_t length)
358{
359 return SYSC_truncate64((const char __user *) path, length);
360}
361SYSCALL_ALIAS(sys_truncate64, SyS_truncate64);
362#endif
358 363
359asmlinkage long sys_ftruncate64(unsigned int fd, loff_t length) 364SYSCALL_DEFINE(ftruncate64)(unsigned int fd, loff_t length)
360{ 365{
361 long ret = do_sys_ftruncate(fd, length, 0); 366 long ret = do_sys_ftruncate(fd, length, 0);
362 /* avoid REGPARM breakage on x86: */ 367 /* avoid REGPARM breakage on x86: */
363 asmlinkage_protect(2, ret, fd, length); 368 asmlinkage_protect(2, ret, fd, length);
364 return ret; 369 return ret;
365} 370}
371#ifdef CONFIG_HAVE_SYSCALL_WRAPPERS
372asmlinkage long SyS_ftruncate64(long fd, loff_t length)
373{
374 return SYSC_ftruncate64((unsigned int) fd, length);
375}
376SYSCALL_ALIAS(sys_ftruncate64, SyS_ftruncate64);
366#endif 377#endif
378#endif /* BITS_PER_LONG == 32 */
367 379
368asmlinkage long sys_fallocate(int fd, int mode, loff_t offset, loff_t len) 380SYSCALL_DEFINE(fallocate)(int fd, int mode, loff_t offset, loff_t len)
369{ 381{
370 struct file *file; 382 struct file *file;
371 struct inode *inode; 383 struct inode *inode;
@@ -422,13 +434,20 @@ out_fput:
422out: 434out:
423 return ret; 435 return ret;
424} 436}
437#ifdef CONFIG_HAVE_SYSCALL_WRAPPERS
438asmlinkage long SyS_fallocate(long fd, long mode, loff_t offset, loff_t len)
439{
440 return SYSC_fallocate((int)fd, (int)mode, offset, len);
441}
442SYSCALL_ALIAS(sys_fallocate, SyS_fallocate);
443#endif
425 444
426/* 445/*
427 * access() needs to use the real uid/gid, not the effective uid/gid. 446 * access() needs to use the real uid/gid, not the effective uid/gid.
428 * We do this by temporarily clearing all FS-related capabilities and 447 * We do this by temporarily clearing all FS-related capabilities and
429 * switching the fsuid/fsgid around to the real ones. 448 * switching the fsuid/fsgid around to the real ones.
430 */ 449 */
431asmlinkage long sys_faccessat(int dfd, const char __user *filename, int mode) 450SYSCALL_DEFINE3(faccessat, int, dfd, const char __user *, filename, int, mode)
432{ 451{
433 const struct cred *old_cred; 452 const struct cred *old_cred;
434 struct cred *override_cred; 453 struct cred *override_cred;
@@ -498,12 +517,12 @@ out:
498 return res; 517 return res;
499} 518}
500 519
501asmlinkage long sys_access(const char __user *filename, int mode) 520SYSCALL_DEFINE2(access, const char __user *, filename, int, mode)
502{ 521{
503 return sys_faccessat(AT_FDCWD, filename, mode); 522 return sys_faccessat(AT_FDCWD, filename, mode);
504} 523}
505 524
506asmlinkage long sys_chdir(const char __user * filename) 525SYSCALL_DEFINE1(chdir, const char __user *, filename)
507{ 526{
508 struct path path; 527 struct path path;
509 int error; 528 int error;
@@ -524,7 +543,7 @@ out:
524 return error; 543 return error;
525} 544}
526 545
527asmlinkage long sys_fchdir(unsigned int fd) 546SYSCALL_DEFINE1(fchdir, unsigned int, fd)
528{ 547{
529 struct file *file; 548 struct file *file;
530 struct inode *inode; 549 struct inode *inode;
@@ -550,7 +569,7 @@ out:
550 return error; 569 return error;
551} 570}
552 571
553asmlinkage long sys_chroot(const char __user * filename) 572SYSCALL_DEFINE1(chroot, const char __user *, filename)
554{ 573{
555 struct path path; 574 struct path path;
556 int error; 575 int error;
@@ -575,7 +594,7 @@ out:
575 return error; 594 return error;
576} 595}
577 596
578asmlinkage long sys_fchmod(unsigned int fd, mode_t mode) 597SYSCALL_DEFINE2(fchmod, unsigned int, fd, mode_t, mode)
579{ 598{
580 struct inode * inode; 599 struct inode * inode;
581 struct dentry * dentry; 600 struct dentry * dentry;
@@ -609,8 +628,7 @@ out:
609 return err; 628 return err;
610} 629}
611 630
612asmlinkage long sys_fchmodat(int dfd, const char __user *filename, 631SYSCALL_DEFINE3(fchmodat, int, dfd, const char __user *, filename, mode_t, mode)
613 mode_t mode)
614{ 632{
615 struct path path; 633 struct path path;
616 struct inode *inode; 634 struct inode *inode;
@@ -639,7 +657,7 @@ out:
639 return error; 657 return error;
640} 658}
641 659
642asmlinkage long sys_chmod(const char __user *filename, mode_t mode) 660SYSCALL_DEFINE2(chmod, const char __user *, filename, mode_t, mode)
643{ 661{
644 return sys_fchmodat(AT_FDCWD, filename, mode); 662 return sys_fchmodat(AT_FDCWD, filename, mode);
645} 663}
@@ -669,7 +687,7 @@ static int chown_common(struct dentry * dentry, uid_t user, gid_t group)
669 return error; 687 return error;
670} 688}
671 689
672asmlinkage long sys_chown(const char __user * filename, uid_t user, gid_t group) 690SYSCALL_DEFINE3(chown, const char __user *, filename, uid_t, user, gid_t, group)
673{ 691{
674 struct path path; 692 struct path path;
675 int error; 693 int error;
@@ -688,8 +706,8 @@ out:
688 return error; 706 return error;
689} 707}
690 708
691asmlinkage long sys_fchownat(int dfd, const char __user *filename, uid_t user, 709SYSCALL_DEFINE5(fchownat, int, dfd, const char __user *, filename, uid_t, user,
692 gid_t group, int flag) 710 gid_t, group, int, flag)
693{ 711{
694 struct path path; 712 struct path path;
695 int error = -EINVAL; 713 int error = -EINVAL;
@@ -713,7 +731,7 @@ out:
713 return error; 731 return error;
714} 732}
715 733
716asmlinkage long sys_lchown(const char __user * filename, uid_t user, gid_t group) 734SYSCALL_DEFINE3(lchown, const char __user *, filename, uid_t, user, gid_t, group)
717{ 735{
718 struct path path; 736 struct path path;
719 int error; 737 int error;
@@ -732,8 +750,7 @@ out:
732 return error; 750 return error;
733} 751}
734 752
735 753SYSCALL_DEFINE3(fchown, unsigned int, fd, uid_t, user, gid_t, group)
736asmlinkage long sys_fchown(unsigned int fd, uid_t user, gid_t group)
737{ 754{
738 struct file * file; 755 struct file * file;
739 int error = -EBADF; 756 int error = -EBADF;
@@ -1029,7 +1046,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, int mode)
1029 return fd; 1046 return fd;
1030} 1047}
1031 1048
1032asmlinkage long sys_open(const char __user *filename, int flags, int mode) 1049SYSCALL_DEFINE3(open, const char __user *, filename, int, flags, int, mode)
1033{ 1050{
1034 long ret; 1051 long ret;
1035 1052
@@ -1042,8 +1059,8 @@ asmlinkage long sys_open(const char __user *filename, int flags, int mode)
1042 return ret; 1059 return ret;
1043} 1060}
1044 1061
1045asmlinkage long sys_openat(int dfd, const char __user *filename, int flags, 1062SYSCALL_DEFINE4(openat, int, dfd, const char __user *, filename, int, flags,
1046 int mode) 1063 int, mode)
1047{ 1064{
1048 long ret; 1065 long ret;
1049 1066
@@ -1062,7 +1079,7 @@ asmlinkage long sys_openat(int dfd, const char __user *filename, int flags,
1062 * For backward compatibility? Maybe this should be moved 1079 * For backward compatibility? Maybe this should be moved
1063 * into arch/i386 instead? 1080 * into arch/i386 instead?
1064 */ 1081 */
1065asmlinkage long sys_creat(const char __user * pathname, int mode) 1082SYSCALL_DEFINE2(creat, const char __user *, pathname, int, mode)
1066{ 1083{
1067 return sys_open(pathname, O_CREAT | O_WRONLY | O_TRUNC, mode); 1084 return sys_open(pathname, O_CREAT | O_WRONLY | O_TRUNC, mode);
1068} 1085}
@@ -1098,7 +1115,7 @@ EXPORT_SYMBOL(filp_close);
1098 * releasing the fd. This ensures that one clone task can't release 1115 * releasing the fd. This ensures that one clone task can't release
1099 * an fd while another clone is opening it. 1116 * an fd while another clone is opening it.
1100 */ 1117 */
1101asmlinkage long sys_close(unsigned int fd) 1118SYSCALL_DEFINE1(close, unsigned int, fd)
1102{ 1119{
1103 struct file * filp; 1120 struct file * filp;
1104 struct files_struct *files = current->files; 1121 struct files_struct *files = current->files;
@@ -1131,14 +1148,13 @@ out_unlock:
1131 spin_unlock(&files->file_lock); 1148 spin_unlock(&files->file_lock);
1132 return -EBADF; 1149 return -EBADF;
1133} 1150}
1134
1135EXPORT_SYMBOL(sys_close); 1151EXPORT_SYMBOL(sys_close);
1136 1152
1137/* 1153/*
1138 * This routine simulates a hangup on the tty, to arrange that users 1154 * This routine simulates a hangup on the tty, to arrange that users
1139 * are given clean terminals at login time. 1155 * are given clean terminals at login time.
1140 */ 1156 */
1141asmlinkage long sys_vhangup(void) 1157SYSCALL_DEFINE0(vhangup)
1142{ 1158{
1143 if (capable(CAP_SYS_TTY_CONFIG)) { 1159 if (capable(CAP_SYS_TTY_CONFIG)) {
1144 tty_vhangup_self(); 1160 tty_vhangup_self();