Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
4e593930
Commit
4e593930
authored
Mar 10, 2005
by
Trond Myklebust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
NFS: mknod() cleanup
Signed-off-by:
Trond Myklebust
<
Trond.Myklebust@netapp.com
>
parent
a1593520
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
70 additions
and
55 deletions
+70
-55
fs/nfs/dir.c
fs/nfs/dir.c
+25
-20
fs/nfs/nfs3proc.c
fs/nfs/nfs3proc.c
+13
-10
fs/nfs/nfs4proc.c
fs/nfs/nfs4proc.c
+14
-13
fs/nfs/proc.c
fs/nfs/proc.c
+14
-10
include/linux/nfs_fs.h
include/linux/nfs_fs.h
+2
-0
include/linux/nfs_xdr.h
include/linux/nfs_xdr.h
+2
-2
No files found.
fs/nfs/dir.c
View file @
4e593930
...
...
@@ -955,7 +955,7 @@ static struct dentry *nfs_readdir_lookup(nfs_readdir_descriptor_t *desc)
/*
* Code common to create, mkdir, and mknod.
*/
static
int
nfs_instantiate
(
struct
dentry
*
dentry
,
struct
nfs_fh
*
fhandle
,
int
nfs_instantiate
(
struct
dentry
*
dentry
,
struct
nfs_fh
*
fhandle
,
struct
nfs_fattr
*
fattr
)
{
struct
inode
*
inode
;
...
...
@@ -976,14 +976,12 @@ static int nfs_instantiate(struct dentry *dentry, struct nfs_fh *fhandle,
if
(
error
<
0
)
goto
out_err
;
}
inode
=
nfs_fhget
(
dentry
->
d_sb
,
fhandle
,
fattr
);
if
(
inode
)
{
d_instantiate
(
dentry
,
inode
);
nfs_renew_times
(
dentry
);
nfs_set_verifier
(
dentry
,
nfs_save_change_attribute
(
dentry
->
d_parent
->
d_inode
));
return
0
;
}
error
=
-
ENOMEM
;
inode
=
nfs_fhget
(
dentry
->
d_sb
,
fhandle
,
fattr
);
if
(
inode
==
NULL
)
goto
out_err
;
d_instantiate
(
dentry
,
inode
);
return
0
;
out_err:
d_drop
(
dentry
);
return
error
;
...
...
@@ -1036,9 +1034,7 @@ static int
nfs_mknod
(
struct
inode
*
dir
,
struct
dentry
*
dentry
,
int
mode
,
dev_t
rdev
)
{
struct
iattr
attr
;
struct
nfs_fattr
fattr
;
struct
nfs_fh
fhandle
;
int
error
;
int
status
;
dfprintk
(
VFS
,
"NFS: mknod(%s/%ld, %s
\n
"
,
dir
->
i_sb
->
s_id
,
dir
->
i_ino
,
dentry
->
d_name
.
name
);
...
...
@@ -1051,15 +1047,18 @@ nfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev)
lock_kernel
();
nfs_begin_data_update
(
dir
);
error
=
NFS_PROTO
(
dir
)
->
mknod
(
dir
,
&
dentry
->
d_name
,
&
attr
,
rdev
,
&
fhandle
,
&
fattr
);
status
=
NFS_PROTO
(
dir
)
->
mknod
(
dir
,
dentry
,
&
attr
,
rdev
);
nfs_end_data_update
(
dir
);
if
(
!
error
)
error
=
nfs_instantiate
(
dentry
,
&
fhandle
,
&
fattr
)
;
else
d_drop
(
dentry
);
if
(
status
!=
0
)
goto
out_err
;
nfs_renew_times
(
dentry
);
nfs_set_verifier
(
dentry
,
nfs_save_change_attribute
(
dir
)
);
unlock_kernel
();
return
error
;
return
0
;
out_err:
unlock_kernel
();
d_drop
(
dentry
);
return
status
;
}
/*
...
...
@@ -1094,8 +1093,14 @@ static int nfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
nfs_end_data_update
(
dir
);
if
(
!
error
)
error
=
nfs_instantiate
(
dentry
,
&
fhandle
,
&
fattr
);
else
d_drop
(
dentry
);
if
(
error
!=
0
)
goto
out_err
;
nfs_renew_times
(
dentry
);
nfs_set_verifier
(
dentry
,
nfs_save_change_attribute
(
dir
));
unlock_kernel
();
return
0
;
out_err:
d_drop
(
dentry
);
unlock_kernel
();
return
error
;
}
...
...
fs/nfs/nfs3proc.c
View file @
4e593930
...
...
@@ -639,23 +639,24 @@ nfs3_proc_readdir(struct dentry *dentry, struct rpc_cred *cred,
}
static
int
nfs3_proc_mknod
(
struct
inode
*
dir
,
struct
qstr
*
name
,
struct
iattr
*
sattr
,
dev_t
rdev
,
struct
nfs_fh
*
fh
,
struct
nfs_fattr
*
fattr
)
nfs3_proc_mknod
(
struct
inode
*
dir
,
struct
dentry
*
dentry
,
struct
iattr
*
sattr
,
dev_t
rdev
)
{
struct
nfs_fattr
dir_attr
;
struct
nfs_fh
fh
;
struct
nfs_fattr
fattr
,
dir_attr
;
struct
nfs3_mknodargs
arg
=
{
.
fh
=
NFS_FH
(
dir
),
.
name
=
name
->
name
,
.
len
=
name
->
len
,
.
name
=
dentry
->
d_name
.
name
,
.
len
=
dentry
->
d_name
.
len
,
.
sattr
=
sattr
,
.
rdev
=
rdev
};
struct
nfs3_diropres
res
=
{
.
dir_attr
=
&
dir_attr
,
.
fh
=
fh
,
.
fattr
=
fattr
.
fh
=
&
fh
,
.
fattr
=
&
fattr
};
int
status
;
int
status
;
switch
(
sattr
->
ia_mode
&
S_IFMT
)
{
case
S_IFBLK
:
arg
.
type
=
NF3BLK
;
break
;
...
...
@@ -665,12 +666,14 @@ nfs3_proc_mknod(struct inode *dir, struct qstr *name, struct iattr *sattr,
default:
return
-
EINVAL
;
}
dprintk
(
"NFS call mknod %s %u:%u
\n
"
,
name
->
name
,
dprintk
(
"NFS call mknod %s %u:%u
\n
"
,
dentry
->
d_name
.
name
,
MAJOR
(
rdev
),
MINOR
(
rdev
));
dir_attr
.
valid
=
0
;
fattr
->
valid
=
0
;
fattr
.
valid
=
0
;
status
=
rpc_call
(
NFS_CLIENT
(
dir
),
NFS3PROC_MKNOD
,
&
arg
,
&
res
,
0
);
nfs_refresh_inode
(
dir
,
&
dir_attr
);
if
(
status
==
0
)
status
=
nfs_instantiate
(
dentry
,
&
fh
,
&
fattr
);
dprintk
(
"NFS reply mknod: %d
\n
"
,
status
);
return
status
;
}
...
...
fs/nfs/nfs4proc.c
View file @
4e593930
...
...
@@ -1755,22 +1755,23 @@ static int nfs4_proc_readdir(struct dentry *dentry, struct rpc_cred *cred,
return
err
;
}
static
int
_nfs4_proc_mknod
(
struct
inode
*
dir
,
struct
qstr
*
name
,
struct
iattr
*
sattr
,
dev_t
rdev
,
struct
nfs_fh
*
fh
,
struct
nfs_fattr
*
fattr
)
static
int
_nfs4_proc_mknod
(
struct
inode
*
dir
,
struct
dentry
*
dentry
,
struct
iattr
*
sattr
,
dev_t
rdev
)
{
struct
nfs_server
*
server
=
NFS_SERVER
(
dir
);
struct
nfs_fh
fh
;
struct
nfs_fattr
fattr
;
struct
nfs4_create_arg
arg
=
{
.
dir_fh
=
NFS_FH
(
dir
),
.
server
=
server
,
.
name
=
name
,
.
name
=
&
dentry
->
d_
name
,
.
attrs
=
sattr
,
.
bitmask
=
server
->
attr_bitmask
,
};
struct
nfs4_create_res
res
=
{
.
server
=
server
,
.
fh
=
fh
,
.
fattr
=
fattr
,
.
fh
=
&
fh
,
.
fattr
=
&
fattr
,
};
struct
rpc_message
msg
=
{
.
rpc_proc
=
&
nfs4_procedures
[
NFSPROC4_CLNT_CREATE
],
...
...
@@ -1780,7 +1781,7 @@ static int _nfs4_proc_mknod(struct inode *dir, struct qstr *name,
int
status
;
int
mode
=
sattr
->
ia_mode
;
fattr
->
valid
=
0
;
fattr
.
valid
=
0
;
BUG_ON
(
!
(
sattr
->
ia_valid
&
ATTR_MODE
));
BUG_ON
(
!
S_ISFIFO
(
mode
)
&&
!
S_ISBLK
(
mode
)
&&
!
S_ISCHR
(
mode
)
&&
!
S_ISSOCK
(
mode
));
...
...
@@ -1800,21 +1801,21 @@ static int _nfs4_proc_mknod(struct inode *dir, struct qstr *name,
arg
.
ftype
=
NF4SOCK
;
status
=
rpc_call_sync
(
NFS_CLIENT
(
dir
),
&
msg
,
0
);
if
(
!
status
)
if
(
status
==
0
)
{
update_changeattr
(
dir
,
&
res
.
dir_cinfo
);
status
=
nfs_instantiate
(
dentry
,
&
fh
,
&
fattr
);
}
return
status
;
}
static
int
nfs4_proc_mknod
(
struct
inode
*
dir
,
struct
qstr
*
name
,
struct
iattr
*
sattr
,
dev_t
rdev
,
struct
nfs_fh
*
fh
,
struct
nfs_fattr
*
fattr
)
static
int
nfs4_proc_mknod
(
struct
inode
*
dir
,
struct
dentry
*
dentry
,
struct
iattr
*
sattr
,
dev_t
rdev
)
{
struct
nfs4_exception
exception
=
{
};
int
err
;
do
{
err
=
nfs4_handle_exception
(
NFS_SERVER
(
dir
),
_nfs4_proc_mknod
(
dir
,
name
,
sattr
,
rdev
,
fh
,
fattr
),
_nfs4_proc_mknod
(
dir
,
dentry
,
sattr
,
rdev
),
&
exception
);
}
while
(
exception
.
retry
);
return
err
;
...
...
fs/nfs/proc.c
View file @
4e593930
...
...
@@ -248,22 +248,24 @@ nfs_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
* In NFSv2, mknod is grafted onto the create call.
*/
static
int
nfs_proc_mknod
(
struct
inode
*
dir
,
struct
qstr
*
name
,
struct
iattr
*
sattr
,
dev_t
rdev
,
struct
nfs_fh
*
fhandle
,
struct
nfs_fattr
*
fattr
)
nfs_proc_mknod
(
struct
inode
*
dir
,
struct
dentry
*
dentry
,
struct
iattr
*
sattr
,
dev_t
rdev
)
{
struct
nfs_fh
fhandle
;
struct
nfs_fattr
fattr
;
struct
nfs_createargs
arg
=
{
.
fh
=
NFS_FH
(
dir
),
.
name
=
name
->
name
,
.
len
=
name
->
len
,
.
name
=
dentry
->
d_name
.
name
,
.
len
=
dentry
->
d_name
.
len
,
.
sattr
=
sattr
};
struct
nfs_diropok
res
=
{
.
fh
=
fhandle
,
.
fattr
=
fattr
.
fh
=
&
fhandle
,
.
fattr
=
&
fattr
};
int
status
,
mode
;
int
status
,
mode
;
dprintk
(
"NFS call mknod %s
\n
"
,
name
->
name
);
dprintk
(
"NFS call mknod %s
\n
"
,
dentry
->
d_name
.
name
);
mode
=
sattr
->
ia_mode
;
if
(
S_ISFIFO
(
mode
))
{
...
...
@@ -274,14 +276,16 @@ nfs_proc_mknod(struct inode *dir, struct qstr *name, struct iattr *sattr,
sattr
->
ia_size
=
new_encode_dev
(
rdev
);
/* get out your barf bag */
}
fattr
->
valid
=
0
;
fattr
.
valid
=
0
;
status
=
rpc_call
(
NFS_CLIENT
(
dir
),
NFSPROC_CREATE
,
&
arg
,
&
res
,
0
);
if
(
status
==
-
EINVAL
&&
S_ISFIFO
(
mode
))
{
sattr
->
ia_mode
=
mode
;
fattr
->
valid
=
0
;
fattr
.
valid
=
0
;
status
=
rpc_call
(
NFS_CLIENT
(
dir
),
NFSPROC_CREATE
,
&
arg
,
&
res
,
0
);
}
if
(
status
==
0
)
status
=
nfs_instantiate
(
dentry
,
&
fhandle
,
&
fattr
);
dprintk
(
"NFS reply mknod: %d
\n
"
,
status
);
return
status
;
}
...
...
include/linux/nfs_fs.h
View file @
4e593930
...
...
@@ -345,6 +345,8 @@ extern struct inode_operations nfs_dir_inode_operations;
extern
struct
file_operations
nfs_dir_operations
;
extern
struct
dentry_operations
nfs_dentry_operations
;
extern
int
nfs_instantiate
(
struct
dentry
*
dentry
,
struct
nfs_fh
*
fh
,
struct
nfs_fattr
*
fattr
);
/*
* linux/fs/nfs/symlink.c
*/
...
...
include/linux/nfs_xdr.h
View file @
4e593930
...
...
@@ -699,8 +699,8 @@ struct nfs_rpc_ops {
int
(
*
rmdir
)
(
struct
inode
*
,
struct
qstr
*
);
int
(
*
readdir
)
(
struct
dentry
*
,
struct
rpc_cred
*
,
u64
,
struct
page
*
,
unsigned
int
,
int
);
int
(
*
mknod
)
(
struct
inode
*
,
struct
qstr
*
,
struct
iattr
*
,
dev_t
,
struct
nfs_fh
*
,
struct
nfs_fattr
*
);
int
(
*
mknod
)
(
struct
inode
*
,
struct
dentry
*
,
struct
iattr
*
,
dev_t
);
int
(
*
statfs
)
(
struct
nfs_server
*
,
struct
nfs_fh
*
,
struct
nfs_fsstat
*
);
int
(
*
fsinfo
)
(
struct
nfs_server
*
,
struct
nfs_fh
*
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment