/*
* linux/fs/9p/vfs_inode.c
*
* This file contains vfs inode ops for the 9P2000 protocol.
*
* Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com>
* Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* 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:
* Free Software Foundation
* 51 Franklin Street, Fifth Floor
* Boston, MA 02111-1301 USA
*
*/
#include <linux/module.h>
#include <linux/errno.h>
#include <linux/fs.h>
#include <linux/file.h>
#include <linux/pagemap.h>
#include <linux/stat.h>
#include <linux/string.h>
#include <linux/smp_lock.h>
#include <linux/inet.h>
#include <linux/namei.h>
#include <linux/idr.h>
#include "debug.h"
#include "v9fs.h"
#include "9p.h"
#include "v9fs_vfs.h"
#include "fid.h"
static const struct inode_operations v9fs_dir_inode_operations;
static const struct inode_operations v9fs_dir_inode_operations_ext;
static const struct inode_operations v9fs_file_inode_operations;
static const struct inode_operations v9fs_symlink_inode_operations;
/**
* unixmode2p9mode - convert unix mode bits to plan 9
* @v9ses: v9fs session information
* @mode: mode to convert
*
*/
static int unixmode2p9mode(struct v9fs_session_info *v9ses, int mode)
{
int res;
res = mode & 0777;
if (S_ISDIR(mode))
res |= V9FS_DMDIR;
if (v9ses->extended) {
if (S_ISLNK(mode))
res |= V9FS_DMSYMLINK;
if (v9ses->nodev == 0) {
if (S_ISSOCK(mode))
res |= V9FS_DMSOCKET;
if (S_ISFIFO(mode))
res |= V9FS_DMNAMEDPIPE;
if (S_ISBLK(mode))
res |= V9FS_DMDEVICE;
if (S_ISCHR(mode))
res |= V9FS_DMDEVICE;
}
if ((mode & S_ISUID) == S_ISUID)
res |= V9FS_DMSETUID;
if ((mode & S_ISGID) == S_ISGID)
res |= V9FS_DMSETGID;
if ((mode & V9FS_DMLINK))
res |= V9FS_DMLINK;
}
return res;
}
/**
* p9mode2unixmode- convert plan9 mode bits to unix mode bits