Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
mariux64
/
linux
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
2
Pull requests
0
Actions
Projects
0
Wiki
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security
Insights
Files
1a50ede
Documentation
LICENSES
arch
block
certs
crypto
drivers
fs
9p
adfs
affs
afs
autofs
befs
bfs
btrfs
cachefiles
ceph
cifs
coda
configfs
cramfs
crypto
debugfs
devpts
dlm
ecryptfs
efivarfs
efs
erofs
exfat
exportfs
ext2
ext4
f2fs
fat
freevxfs
fscache
fuse
gfs2
hfs
hfsplus
hostfs
hpfs
hugetlbfs
iomap
isofs
jbd2
jffs2
jfs
kernfs
lockd
minix
nfs
blocklayout
filelayout
flexfilelayout
Kconfig
Makefile
cache_lib.c
cache_lib.h
callback.c
callback.h
callback_proc.c
callback_xdr.c
client.c
delegation.c
delegation.h
dir.c
direct.c
dns_resolve.c
dns_resolve.h
export.c
file.c
fs_context.c
fscache-index.c
fscache.c
fscache.h
getroot.c
inode.c
internal.h
io.c
iostat.h
mount_clnt.c
namespace.c
netns.h
nfs.h
nfs2super.c
nfs2xdr.c
nfs3_fs.h
nfs3acl.c
nfs3client.c
nfs3proc.c
nfs3super.c
nfs3xdr.c
nfs42.h
nfs42proc.c
nfs42xattr.c
nfs42xdr.c
nfs4_fs.h
nfs4client.c
nfs4file.c
nfs4getroot.c
nfs4idmap.c
nfs4idmap.h
nfs4namespace.c
nfs4proc.c
nfs4renewd.c
nfs4session.c
nfs4session.h
nfs4state.c
nfs4super.c
nfs4sysctl.c
nfs4trace.c
nfs4trace.h
nfs4xdr.c
nfsroot.c
nfstrace.c
nfstrace.h
pagelist.c
pnfs.c
pnfs.h
pnfs_dev.c
pnfs_nfs.c
proc.c
read.c
super.c
symlink.c
sysctl.c
sysfs.c
sysfs.h
unlink.c
write.c
nfs_common
nfsd
nilfs2
nls
notify
ntfs
ocfs2
omfs
openpromfs
orangefs
overlayfs
proc
pstore
qnx4
qnx6
quota
ramfs
reiserfs
romfs
squashfs
sysfs
sysv
tracefs
ubifs
udf
ufs
unicode
vboxsf
verity
xfs
zonefs
Kconfig
Kconfig.binfmt
Makefile
aio.c
anon_inodes.c
attr.c
bad_inode.c
binfmt_aout.c
binfmt_elf.c
binfmt_elf_fdpic.c
binfmt_em86.c
binfmt_flat.c
binfmt_misc.c
binfmt_script.c
block_dev.c
buffer.c
char_dev.c
compat_binfmt_elf.c
coredump.c
d_path.c
dax.c
dcache.c
dcookies.c
direct-io.c
drop_caches.c
eventfd.c
eventpoll.c
exec.c
fcntl.c
fhandle.c
file.c
file_table.c
filesystems.c
fs-writeback.c
fs_context.c
fs_parser.c
fs_pin.c
fs_struct.c
fs_types.c
fsopen.c
init.c
inode.c
internal.h
io-wq.c
io-wq.h
io_uring.c
ioctl.c
kernel_read_file.c
libfs.c
locks.c
mbcache.c
mount.h
mpage.c
namei.c
namespace.c
no-block.c
nsfs.c
open.c
pipe.c
pnode.c
pnode.h
posix_acl.c
proc_namespace.c
read_write.c
readdir.c
remap_range.c
select.c
seq_file.c
signalfd.c
splice.c
stack.c
stat.c
statfs.c
super.c
sync.c
timerfd.c
userfaultfd.c
utimes.c
xattr.c
include
init
ipc
kernel
lib
mm
net
samples
scripts
security
sound
tools
usr
virt
.clang-format
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS
Makefile
README
Breadcrumbs
linux
/
fs
/
nfs
/
export.c
Blame
Blame
Latest commit
History
History
177 lines (150 loc) · 4.34 KB
Breadcrumbs
linux
/
fs
/
nfs
/
export.c
Top
File metadata and controls
Code
Blame
177 lines (150 loc) · 4.34 KB
Raw
// SPDX-License-Identifier: GPL-2.0 /* * Copyright (c) 2015, Primary Data, Inc. All rights reserved. * * Tao Peng <bergwolf@primarydata.com> */ #include <linux/dcache.h> #include <linux/exportfs.h> #include <linux/nfs.h> #include <linux/nfs_fs.h> #include "internal.h" #include "nfstrace.h" #define NFSDBG_FACILITY NFSDBG_VFS enum { FILEID_HIGH_OFF = 0, /* inode fileid high */ FILEID_LOW_OFF, /* inode fileid low */ FILE_I_TYPE_OFF, /* inode type */ EMBED_FH_OFF /* embeded server fh */ }; static struct nfs_fh *nfs_exp_embedfh(__u32 *p) { return (struct nfs_fh *)(p + EMBED_FH_OFF); } /* * Let's break subtree checking for now... otherwise we'll have to embed parent fh * but there might not be enough space. */ static int nfs_encode_fh(struct inode *inode, __u32 *p, int *max_len, struct inode *parent) { struct nfs_fh *server_fh = NFS_FH(inode); struct nfs_fh *clnt_fh = nfs_exp_embedfh(p); size_t fh_size = offsetof(struct nfs_fh, data) + server_fh->size; int len = EMBED_FH_OFF + XDR_QUADLEN(fh_size); dprintk("%s: max fh len %d inode %p parent %p", __func__, *max_len, inode, parent); if (*max_len < len || IS_AUTOMOUNT(inode)) { dprintk("%s: fh len %d too small, required %d\n", __func__, *max_len, len); *max_len = len; return FILEID_INVALID; } p[FILEID_HIGH_OFF] = NFS_FILEID(inode) >> 32; p[FILEID_LOW_OFF] = NFS_FILEID(inode); p[FILE_I_TYPE_OFF] = inode->i_mode & S_IFMT; p[len - 1] = 0; /* Padding */ nfs_copy_fh(clnt_fh, server_fh); *max_len = len; dprintk("%s: result fh fileid %llu mode %u size %d\n", __func__, NFS_FILEID(inode), inode->i_mode, *max_len); return *max_len; } static struct dentry * nfs_fh_to_dentry(struct super_block *sb, struct fid *fid, int fh_len, int fh_type) { struct nfs4_label *label = NULL; struct nfs_fattr *fattr = NULL; struct nfs_fh *server_fh = nfs_exp_embedfh(fid->raw); size_t fh_size = offsetof(struct nfs_fh, data) + server_fh->size; const struct nfs_rpc_ops *rpc_ops; struct dentry *dentry; struct inode *inode; int len = EMBED_FH_OFF + XDR_QUADLEN(fh_size); u32 *p = fid->raw; int ret; /* NULL translates to ESTALE */ if (fh_len < len || fh_type != len) return NULL; fattr = nfs_alloc_fattr(); if (fattr == NULL) { dentry = ERR_PTR(-ENOMEM); goto out; } fattr->fileid = ((u64)p[FILEID_HIGH_OFF] << 32) + p[FILEID_LOW_OFF]; fattr->mode = p[FILE_I_TYPE_OFF]; fattr->valid |= NFS_ATTR_FATTR_FILEID | NFS_ATTR_FATTR_TYPE; dprintk("%s: fileid %llu mode %d\n", __func__, fattr->fileid, fattr->mode); inode = nfs_ilookup(sb, fattr, server_fh); if (inode) goto out_found; label = nfs4_label_alloc(NFS_SB(sb), GFP_KERNEL); if (IS_ERR(label)) { dentry = ERR_CAST(label); goto out_free_fattr; } rpc_ops = NFS_SB(sb)->nfs_client->rpc_ops; ret = rpc_ops->getattr(NFS_SB(sb), server_fh, fattr, label, NULL); if (ret) { dprintk("%s: getattr failed %d\n", __func__, ret); trace_nfs_fh_to_dentry(sb, server_fh, fattr->fileid, ret); dentry = ERR_PTR(ret); goto out_free_label; } inode = nfs_fhget(sb, server_fh, fattr, label); out_found: dentry = d_obtain_alias(inode); out_free_label: nfs4_label_free(label); out_free_fattr: nfs_free_fattr(fattr); out: return dentry; } static struct dentry * nfs_get_parent(struct dentry *dentry) { int ret; struct inode *inode = d_inode(dentry), *pinode; struct super_block *sb = inode->i_sb; struct nfs_server *server = NFS_SB(sb); struct nfs_fattr *fattr = NULL; struct nfs4_label *label = NULL; struct dentry *parent; struct nfs_rpc_ops const *ops = server->nfs_client->rpc_ops; struct nfs_fh fh; if (!ops->lookupp) return ERR_PTR(-EACCES); fattr = nfs_alloc_fattr(); if (fattr == NULL) { parent = ERR_PTR(-ENOMEM); goto out; } label = nfs4_label_alloc(server, GFP_KERNEL); if (IS_ERR(label)) { parent = ERR_CAST(label); goto out_free_fattr; } ret = ops->lookupp(inode, &fh, fattr, label); if (ret) { parent = ERR_PTR(ret); goto out_free_label; } pinode = nfs_fhget(sb, &fh, fattr, label); parent = d_obtain_alias(pinode); out_free_label: nfs4_label_free(label); out_free_fattr: nfs_free_fattr(fattr); out: return parent; } const struct export_operations nfs_export_ops = { .encode_fh = nfs_encode_fh, .fh_to_dentry = nfs_fh_to_dentry, .get_parent = nfs_get_parent, .flags = EXPORT_OP_NOWCC|EXPORT_OP_NOSUBTREECHK| EXPORT_OP_CLOSE_BEFORE_UNLINK|EXPORT_OP_REMOTE_FS| EXPORT_OP_NOATOMIC_ATTR, };
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
You can’t perform that action at this time.