⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 file.c

📁 jfs-2.4-1.1.7.tar.gz jfs 2.4-1.1.7 源码
💻 C
字号:
/* *   Copyright (c) International Business Machines Corp., 2000-2002 *   Portions Copyright (c) Christoph Hellwig, 2001-2002 * *   This program is free software;  you can redistribute it and/or modify *   it under the terms of the GNU General Public License as published by *   the Free Software Foundation; either version 2 of the License, or  *   (at your option) any later version. *  *   This program is distributed in the hope that it will be useful, *   but WITHOUT ANY WARRANTY;  without even the implied warranty of *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See *   the GNU General Public License for more details. * *   You should have received a copy of the GNU General Public License *   along with this program;  if not, write to the Free Software  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */#include <linux/fs.h>#include "jfs_incore.h"#include "jfs_dmap.h"#include "jfs_txnmgr.h"#include "jfs_xattr.h"#include "jfs_debug.h"extern int jfs_commit_inode(struct inode *, int);extern void jfs_truncate(struct inode *);int jfs_fsync(struct file *file, struct dentry *dentry, int datasync){	struct inode *inode = dentry->d_inode;	int rc = 0;	/* No need to resync the data at commit time, unless this flag gets	 * set again */	clear_cflag(COMMIT_Syncdata, inode);	rc = fsync_inode_data_buffers(inode);	if (!(inode->i_state & I_DIRTY) ||	    (datasync && !(inode->i_state & I_DIRTY_DATASYNC))) {		/* Make sure committed changes hit the disk */		jfs_flush_journal(JFS_SBI(inode->i_sb)->log, 1);		return rc;	}	rc |= jfs_commit_inode(inode, 1);	return rc ? -EIO : 0;}static int jfs_open(struct inode *inode, struct file *file){	int rc;	if ((rc = generic_file_open(inode, file)))		return rc;	/*	 * We attempt to allow only one "active" file open per aggregate	 * group.  Otherwise, appending to files in parallel can cause	 * fragmentation within the files.	 *	 * If the file is empty, it was probably just created and going	 * to be written to.  If it has a size, we'll hold off until the	 * file is actually grown.	 */	if (S_ISREG(inode->i_mode) && file->f_mode & FMODE_WRITE &&	    (inode->i_size == 0)) {		struct jfs_inode_info *ji = JFS_IP(inode);		spin_lock_irq(&ji->ag_lock);		if (ji->active_ag == -1) {			ji->active_ag = ji->agno;			atomic_inc(			    &JFS_SBI(inode->i_sb)->bmap->db_active[ji->agno]);		}		spin_unlock_irq(&ji->ag_lock);	}	return 0;}static int jfs_release(struct inode *inode, struct file *file){	struct jfs_inode_info *ji = JFS_IP(inode);	spin_lock_irq(&ji->ag_lock);	if (ji->active_ag != -1) {		struct bmap *bmap = JFS_SBI(inode->i_sb)->bmap;		atomic_dec(&bmap->db_active[ji->active_ag]);		ji->active_ag = -1;	}	spin_unlock_irq(&ji->ag_lock);	return 0;}struct inode_operations jfs_file_inode_operations = {	.truncate	= jfs_truncate,#ifdef JFS_XATTR	.setxattr	= jfs_setxattr,	.getxattr	= jfs_getxattr,	.listxattr	= jfs_listxattr,	.removexattr	= jfs_removexattr,#endif};struct file_operations jfs_file_operations = {	.open		= jfs_open,	.llseek		= generic_file_llseek,	.write		= generic_file_write,	.read		= generic_file_read,	.mmap		= generic_file_mmap,	.fsync		= jfs_fsync,	.release	= jfs_release,};struct inode_operations jfs_special_inode_operations = {#ifdef JFS_XATTR	.setxattr	= jfs_setxattr,	.getxattr	= jfs_getxattr,	.listxattr	= jfs_listxattr,	.removexattr	= jfs_removexattr,#endif};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -