4 * Copyright (C) 1991, 1992 Linus Torvalds
7 #include <linux/string.h>
9 #include <linux/file.h>
10 #include <linux/smp_lock.h>
11 #include <linux/quotaops.h>
12 #include <linux/fsnotify.h>
13 #include <linux/module.h>
14 #include <linux/slab.h>
15 #include <linux/tty.h>
16 #include <linux/namei.h>
17 #include <linux/backing-dev.h>
18 #include <linux/capability.h>
19 #include <linux/security.h>
20 #include <linux/mount.h>
21 #include <linux/vfs.h>
22 #include <linux/fcntl.h>
23 #include <asm/uaccess.h>
25 #include <linux/personality.h>
26 #include <linux/pagemap.h>
27 #include <linux/syscalls.h>
28 #include <linux/rcupdate.h>
29 #include <linux/audit.h>
30 #include <linux/vs_base.h>
31 #include <linux/vs_limit.h>
32 #include <linux/vs_dlimit.h>
33 #include <linux/vs_tag.h>
34 #include <linux/vs_cowbl.h>
36 int vfs_statfs(struct dentry *dentry, struct kstatfs *buf)
41 struct super_block *sb = dentry->d_sb;
44 if (sb->s_op->statfs) {
45 memset(buf, 0, sizeof(*buf));
46 retval = security_sb_statfs(dentry);
49 retval = sb->s_op->statfs(dentry, buf);
50 if (retval == 0 && buf->f_frsize == 0)
51 buf->f_frsize = buf->f_bsize;
53 if (!vx_check(0, VS_ADMIN|VS_WATCH))
54 vx_vsi_statfs(sb, buf);
59 EXPORT_SYMBOL(vfs_statfs);
61 static int vfs_statfs_native(struct dentry *dentry, struct statfs *buf)
66 retval = vfs_statfs(dentry, &st);
70 if (sizeof(*buf) == sizeof(st))
71 memcpy(buf, &st, sizeof(st));
73 if (sizeof buf->f_blocks == 4) {
74 if ((st.f_blocks | st.f_bfree | st.f_bavail) &
75 0xffffffff00000000ULL)
78 * f_files and f_ffree may be -1; it's okay to stuff
81 if (st.f_files != -1 &&
82 (st.f_files & 0xffffffff00000000ULL))
84 if (st.f_ffree != -1 &&
85 (st.f_ffree & 0xffffffff00000000ULL))
89 buf->f_type = st.f_type;
90 buf->f_bsize = st.f_bsize;
91 buf->f_blocks = st.f_blocks;
92 buf->f_bfree = st.f_bfree;
93 buf->f_bavail = st.f_bavail;
94 buf->f_files = st.f_files;
95 buf->f_ffree = st.f_ffree;
96 buf->f_fsid = st.f_fsid;
97 buf->f_namelen = st.f_namelen;
98 buf->f_frsize = st.f_frsize;
99 memset(buf->f_spare, 0, sizeof(buf->f_spare));
104 static int vfs_statfs64(struct dentry *dentry, struct statfs64 *buf)
109 retval = vfs_statfs(dentry, &st);
113 if (sizeof(*buf) == sizeof(st))
114 memcpy(buf, &st, sizeof(st));
116 buf->f_type = st.f_type;
117 buf->f_bsize = st.f_bsize;
118 buf->f_blocks = st.f_blocks;
119 buf->f_bfree = st.f_bfree;
120 buf->f_bavail = st.f_bavail;
121 buf->f_files = st.f_files;
122 buf->f_ffree = st.f_ffree;
123 buf->f_fsid = st.f_fsid;
124 buf->f_namelen = st.f_namelen;
125 buf->f_frsize = st.f_frsize;
126 memset(buf->f_spare, 0, sizeof(buf->f_spare));
131 asmlinkage long sys_statfs(const char __user * path, struct statfs __user * buf)
136 error = user_path_walk(path, &nd);
139 error = vfs_statfs_native(nd.dentry, &tmp);
140 if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
148 asmlinkage long sys_statfs64(const char __user *path, size_t sz, struct statfs64 __user *buf)
153 if (sz != sizeof(*buf))
155 error = user_path_walk(path, &nd);
158 error = vfs_statfs64(nd.dentry, &tmp);
159 if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
167 asmlinkage long sys_fstatfs(unsigned int fd, struct statfs __user * buf)
177 error = vfs_statfs_native(file->f_path.dentry, &tmp);
178 if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
185 asmlinkage long sys_fstatfs64(unsigned int fd, size_t sz, struct statfs64 __user *buf)
191 if (sz != sizeof(*buf))
198 error = vfs_statfs64(file->f_path.dentry, &tmp);
199 if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
206 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
210 struct iattr newattrs;
212 /* Not pretty: "inode->i_size" shouldn't really be signed. But it is. */
216 newattrs.ia_size = length;
217 newattrs.ia_valid = ATTR_SIZE | time_attrs;
219 newattrs.ia_file = filp;
220 newattrs.ia_valid |= ATTR_FILE;
223 mutex_lock(&dentry->d_inode->i_mutex);
224 err = notify_change(dentry, &newattrs);
225 mutex_unlock(&dentry->d_inode->i_mutex);
229 static long do_sys_truncate(const char __user * path, loff_t length)
232 struct inode * inode;
236 if (length < 0) /* sorry, but loff_t says... */
239 error = user_path_walk(path, &nd);
242 inode = nd.dentry->d_inode;
244 /* For directories it's -EISDIR, for other non-regulars - -EINVAL */
246 if (S_ISDIR(inode->i_mode))
250 if (!S_ISREG(inode->i_mode))
253 error = vfs_permission(&nd, MAY_WRITE);
258 if (IS_RDONLY(inode) || MNT_IS_RDONLY(nd.mnt))
262 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
266 * Make sure that there are no leases.
268 error = break_lease(inode, FMODE_WRITE);
272 error = get_write_access(inode);
276 error = locks_verify_truncate(inode, NULL, length);
279 error = do_truncate(nd.dentry, length, 0, NULL);
281 put_write_access(inode);
289 asmlinkage long sys_truncate(const char __user * path, unsigned long length)
291 /* on 32-bit boxen it will cut the range 2^31--2^32-1 off */
292 return do_sys_truncate(path, (long)length);
295 static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
297 struct inode * inode;
298 struct dentry *dentry;
310 /* explicitly opened as large or we are on 64-bit box */
311 if (file->f_flags & O_LARGEFILE)
314 dentry = file->f_path.dentry;
315 inode = dentry->d_inode;
317 if (!S_ISREG(inode->i_mode) || !(file->f_mode & FMODE_WRITE))
321 /* Cannot ftruncate over 2^31 bytes without large file support */
322 if (small && length > MAX_NON_LFS)
326 if (IS_APPEND(inode))
329 error = locks_verify_truncate(inode, file, length);
331 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file);
338 asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length)
340 long ret = do_sys_ftruncate(fd, length, 1);
341 /* avoid REGPARM breakage on x86: */
342 prevent_tail_call(ret);
346 /* LFS versions of truncate are only needed on 32 bit machines */
347 #if BITS_PER_LONG == 32
348 asmlinkage long sys_truncate64(const char __user * path, loff_t length)
350 return do_sys_truncate(path, length);
353 asmlinkage long sys_ftruncate64(unsigned int fd, loff_t length)
355 long ret = do_sys_ftruncate(fd, length, 0);
356 /* avoid REGPARM breakage on x86: */
357 prevent_tail_call(ret);
363 * access() needs to use the real uid/gid, not the effective uid/gid.
364 * We do this by temporarily clearing all FS-related capabilities and
365 * switching the fsuid/fsgid around to the real ones.
367 asmlinkage long sys_faccessat(int dfd, const char __user *filename, int mode)
370 int old_fsuid, old_fsgid;
371 kernel_cap_t old_cap;
374 if (mode & ~S_IRWXO) /* where's F_OK, X_OK, W_OK, R_OK? */
377 old_fsuid = current->fsuid;
378 old_fsgid = current->fsgid;
379 old_cap = current->cap_effective;
381 current->fsuid = current->uid;
382 current->fsgid = current->gid;
385 * Clear the capabilities if we switch to a non-root user
387 * FIXME: There is a race here against sys_capset. The
388 * capabilities can change yet we will restore the old
389 * value below. We should hold task_capabilities_lock,
390 * but we cannot because user_path_walk can sleep.
393 cap_clear(current->cap_effective);
395 current->cap_effective = current->cap_permitted;
397 res = __user_walk_fd(dfd, filename, LOOKUP_FOLLOW|LOOKUP_ACCESS, &nd);
401 res = vfs_permission(&nd, mode);
402 /* SuS v2 requires we report a read only fs too */
403 if(res || !(mode & S_IWOTH) ||
404 special_file(nd.dentry->d_inode->i_mode))
405 goto out_path_release;
407 if(IS_RDONLY(nd.dentry->d_inode) || MNT_IS_RDONLY(nd.mnt))
413 current->fsuid = old_fsuid;
414 current->fsgid = old_fsgid;
415 current->cap_effective = old_cap;
420 asmlinkage long sys_access(const char __user *filename, int mode)
422 return sys_faccessat(AT_FDCWD, filename, mode);
425 asmlinkage long sys_chdir(const char __user * filename)
430 error = __user_walk(filename,
431 LOOKUP_FOLLOW|LOOKUP_DIRECTORY|LOOKUP_CHDIR, &nd);
435 error = vfs_permission(&nd, MAY_EXEC);
439 set_fs_pwd(current->fs, nd.mnt, nd.dentry);
447 asmlinkage long sys_fchdir(unsigned int fd)
450 struct dentry *dentry;
452 struct vfsmount *mnt;
460 dentry = file->f_path.dentry;
461 mnt = file->f_path.mnt;
462 inode = dentry->d_inode;
465 if (!S_ISDIR(inode->i_mode))
468 error = file_permission(file, MAY_EXEC);
470 set_fs_pwd(current->fs, mnt, dentry);
477 asmlinkage long sys_chroot(const char __user * filename)
482 error = __user_walk(filename, LOOKUP_FOLLOW | LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
486 error = vfs_permission(&nd, MAY_EXEC);
491 if (!capable(CAP_SYS_CHROOT))
494 set_fs_root(current->fs, nd.mnt, nd.dentry);
503 asmlinkage long sys_fchmod(unsigned int fd, mode_t mode)
505 struct inode * inode;
506 struct dentry * dentry;
509 struct iattr newattrs;
515 dentry = file->f_path.dentry;
516 inode = dentry->d_inode;
518 audit_inode(NULL, inode);
521 if (IS_RDONLY(inode) || MNT_IS_RDONLY(file->f_vfsmnt))
524 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
526 mutex_lock(&inode->i_mutex);
527 if (mode == (mode_t) -1)
528 mode = inode->i_mode;
529 newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
530 newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
531 err = notify_change(dentry, &newattrs);
532 mutex_unlock(&inode->i_mutex);
540 asmlinkage long sys_fchmodat(int dfd, const char __user *filename,
544 struct inode * inode;
546 struct iattr newattrs;
548 error = __user_walk_fd(dfd, filename, LOOKUP_FOLLOW, &nd);
552 error = cow_check_and_break(&nd);
555 inode = nd.dentry->d_inode;
558 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
561 mutex_lock(&inode->i_mutex);
562 if (mode == (mode_t) -1)
563 mode = inode->i_mode;
564 newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
565 newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
566 error = notify_change(nd.dentry, &newattrs);
567 mutex_unlock(&inode->i_mutex);
575 asmlinkage long sys_chmod(const char __user *filename, mode_t mode)
577 return sys_fchmodat(AT_FDCWD, filename, mode);
580 static int chown_common(struct dentry *dentry, struct vfsmount *mnt,
581 uid_t user, gid_t group)
583 struct inode * inode;
585 struct iattr newattrs;
588 if (!(inode = dentry->d_inode)) {
589 printk(KERN_ERR "chown_common: NULL inode\n");
593 if (IS_RDONLY(inode) || MNT_IS_RDONLY(mnt))
596 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
598 newattrs.ia_valid = ATTR_CTIME;
599 if (user != (uid_t) -1) {
600 newattrs.ia_valid |= ATTR_UID;
601 newattrs.ia_uid = dx_map_uid(user);
603 if (group != (gid_t) -1) {
604 newattrs.ia_valid |= ATTR_GID;
605 newattrs.ia_gid = dx_map_gid(group);
607 if (!S_ISDIR(inode->i_mode))
608 newattrs.ia_valid |= ATTR_KILL_SUID|ATTR_KILL_SGID;
609 mutex_lock(&inode->i_mutex);
610 error = notify_change(dentry, &newattrs);
611 mutex_unlock(&inode->i_mutex);
616 asmlinkage long sys_chown(const char __user * filename, uid_t user, gid_t group)
621 error = user_path_walk(filename, &nd);
624 #ifdef CONFIG_VSERVER_COWBL
625 error = cow_check_and_break(&nd);
628 error = chown_common(nd.dentry, nd.mnt, user, group);
634 asmlinkage long sys_fchownat(int dfd, const char __user *filename, uid_t user,
635 gid_t group, int flag)
641 if ((flag & ~AT_SYMLINK_NOFOLLOW) != 0)
644 follow = (flag & AT_SYMLINK_NOFOLLOW) ? 0 : LOOKUP_FOLLOW;
645 error = __user_walk_fd(dfd, filename, follow, &nd);
648 #ifdef CONFIG_VSERVER_COWBL
649 error = cow_check_and_break(&nd);
652 error = chown_common(nd.dentry, nd.mnt, user, group);
658 asmlinkage long sys_lchown(const char __user * filename, uid_t user, gid_t group)
663 error = user_path_walk_link(filename, &nd);
666 #ifdef CONFIG_VSERVER_COWBL
667 error = cow_check_and_break(&nd);
670 error = chown_common(nd.dentry, nd.mnt, user, group);
677 asmlinkage long sys_fchown(unsigned int fd, uid_t user, gid_t group)
681 struct dentry * dentry;
687 dentry = file->f_path.dentry;
688 audit_inode(NULL, dentry->d_inode);
689 error = chown_common(dentry, file->f_vfsmnt, user, group);
695 static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt,
696 int flags, struct file *f,
697 int (*open)(struct inode *, struct file *))
703 f->f_mode = ((flags+1) & O_ACCMODE) | FMODE_LSEEK |
704 FMODE_PREAD | FMODE_PWRITE;
705 inode = dentry->d_inode;
706 if (f->f_mode & FMODE_WRITE) {
707 error = get_write_access(inode);
712 f->f_mapping = inode->i_mapping;
713 f->f_path.dentry = dentry;
716 f->f_op = fops_get(inode->i_fop);
717 file_move(f, &inode->i_sb->s_files);
719 if (!open && f->f_op)
720 open = f->f_op->open;
722 error = open(inode, f);
727 f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
729 file_ra_state_init(&f->f_ra, f->f_mapping->host->i_mapping);
731 /* NB: we're sure to have correct a_ops only after f_op->open */
732 if (f->f_flags & O_DIRECT) {
733 if (!f->f_mapping->a_ops ||
734 ((!f->f_mapping->a_ops->direct_IO) &&
735 (!f->f_mapping->a_ops->get_xip_page))) {
737 f = ERR_PTR(-EINVAL);
745 if (f->f_mode & FMODE_WRITE)
746 put_write_access(inode);
748 f->f_path.dentry = NULL;
749 f->f_path.mnt = NULL;
754 return ERR_PTR(error);
758 * Note that while the flag value (low two bits) for sys_open means:
764 * 00 - no permissions needed
765 * 01 - read-permission
766 * 10 - write-permission
768 * for the internal routines (ie open_namei()/follow_link() etc). 00 is
771 static struct file *do_filp_open(int dfd, const char *filename, int flags,
774 int namei_flags, error;
778 if ((namei_flags+1) & O_ACCMODE)
781 error = open_namei(dfd, filename, namei_flags, mode, &nd);
783 return nameidata_to_filp(&nd, flags);
785 return ERR_PTR(error);
788 struct file *filp_open(const char *filename, int flags, int mode)
790 return do_filp_open(AT_FDCWD, filename, flags, mode);
792 EXPORT_SYMBOL(filp_open);
795 * lookup_instantiate_filp - instantiates the open intent filp
796 * @nd: pointer to nameidata
797 * @dentry: pointer to dentry
798 * @open: open callback
800 * Helper for filesystems that want to use lookup open intents and pass back
801 * a fully instantiated struct file to the caller.
802 * This function is meant to be called from within a filesystem's
804 * Beware of calling it for non-regular files! Those ->open methods might block
805 * (e.g. in fifo_open), leaving you with parent locked (and in case of fifo,
806 * leading to a deadlock, as nobody can open that fifo anymore, because
807 * another process to open fifo will block on locked parent when doing lookup).
808 * Note that in case of error, nd->intent.open.file is destroyed, but the
809 * path information remains valid.
810 * If the open callback is set to NULL, then the standard f_op->open()
811 * filesystem callback is substituted.
813 struct file *lookup_instantiate_filp(struct nameidata *nd, struct dentry *dentry,
814 int (*open)(struct inode *, struct file *))
816 if (IS_ERR(nd->intent.open.file))
820 nd->intent.open.file = __dentry_open(dget(dentry), mntget(nd->mnt),
821 nd->intent.open.flags - 1,
822 nd->intent.open.file,
825 return nd->intent.open.file;
827 release_open_intent(nd);
828 nd->intent.open.file = (struct file *)dentry;
831 EXPORT_SYMBOL_GPL(lookup_instantiate_filp);
834 * nameidata_to_filp - convert a nameidata to an open filp.
835 * @nd: pointer to nameidata
838 * Note that this function destroys the original nameidata
840 struct file *nameidata_to_filp(struct nameidata *nd, int flags)
844 /* Pick up the filp from the open intent */
845 filp = nd->intent.open.file;
846 /* Has the filesystem initialised the file for us? */
847 if (filp->f_path.dentry == NULL)
848 filp = __dentry_open(nd->dentry, nd->mnt, flags, filp, NULL);
855 * dentry_open() will have done dput(dentry) and mntput(mnt) if it returns an
858 struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
864 f = get_empty_filp();
868 return ERR_PTR(error);
871 return __dentry_open(dentry, mnt, flags, f, NULL);
873 EXPORT_SYMBOL(dentry_open);
876 * Find an empty file descriptor entry, and mark it busy.
878 int get_unused_fd(void)
880 struct files_struct * files = current->files;
885 spin_lock(&files->file_lock);
888 fdt = files_fdtable(files);
889 fd = find_next_zero_bit(fdt->open_fds->fds_bits, fdt->max_fds,
893 * N.B. For clone tasks sharing a files structure, this test
894 * will limit the total number of files that can be opened.
896 if (fd >= current->signal->rlim[RLIMIT_NOFILE].rlim_cur)
899 /* Do we need to expand the fd array or fd set? */
900 error = expand_files(files, fd);
906 * If we needed to expand the fs array we
907 * might have blocked - try again.
913 FD_SET(fd, fdt->open_fds);
914 FD_CLR(fd, fdt->close_on_exec);
915 files->next_fd = fd + 1;
919 if (fdt->fd[fd] != NULL) {
920 printk(KERN_WARNING "get_unused_fd: slot %d not NULL!\n", fd);
927 spin_unlock(&files->file_lock);
931 EXPORT_SYMBOL(get_unused_fd);
933 static void __put_unused_fd(struct files_struct *files, unsigned int fd)
935 struct fdtable *fdt = files_fdtable(files);
936 __FD_CLR(fd, fdt->open_fds);
937 if (fd < files->next_fd)
942 void fastcall put_unused_fd(unsigned int fd)
944 struct files_struct *files = current->files;
945 spin_lock(&files->file_lock);
946 __put_unused_fd(files, fd);
947 spin_unlock(&files->file_lock);
950 EXPORT_SYMBOL(put_unused_fd);
953 * Install a file pointer in the fd array.
955 * The VFS is full of places where we drop the files lock between
956 * setting the open_fds bitmap and installing the file in the file
957 * array. At any such point, we are vulnerable to a dup2() race
958 * installing a file in the array before us. We need to detect this and
959 * fput() the struct file we are about to overwrite in this case.
961 * It should never happen - if we allow dup2() do it, _really_ bad things
965 void fastcall fd_install(unsigned int fd, struct file * file)
967 struct files_struct *files = current->files;
969 spin_lock(&files->file_lock);
970 fdt = files_fdtable(files);
971 BUG_ON(fdt->fd[fd] != NULL);
972 rcu_assign_pointer(fdt->fd[fd], file);
973 spin_unlock(&files->file_lock);
976 EXPORT_SYMBOL(fd_install);
978 long do_sys_open(int dfd, const char __user *filename, int flags, int mode)
980 char *tmp = getname(filename);
981 int fd = PTR_ERR(tmp);
984 fd = get_unused_fd();
986 struct file *f = do_filp_open(dfd, tmp, flags, mode);
991 fsnotify_open(f->f_path.dentry);
1000 asmlinkage long sys_open(const char __user *filename, int flags, int mode)
1004 if (force_o_largefile())
1005 flags |= O_LARGEFILE;
1007 ret = do_sys_open(AT_FDCWD, filename, flags, mode);
1008 /* avoid REGPARM breakage on x86: */
1009 prevent_tail_call(ret);
1013 asmlinkage long sys_openat(int dfd, const char __user *filename, int flags,
1018 if (force_o_largefile())
1019 flags |= O_LARGEFILE;
1021 ret = do_sys_open(dfd, filename, flags, mode);
1022 /* avoid REGPARM breakage on x86: */
1023 prevent_tail_call(ret);
1030 * For backward compatibility? Maybe this should be moved
1031 * into arch/i386 instead?
1033 asmlinkage long sys_creat(const char __user * pathname, int mode)
1035 return sys_open(pathname, O_CREAT | O_WRONLY | O_TRUNC, mode);
1041 * "id" is the POSIX thread ID. We use the
1042 * files pointer for this..
1044 int filp_close(struct file *filp, fl_owner_t id)
1048 if (!file_count(filp)) {
1049 printk(KERN_ERR "VFS: Close: file count is 0\n");
1053 if (filp->f_op && filp->f_op->flush)
1054 retval = filp->f_op->flush(filp, id);
1056 dnotify_flush(filp, id);
1057 locks_remove_posix(filp, id);
1062 EXPORT_SYMBOL(filp_close);
1065 * Careful here! We test whether the file pointer is NULL before
1066 * releasing the fd. This ensures that one clone task can't release
1067 * an fd while another clone is opening it.
1069 asmlinkage long sys_close(unsigned int fd)
1072 struct files_struct *files = current->files;
1073 struct fdtable *fdt;
1076 spin_lock(&files->file_lock);
1077 fdt = files_fdtable(files);
1078 if (fd >= fdt->max_fds)
1083 rcu_assign_pointer(fdt->fd[fd], NULL);
1084 FD_CLR(fd, fdt->close_on_exec);
1085 __put_unused_fd(files, fd);
1086 spin_unlock(&files->file_lock);
1087 retval = filp_close(filp, files);
1089 /* can't restart close syscall because file table entry was cleared */
1090 if (unlikely(retval == -ERESTARTSYS ||
1091 retval == -ERESTARTNOINTR ||
1092 retval == -ERESTARTNOHAND ||
1093 retval == -ERESTART_RESTARTBLOCK))
1099 spin_unlock(&files->file_lock);
1103 EXPORT_SYMBOL(sys_close);
1106 * This routine simulates a hangup on the tty, to arrange that users
1107 * are given clean terminals at login time.
1109 asmlinkage long sys_vhangup(void)
1111 if (capable(CAP_SYS_TTY_CONFIG)) {
1112 /* XXX: this needs locking */
1113 tty_vhangup(current->signal->tty);
1120 * Called when an inode is about to be open.
1121 * We use this to disallow opening large files on 32bit systems if
1122 * the caller didn't specify O_LARGEFILE. On 64bit systems we force
1123 * on this flag in sys_open.
1125 int generic_file_open(struct inode * inode, struct file * filp)
1127 if (!(filp->f_flags & O_LARGEFILE) && i_size_read(inode) > MAX_NON_LFS)
1132 EXPORT_SYMBOL(generic_file_open);
1135 * This is used by subsystems that don't want seekable
1138 int nonseekable_open(struct inode *inode, struct file *filp)
1140 filp->f_mode &= ~(FMODE_LSEEK | FMODE_PREAD | FMODE_PWRITE);
1144 EXPORT_SYMBOL(nonseekable_open);