4 * This code is issued under the GNU General Public License.
5 * See the file COPYING in this distribution
7 * Copyright (C) 1992, 1993, 1994, 1995
8 * Remy Card (card@masi.ibp.fr)
9 * Laboratoire MASI - Institut Blaise Pascal
10 * Universite Pierre et Marie Curie (Paris VI)
14 * linux/fs/minix/file.c
16 * Copyright (C) 1991, 1992 Linus Torvalds
18 * ext2 fs regular file handling primitives
20 * 64-bit file support on 64-bit platforms by Jakub Jelinek
21 * (jj@sunsite.ms.mff.cuni.cz)
24 #include <asm/uaccess.h>
25 #include <asm/system.h>
27 #include <linux/errno.h>
29 #include <linux/fcntl.h>
30 #include <linux/sched.h>
31 #include <linux/stat.h>
32 #include <linux/locks.h>
34 #include <linux/pagemap.h>
35 #include <linux/smp_lock.h>
37 #define DEBUG_SUBSYSTEM S_OBDFS
39 #include <linux/obd_support.h>
40 #include <linux/obdfs.h>
42 extern int obdfs_setattr(struct dentry *de, struct iattr *attr);
43 void obdfs_change_inode(struct inode *inode);
45 static inline void obdfs_remove_suid(struct inode *inode)
49 /* set S_IGID if S_IXGRP is set, and always set S_ISUID */
50 mode = (inode->i_mode & S_IXGRP)*(S_ISGID/S_IXGRP) | S_ISUID;
52 /* was any of the uid bits set? */
53 mode &= inode->i_mode;
54 if (mode && !capable(CAP_FSETID)) {
55 inode->i_mode &= ~mode;
56 // XXX careful here - we cannot change the size
57 //obdfs_change_inode(inode);
62 * Write to a file (through the page cache).
65 obdfs_file_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
68 CDEBUG(D_INFO, "Writing inode %ld, %ld bytes, offset %Ld\n",
69 file->f_dentry->d_inode->i_ino, (long)count, *ppos);
71 retval = generic_file_write(file, buf, count, ppos);
72 CDEBUG(D_INFO, "Wrote %ld\n", (long)retval);
74 /* update mtime/ctime/atime here, NOT size */
77 attr.ia_valid = ATTR_MTIME | ATTR_CTIME | ATTR_ATIME;
78 attr.ia_mtime = attr.ia_ctime = attr.ia_atime =
80 obdfs_setattr(file->f_dentry, &attr);
87 /* XXX this does not need to do anything for data, it _does_ need to
89 int obdfs_fsync(struct file *file, struct dentry *dentry, int data)
94 struct file_operations obdfs_file_operations = {
95 read: generic_file_read,
96 write: obdfs_file_write,
97 mmap: generic_file_mmap,
102 struct inode_operations obdfs_file_inode_operations = {
103 truncate: obdfs_truncate,
104 setattr: obdfs_setattr