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

📄 cifsfs.c

📁 Linux内核自带的cifs模块
💻 C
📖 第 1 页 / 共 3 页
字号:
	}	FreeXid(xid);	return rc;}int cifs_xstate_set(struct super_block *sb, unsigned int flags, int operation){	int xid;	int rc = 0;	struct cifs_sb_info *cifs_sb = CIFS_SB(sb);	struct cifsTconInfo *pTcon;	if (cifs_sb)		pTcon = cifs_sb->tcon;	else		return -EIO;	xid = GetXid();	if (pTcon) {		cFYI(1, ("flags: 0x%x operation: 0x%x", flags, operation));	} else {		rc = -EIO;	}	FreeXid(xid);	return rc;}int cifs_xstate_get(struct super_block *sb, struct fs_quota_stat *qstats){	int xid;	int rc = 0;	struct cifs_sb_info *cifs_sb = CIFS_SB(sb);	struct cifsTconInfo *pTcon;	if (cifs_sb) {		pTcon = cifs_sb->tcon;	} else {		return -EIO;	}	xid = GetXid();	if (pTcon) {		cFYI(1, ("pqstats %p", qstats));	} else {		rc = -EIO;	}	FreeXid(xid);	return rc;}static struct quotactl_ops cifs_quotactl_ops = {	.set_xquota	= cifs_xquota_set,	.get_xquota	= cifs_xquota_set,	.set_xstate	= cifs_xstate_set,	.get_xstate	= cifs_xstate_get,};#endif#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 16)static void cifs_umount_begin(struct vfsmount *vfsmnt, int flags)#elsestatic void cifs_umount_begin(struct super_block * sblock)#endif{	struct cifs_sb_info *cifs_sb;	struct cifsTconInfo *tcon;#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 16)	if (!(flags & MNT_FORCE))		return;	cifs_sb = CIFS_SB(vfsmnt->mnt_sb);#else	cifs_sb = CIFS_SB(sblock);#endif	if (cifs_sb == NULL)		return;	tcon = cifs_sb->tcon;	if (tcon == NULL)		return;	down(&tcon->tconSem);	if (atomic_read(&tcon->useCount) == 1)		tcon->tidStatus = CifsExiting;	up(&tcon->tconSem);	/* cancel_brl_requests(tcon); */ /* BB mark all brl mids as exiting */	/* cancel_notify_requests(tcon); */	if (tcon->ses && tcon->ses->server) {		cFYI(1, ("wake up tasks now - umount begin not complete"));		wake_up_all(&tcon->ses->server->request_q);		wake_up_all(&tcon->ses->server->response_q);		msleep(1); /* yield */		/* we have to kick the requests once more */		wake_up_all(&tcon->ses->server->response_q);		msleep(1);	}/* BB FIXME - finish add checks for tidStatus BB */	return;}#ifdef CONFIG_CIFS_STATS2#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17)static int cifs_show_stats(struct seq_file *s, struct vfsmount *mnt){	/* BB FIXME */	return 0;}#endif#endifstatic int cifs_remount(struct super_block *sb, int *flags, char *data){	*flags |= MS_NODIRATIME;	return 0;}static const struct super_operations cifs_super_ops = {	.read_inode = cifs_read_inode,	.put_super = cifs_put_super,	.statfs = cifs_statfs,	.alloc_inode = cifs_alloc_inode,	.destroy_inode = cifs_destroy_inode,/*	.drop_inode	    = generic_delete_inode,	.delete_inode	= cifs_delete_inode,  */  /* Do not need above two	functions unless later we add lazy close of inodes or unless the	kernel forgets to call us with the same number of releases (closes)	as opens */	.show_options = cifs_show_options,	.umount_begin   = cifs_umount_begin,	.remount_fs = cifs_remount,#ifdef CONFIG_CIFS_STATS2#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17)	.show_stats = cifs_show_stats,#endif#endif};#ifndef MS_SILENT#define MS_SILENT MS_VERBOSE#endif#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17)static intcifs_get_sb(struct file_system_type *fs_type,	    int flags, const char *dev_name, void *data, struct vfsmount *mnt)#elsestatic struct super_block *cifs_get_sb(struct file_system_type *fs_type,	    int flags, const char *dev_name, void *data)#endif{	int rc;	struct super_block *sb = sget(fs_type, NULL, set_anon_super, NULL);	cFYI(1, ("Devname: %s flags: %d ", dev_name, flags));	if (IS_ERR(sb))#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17)		return PTR_ERR(sb);#else			return sb;#endif	sb->s_flags = flags;	rc = cifs_read_super(sb, data, dev_name, flags & MS_SILENT ? 1 : 0);	if (rc) {		up_write(&sb->s_umount);		deactivate_super(sb);#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17)		return rc;#else				return ERR_PTR(rc);#endif	}	sb->s_flags |= MS_ACTIVE;#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17)	return simple_set_mnt(mnt, sb);#else	return sb;#endif}#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 18)static ssize_t cifs_file_aio_write(struct kiocb *iocb, const struct iovec *iov,				   unsigned long nr_segs, loff_t pos){	struct inode *inode = iocb->ki_filp->f_path.dentry->d_inode;	ssize_t written;	written = generic_file_aio_write(iocb, iov, nr_segs, pos);#elsestatic ssize_t cifs_file_writev(struct file *file, const struct iovec *iov,				unsigned long nr_segs, loff_t *ppos){	struct inode *inode = file->f_dentry->d_inode;	ssize_t written;	written = generic_file_writev(file, iov, nr_segs, ppos);	if (!CIFS_I(inode)->clientCanCacheAll)		filemap_fdatawrite(inode->i_mapping);	return written;}static ssize_t cifs_file_aio_write(struct kiocb *iocb, const char __user *buf,				   size_t count, loff_t pos){	struct inode *inode = iocb->ki_filp->f_dentry->d_inode;	ssize_t written;	written = generic_file_aio_write(iocb, buf, count, pos);#endif	if (!CIFS_I(inode)->clientCanCacheAll)		filemap_fdatawrite(inode->i_mapping);	return written;}static loff_t cifs_llseek(struct file *file, loff_t offset, int origin){	/* origin == SEEK_END => we must revalidate the cached file length */	if (origin == 2) {		int retval;		/* some applications poll for the file length in this strange		   way so we must seek to end on non-oplocked files by		   setting the revalidate time to zero */#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 19)		CIFS_I(file->f_path.dentry->d_inode)->time = 0;		retval = cifs_revalidate(file->f_path.dentry);#else		if(file->f_dentry->d_inode)			CIFS_I(file->f_dentry->d_inode)->time = 0;		retval = cifs_revalidate(file->f_dentry);#endif		if (retval < 0)			return (loff_t)retval;	}	return remote_llseek(file, offset, origin);}static struct file_system_type cifs_fs_type = {	.owner = THIS_MODULE,	.name = "cifs",	.get_sb = cifs_get_sb,	.kill_sb = kill_anon_super,	/*  .fs_flags */};const struct inode_operations cifs_dir_inode_ops = {	.create = cifs_create,	.lookup = cifs_lookup,	.getattr = cifs_getattr,	.unlink = cifs_unlink,	.link = cifs_hardlink,	.mkdir = cifs_mkdir,	.rmdir = cifs_rmdir,	.rename = cifs_rename,	.permission = cifs_permission,/*	revalidate:cifs_revalidate,   */	.setattr = cifs_setattr,	.symlink = cifs_symlink,	.mknod   = cifs_mknod,#ifdef CONFIG_CIFS_XATTR	.setxattr = cifs_setxattr,	.getxattr = cifs_getxattr,	.listxattr = cifs_listxattr,	.removexattr = cifs_removexattr,#endif};const struct inode_operations cifs_file_inode_ops = {/*	revalidate:cifs_revalidate, */	.setattr = cifs_setattr,	.getattr = cifs_getattr, /* do we need this anymore? */	.rename = cifs_rename,	.permission = cifs_permission,#ifdef CONFIG_CIFS_XATTR	.setxattr = cifs_setxattr,	.getxattr = cifs_getxattr,	.listxattr = cifs_listxattr,	.removexattr = cifs_removexattr,#endif};const struct inode_operations cifs_symlink_inode_ops = {#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9)	.readlink = cifs_readlink,#else	.readlink = generic_readlink,	.put_link = cifs_put_link,#endif	.follow_link = cifs_follow_link,	.permission = cifs_permission,	/* BB add the following two eventually */	/* revalidate: cifs_revalidate,	   setattr:    cifs_notify_change, *//* BB do we need notify change */#ifdef CONFIG_CIFS_XATTR	.setxattr = cifs_setxattr,	.getxattr = cifs_getxattr,	.listxattr = cifs_listxattr,	.removexattr = cifs_removexattr,#endif};const struct file_operations cifs_file_ops = {	.read = do_sync_read,	.write = do_sync_write,#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)	.readv = generic_file_readv,	.writev = cifs_file_writev,#endif	.aio_read = generic_file_aio_read,	.aio_write = cifs_file_aio_write,	.open = cifs_open,	.release = cifs_close,	.lock = cifs_lock,	.fsync = cifs_fsync,	.flush = cifs_flush,	.mmap  = cifs_file_mmap,#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)	.sendfile = generic_file_sendfile,#else	.splice_read = generic_file_splice_read,#endif	.llseek = cifs_llseek,#ifdef CONFIG_CIFS_POSIX	.ioctl	= cifs_ioctl,#endif /* CONFIG_CIFS_POSIX */#ifdef CONFIG_CIFS_EXPERIMENTAL	.dir_notify = cifs_dir_notify,#endif /* CONFIG_CIFS_EXPERIMENTAL */};const struct file_operations cifs_file_direct_ops = {	/* no mmap, no aio, no readv -	   BB reevaluate whether they can be done with directio, no cache */	.read = cifs_user_read,	.write = cifs_user_write,	.open = cifs_open,	.release = cifs_close,	.lock = cifs_lock,	.fsync = cifs_fsync,	.flush = cifs_flush,#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)	.sendfile = generic_file_sendfile, /* BB removeme BB */#else	.splice_read = generic_file_splice_read,#endif#ifdef CONFIG_CIFS_POSIX	.ioctl  = cifs_ioctl,#endif /* CONFIG_CIFS_POSIX */	.llseek = cifs_llseek,#ifdef CONFIG_CIFS_EXPERIMENTAL	.dir_notify = cifs_dir_notify,#endif /* CONFIG_CIFS_EXPERIMENTAL */};const struct file_operations cifs_file_nobrl_ops = {	.read = do_sync_read,	.write = do_sync_write,#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)	.readv = generic_file_readv,	.writev = cifs_file_writev,#endif	.aio_read = generic_file_aio_read,	.aio_write = cifs_file_aio_write,	.open = cifs_open,	.release = cifs_close,	.fsync = cifs_fsync,	.flush = cifs_flush,	.mmap  = cifs_file_mmap,#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)	.sendfile = generic_file_sendfile,#else	.splice_read = generic_file_splice_read,#endif	.llseek = cifs_llseek,#ifdef CONFIG_CIFS_POSIX	.ioctl	= cifs_ioctl,#endif /* CONFIG_CIFS_POSIX */#ifdef CONFIG_CIFS_EXPERIMENTAL	.dir_notify = cifs_dir_notify,#endif /* CONFIG_CIFS_EXPERIMENTAL */};const struct file_operations cifs_file_direct_nobrl_ops = {	/* no mmap, no aio, no readv -	   BB reevaluate whether they can be done with directio, no cache */	.read = cifs_user_read,	.write = cifs_user_write,	.open = cifs_open,	.release = cifs_close,	.fsync = cifs_fsync,	.flush = cifs_flush,#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)	.sendfile = generic_file_sendfile, /* BB removeme BB */#else	.splice_read = generic_file_splice_read,#endif#ifdef CONFIG_CIFS_POSIX	.ioctl  = cifs_ioctl,#endif /* CONFIG_CIFS_POSIX */	.llseek = cifs_llseek,#ifdef CONFIG_CIFS_EXPERIMENTAL	.dir_notify = cifs_dir_notify,

⌨️ 快捷键说明

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