fs/9p/vfs_inode.c
Source file repositories/reference/linux-study-clean/fs/9p/vfs_inode.c
File Facts
- System
- Linux kernel
- Corpus path
fs/9p/vfs_inode.c- Extension
.c- Size
- 33838 bytes
- Lines
- 1404
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/errno.hlinux/fs.hlinux/file.hlinux/pagemap.hlinux/stat.hlinux/string.hlinux/namei.hlinux/sched.hlinux/slab.hlinux/xattr.hlinux/posix_acl.hnet/9p/9p.hnet/9p/client.hv9fs.hv9fs_vfs.hfid.hcache.hxattr.hacl.h
Detected Declarations
function unixmode2p9modefunction p9mode2permfunction p9mode2unixmodefunction v9fs_uflags2omodefunction v9fs_blank_wstatfunction v9fs_free_inodefunction v9fs_set_netfs_contextfunction v9fs_init_inodefunction v9fs_evict_inodefunction v9fs_test_inodefunction v9fs_test_new_inodefunction v9fs_set_inodefunction v9fs_inode_from_fidfunction v9fs_at_to_dotl_flagsfunction EXT4_LINK_MAXfunction v9fs_removefunction v9fs_createfunction openfunction v9fs_vfs_atomic_openfunction v9fs_vfs_unlinkfunction v9fs_vfs_rmdirfunction v9fs_vfs_renamefunction v9fs_vfs_getattrfunction v9fs_vfs_setattrfunction v9fs_stat2inodefunction v9fs_vfs_mkspecialfunction v9fs_vfs_symlinkfunction v9fs_vfs_linkfunction v9fs_vfs_mknodfunction v9fs_refresh_inode
Annotated Snippet
if (v9ses->nodev == 0) {
if (S_ISSOCK(mode))
res |= P9_DMSOCKET;
if (S_ISFIFO(mode))
res |= P9_DMNAMEDPIPE;
if (S_ISBLK(mode))
res |= P9_DMDEVICE;
if (S_ISCHR(mode))
res |= P9_DMDEVICE;
}
if ((mode & S_ISUID) == S_ISUID)
res |= P9_DMSETUID;
if ((mode & S_ISGID) == S_ISGID)
res |= P9_DMSETGID;
if ((mode & S_ISVTX) == S_ISVTX)
res |= P9_DMSETVTX;
}
return res;
}
/**
* p9mode2perm- convert plan9 mode bits to unix permission bits
* @v9ses: v9fs session information
* @stat: p9_wstat from which mode need to be derived
*
*/
static int p9mode2perm(struct v9fs_session_info *v9ses,
struct p9_wstat *stat)
{
int res;
int mode = stat->mode;
res = mode & 0777; /* S_IRWXUGO */
if (v9fs_proto_dotu(v9ses)) {
if ((mode & P9_DMSETUID) == P9_DMSETUID)
res |= S_ISUID;
if ((mode & P9_DMSETGID) == P9_DMSETGID)
res |= S_ISGID;
if ((mode & P9_DMSETVTX) == P9_DMSETVTX)
res |= S_ISVTX;
}
return res;
}
/**
* p9mode2unixmode- convert plan9 mode bits to unix mode bits
* @v9ses: v9fs session information
* @stat: p9_wstat from which mode need to be derived
* @rdev: major number, minor number in case of device files.
*
*/
static umode_t p9mode2unixmode(struct v9fs_session_info *v9ses,
struct p9_wstat *stat, dev_t *rdev)
{
int res, r;
u32 mode = stat->mode;
*rdev = 0;
res = p9mode2perm(v9ses, stat);
if ((mode & P9_DMDIR) == P9_DMDIR)
res |= S_IFDIR;
else if ((mode & P9_DMSYMLINK) && (v9fs_proto_dotu(v9ses)))
res |= S_IFLNK;
else if ((mode & P9_DMSOCKET) && (v9fs_proto_dotu(v9ses))
&& (v9ses->nodev == 0))
res |= S_IFSOCK;
else if ((mode & P9_DMNAMEDPIPE) && (v9fs_proto_dotu(v9ses))
&& (v9ses->nodev == 0))
res |= S_IFIFO;
else if ((mode & P9_DMDEVICE) && (v9fs_proto_dotu(v9ses))
&& (v9ses->nodev == 0)) {
char type = 0;
int major = -1, minor = -1;
r = sscanf(stat->extension, "%c %i %i", &type, &major, &minor);
if (r != 3) {
p9_debug(P9_DEBUG_ERROR,
"invalid device string, umode will be bogus: %s\n",
stat->extension);
return res;
}
switch (type) {
case 'c':
res |= S_IFCHR;
break;
case 'b':
Annotation
- Immediate include surface: `linux/module.h`, `linux/errno.h`, `linux/fs.h`, `linux/file.h`, `linux/pagemap.h`, `linux/stat.h`, `linux/string.h`, `linux/namei.h`.
- Detected declarations: `function unixmode2p9mode`, `function p9mode2perm`, `function p9mode2unixmode`, `function v9fs_uflags2omode`, `function v9fs_blank_wstat`, `function v9fs_free_inode`, `function v9fs_set_netfs_context`, `function v9fs_init_inode`, `function v9fs_evict_inode`, `function v9fs_test_inode`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.