diff options
Diffstat (limited to 'fs/open.c')
-rw-r--r-- | fs/open.c | 89 |
1 files changed, 55 insertions, 34 deletions
@@ -122,7 +122,7 @@ static int vfs_statfs64(struct dentry *dentry, struct statfs64 *buf) | |||
122 | return 0; | 122 | return 0; |
123 | } | 123 | } |
124 | 124 | ||
125 | asmlinkage long sys_statfs(const char __user *pathname, struct statfs __user * buf) | 125 | SYSCALL_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 | 141 | SYSCALL_DEFINE3(statfs64, const char __user *, pathname, size_t, sz, struct statfs64 __user *, buf) | |
142 | asmlinkage 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 | 159 | SYSCALL_DEFINE2(fstatfs, unsigned int, fd, struct statfs __user *, buf) | |
161 | asmlinkage 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 | ||
179 | asmlinkage long sys_fstatfs64(unsigned int fd, size_t sz, struct statfs64 __user *buf) | 177 | SYSCALL_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; |
@@ -272,6 +270,8 @@ static long do_sys_truncate(const char __user *pathname, loff_t length) | |||
272 | goto put_write_and_out; | 270 | goto put_write_and_out; |
273 | 271 | ||
274 | error = locks_verify_truncate(inode, NULL, length); | 272 | error = locks_verify_truncate(inode, NULL, length); |
273 | if (!error) | ||
274 | error = security_path_truncate(&path, length, 0); | ||
275 | if (!error) { | 275 | if (!error) { |
276 | DQUOT_INIT(inode); | 276 | DQUOT_INIT(inode); |
277 | error = do_truncate(path.dentry, length, 0, NULL); | 277 | error = do_truncate(path.dentry, length, 0, NULL); |
@@ -287,7 +287,7 @@ out: | |||
287 | return error; | 287 | return error; |
288 | } | 288 | } |
289 | 289 | ||
290 | asmlinkage long sys_truncate(const char __user * path, unsigned long length) | 290 | SYSCALL_DEFINE2(truncate, const char __user *, path, unsigned long, length) |
291 | { | 291 | { |
292 | /* 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 */ |
293 | return do_sys_truncate(path, (long)length); | 293 | return do_sys_truncate(path, (long)length); |
@@ -329,6 +329,9 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small) | |||
329 | 329 | ||
330 | error = locks_verify_truncate(inode, file, length); | 330 | error = locks_verify_truncate(inode, file, length); |
331 | if (!error) | 331 | if (!error) |
332 | error = security_path_truncate(&file->f_path, length, | ||
333 | ATTR_MTIME|ATTR_CTIME); | ||
334 | if (!error) | ||
332 | error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file); | 335 | error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file); |
333 | out_putf: | 336 | out_putf: |
334 | fput(file); | 337 | fput(file); |
@@ -336,7 +339,7 @@ out: | |||
336 | return error; | 339 | return error; |
337 | } | 340 | } |
338 | 341 | ||
339 | asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length) | 342 | SYSCALL_DEFINE2(ftruncate, unsigned int, fd, unsigned long, length) |
340 | { | 343 | { |
341 | long ret = do_sys_ftruncate(fd, length, 1); | 344 | long ret = do_sys_ftruncate(fd, length, 1); |
342 | /* avoid REGPARM breakage on x86: */ | 345 | /* avoid REGPARM breakage on x86: */ |
@@ -346,21 +349,35 @@ asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length) | |||
346 | 349 | ||
347 | /* LFS versions of truncate are only needed on 32 bit machines */ | 350 | /* LFS versions of truncate are only needed on 32 bit machines */ |
348 | #if BITS_PER_LONG == 32 | 351 | #if BITS_PER_LONG == 32 |
349 | asmlinkage long sys_truncate64(const char __user * path, loff_t length) | 352 | SYSCALL_DEFINE(truncate64)(const char __user * path, loff_t length) |
350 | { | 353 | { |
351 | return do_sys_truncate(path, length); | 354 | return do_sys_truncate(path, length); |
352 | } | 355 | } |
356 | #ifdef CONFIG_HAVE_SYSCALL_WRAPPERS | ||
357 | asmlinkage long SyS_truncate64(long path, loff_t length) | ||
358 | { | ||
359 | return SYSC_truncate64((const char __user *) path, length); | ||
360 | } | ||
361 | SYSCALL_ALIAS(sys_truncate64, SyS_truncate64); | ||
362 | #endif | ||
353 | 363 | ||
354 | asmlinkage long sys_ftruncate64(unsigned int fd, loff_t length) | 364 | SYSCALL_DEFINE(ftruncate64)(unsigned int fd, loff_t length) |
355 | { | 365 | { |
356 | long ret = do_sys_ftruncate(fd, length, 0); | 366 | long ret = do_sys_ftruncate(fd, length, 0); |
357 | /* avoid REGPARM breakage on x86: */ | 367 | /* avoid REGPARM breakage on x86: */ |
358 | asmlinkage_protect(2, ret, fd, length); | 368 | asmlinkage_protect(2, ret, fd, length); |
359 | return ret; | 369 | return ret; |
360 | } | 370 | } |
371 | #ifdef CONFIG_HAVE_SYSCALL_WRAPPERS | ||
372 | asmlinkage long SyS_ftruncate64(long fd, loff_t length) | ||
373 | { | ||
374 | return SYSC_ftruncate64((unsigned int) fd, length); | ||
375 | } | ||
376 | SYSCALL_ALIAS(sys_ftruncate64, SyS_ftruncate64); | ||
361 | #endif | 377 | #endif |
378 | #endif /* BITS_PER_LONG == 32 */ | ||
362 | 379 | ||
363 | asmlinkage long sys_fallocate(int fd, int mode, loff_t offset, loff_t len) | 380 | SYSCALL_DEFINE(fallocate)(int fd, int mode, loff_t offset, loff_t len) |
364 | { | 381 | { |
365 | struct file *file; | 382 | struct file *file; |
366 | struct inode *inode; | 383 | struct inode *inode; |
@@ -407,7 +424,7 @@ asmlinkage long sys_fallocate(int fd, int mode, loff_t offset, loff_t len) | |||
407 | if (((offset + len) > inode->i_sb->s_maxbytes) || ((offset + len) < 0)) | 424 | if (((offset + len) > inode->i_sb->s_maxbytes) || ((offset + len) < 0)) |
408 | goto out_fput; | 425 | goto out_fput; |
409 | 426 | ||
410 | if (inode->i_op && inode->i_op->fallocate) | 427 | if (inode->i_op->fallocate) |
411 | ret = inode->i_op->fallocate(inode, mode, offset, len); | 428 | ret = inode->i_op->fallocate(inode, mode, offset, len); |
412 | else | 429 | else |
413 | ret = -EOPNOTSUPP; | 430 | ret = -EOPNOTSUPP; |
@@ -417,13 +434,20 @@ out_fput: | |||
417 | out: | 434 | out: |
418 | return ret; | 435 | return ret; |
419 | } | 436 | } |
437 | #ifdef CONFIG_HAVE_SYSCALL_WRAPPERS | ||
438 | asmlinkage 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 | } | ||
442 | SYSCALL_ALIAS(sys_fallocate, SyS_fallocate); | ||
443 | #endif | ||
420 | 444 | ||
421 | /* | 445 | /* |
422 | * 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. |
423 | * We do this by temporarily clearing all FS-related capabilities and | 447 | * We do this by temporarily clearing all FS-related capabilities and |
424 | * switching the fsuid/fsgid around to the real ones. | 448 | * switching the fsuid/fsgid around to the real ones. |
425 | */ | 449 | */ |
426 | asmlinkage long sys_faccessat(int dfd, const char __user *filename, int mode) | 450 | SYSCALL_DEFINE3(faccessat, int, dfd, const char __user *, filename, int, mode) |
427 | { | 451 | { |
428 | const struct cred *old_cred; | 452 | const struct cred *old_cred; |
429 | struct cred *override_cred; | 453 | struct cred *override_cred; |
@@ -493,12 +517,12 @@ out: | |||
493 | return res; | 517 | return res; |
494 | } | 518 | } |
495 | 519 | ||
496 | asmlinkage long sys_access(const char __user *filename, int mode) | 520 | SYSCALL_DEFINE2(access, const char __user *, filename, int, mode) |
497 | { | 521 | { |
498 | return sys_faccessat(AT_FDCWD, filename, mode); | 522 | return sys_faccessat(AT_FDCWD, filename, mode); |
499 | } | 523 | } |
500 | 524 | ||
501 | asmlinkage long sys_chdir(const char __user * filename) | 525 | SYSCALL_DEFINE1(chdir, const char __user *, filename) |
502 | { | 526 | { |
503 | struct path path; | 527 | struct path path; |
504 | int error; | 528 | int error; |
@@ -519,7 +543,7 @@ out: | |||
519 | return error; | 543 | return error; |
520 | } | 544 | } |
521 | 545 | ||
522 | asmlinkage long sys_fchdir(unsigned int fd) | 546 | SYSCALL_DEFINE1(fchdir, unsigned int, fd) |
523 | { | 547 | { |
524 | struct file *file; | 548 | struct file *file; |
525 | struct inode *inode; | 549 | struct inode *inode; |
@@ -545,7 +569,7 @@ out: | |||
545 | return error; | 569 | return error; |
546 | } | 570 | } |
547 | 571 | ||
548 | asmlinkage long sys_chroot(const char __user * filename) | 572 | SYSCALL_DEFINE1(chroot, const char __user *, filename) |
549 | { | 573 | { |
550 | struct path path; | 574 | struct path path; |
551 | int error; | 575 | int error; |
@@ -570,7 +594,7 @@ out: | |||
570 | return error; | 594 | return error; |
571 | } | 595 | } |
572 | 596 | ||
573 | asmlinkage long sys_fchmod(unsigned int fd, mode_t mode) | 597 | SYSCALL_DEFINE2(fchmod, unsigned int, fd, mode_t, mode) |
574 | { | 598 | { |
575 | struct inode * inode; | 599 | struct inode * inode; |
576 | struct dentry * dentry; | 600 | struct dentry * dentry; |
@@ -604,8 +628,7 @@ out: | |||
604 | return err; | 628 | return err; |
605 | } | 629 | } |
606 | 630 | ||
607 | asmlinkage long sys_fchmodat(int dfd, const char __user *filename, | 631 | SYSCALL_DEFINE3(fchmodat, int, dfd, const char __user *, filename, mode_t, mode) |
608 | mode_t mode) | ||
609 | { | 632 | { |
610 | struct path path; | 633 | struct path path; |
611 | struct inode *inode; | 634 | struct inode *inode; |
@@ -634,7 +657,7 @@ out: | |||
634 | return error; | 657 | return error; |
635 | } | 658 | } |
636 | 659 | ||
637 | asmlinkage long sys_chmod(const char __user *filename, mode_t mode) | 660 | SYSCALL_DEFINE2(chmod, const char __user *, filename, mode_t, mode) |
638 | { | 661 | { |
639 | return sys_fchmodat(AT_FDCWD, filename, mode); | 662 | return sys_fchmodat(AT_FDCWD, filename, mode); |
640 | } | 663 | } |
@@ -664,7 +687,7 @@ static int chown_common(struct dentry * dentry, uid_t user, gid_t group) | |||
664 | return error; | 687 | return error; |
665 | } | 688 | } |
666 | 689 | ||
667 | asmlinkage long sys_chown(const char __user * filename, uid_t user, gid_t group) | 690 | SYSCALL_DEFINE3(chown, const char __user *, filename, uid_t, user, gid_t, group) |
668 | { | 691 | { |
669 | struct path path; | 692 | struct path path; |
670 | int error; | 693 | int error; |
@@ -683,8 +706,8 @@ out: | |||
683 | return error; | 706 | return error; |
684 | } | 707 | } |
685 | 708 | ||
686 | asmlinkage long sys_fchownat(int dfd, const char __user *filename, uid_t user, | 709 | SYSCALL_DEFINE5(fchownat, int, dfd, const char __user *, filename, uid_t, user, |
687 | gid_t group, int flag) | 710 | gid_t, group, int, flag) |
688 | { | 711 | { |
689 | struct path path; | 712 | struct path path; |
690 | int error = -EINVAL; | 713 | int error = -EINVAL; |
@@ -708,7 +731,7 @@ out: | |||
708 | return error; | 731 | return error; |
709 | } | 732 | } |
710 | 733 | ||
711 | asmlinkage long sys_lchown(const char __user * filename, uid_t user, gid_t group) | 734 | SYSCALL_DEFINE3(lchown, const char __user *, filename, uid_t, user, gid_t, group) |
712 | { | 735 | { |
713 | struct path path; | 736 | struct path path; |
714 | int error; | 737 | int error; |
@@ -727,8 +750,7 @@ out: | |||
727 | return error; | 750 | return error; |
728 | } | 751 | } |
729 | 752 | ||
730 | 753 | SYSCALL_DEFINE3(fchown, unsigned int, fd, uid_t, user, gid_t, group) | |
731 | asmlinkage long sys_fchown(unsigned int fd, uid_t user, gid_t group) | ||
732 | { | 754 | { |
733 | struct file * file; | 755 | struct file * file; |
734 | int error = -EBADF; | 756 | int error = -EBADF; |
@@ -1024,7 +1046,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, int mode) | |||
1024 | return fd; | 1046 | return fd; |
1025 | } | 1047 | } |
1026 | 1048 | ||
1027 | asmlinkage long sys_open(const char __user *filename, int flags, int mode) | 1049 | SYSCALL_DEFINE3(open, const char __user *, filename, int, flags, int, mode) |
1028 | { | 1050 | { |
1029 | long ret; | 1051 | long ret; |
1030 | 1052 | ||
@@ -1037,8 +1059,8 @@ asmlinkage long sys_open(const char __user *filename, int flags, int mode) | |||
1037 | return ret; | 1059 | return ret; |
1038 | } | 1060 | } |
1039 | 1061 | ||
1040 | asmlinkage long sys_openat(int dfd, const char __user *filename, int flags, | 1062 | SYSCALL_DEFINE4(openat, int, dfd, const char __user *, filename, int, flags, |
1041 | int mode) | 1063 | int, mode) |
1042 | { | 1064 | { |
1043 | long ret; | 1065 | long ret; |
1044 | 1066 | ||
@@ -1057,7 +1079,7 @@ asmlinkage long sys_openat(int dfd, const char __user *filename, int flags, | |||
1057 | * For backward compatibility? Maybe this should be moved | 1079 | * For backward compatibility? Maybe this should be moved |
1058 | * into arch/i386 instead? | 1080 | * into arch/i386 instead? |
1059 | */ | 1081 | */ |
1060 | asmlinkage long sys_creat(const char __user * pathname, int mode) | 1082 | SYSCALL_DEFINE2(creat, const char __user *, pathname, int, mode) |
1061 | { | 1083 | { |
1062 | return sys_open(pathname, O_CREAT | O_WRONLY | O_TRUNC, mode); | 1084 | return sys_open(pathname, O_CREAT | O_WRONLY | O_TRUNC, mode); |
1063 | } | 1085 | } |
@@ -1093,7 +1115,7 @@ EXPORT_SYMBOL(filp_close); | |||
1093 | * 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 |
1094 | * an fd while another clone is opening it. | 1116 | * an fd while another clone is opening it. |
1095 | */ | 1117 | */ |
1096 | asmlinkage long sys_close(unsigned int fd) | 1118 | SYSCALL_DEFINE1(close, unsigned int, fd) |
1097 | { | 1119 | { |
1098 | struct file * filp; | 1120 | struct file * filp; |
1099 | struct files_struct *files = current->files; | 1121 | struct files_struct *files = current->files; |
@@ -1126,14 +1148,13 @@ out_unlock: | |||
1126 | spin_unlock(&files->file_lock); | 1148 | spin_unlock(&files->file_lock); |
1127 | return -EBADF; | 1149 | return -EBADF; |
1128 | } | 1150 | } |
1129 | |||
1130 | EXPORT_SYMBOL(sys_close); | 1151 | EXPORT_SYMBOL(sys_close); |
1131 | 1152 | ||
1132 | /* | 1153 | /* |
1133 | * 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 |
1134 | * are given clean terminals at login time. | 1155 | * are given clean terminals at login time. |
1135 | */ | 1156 | */ |
1136 | asmlinkage long sys_vhangup(void) | 1157 | SYSCALL_DEFINE0(vhangup) |
1137 | { | 1158 | { |
1138 | if (capable(CAP_SYS_TTY_CONFIG)) { | 1159 | if (capable(CAP_SYS_TTY_CONFIG)) { |
1139 | tty_vhangup_self(); | 1160 | tty_vhangup_self(); |