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
29c353b3
Commit
29c353b3
authored
Jun 24, 2014
by
J. Bruce Fields
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nfsd4: define svcxdr_dupstr to share some common code
Signed-off-by:
J. Bruce Fields
<
bfields@redhat.com
>
parent
ce043ac8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
13 deletions
+23
-13
fs/nfsd/nfs4xdr.c
fs/nfsd/nfs4xdr.c
+23
-13
No files found.
fs/nfsd/nfs4xdr.c
View file @
29c353b3
...
@@ -202,6 +202,26 @@ defer_free(struct nfsd4_compoundargs *argp, void *p)
...
@@ -202,6 +202,26 @@ defer_free(struct nfsd4_compoundargs *argp, void *p)
return
0
;
return
0
;
}
}
/*
* For xdr strings that need to be passed to other kernel api's
* as null-terminated strings.
*
* Note null-terminating in place usually isn't safe since the
* buffer might end on a page boundary.
*/
static
char
*
svcxdr_dupstr
(
struct
nfsd4_compoundargs
*
argp
,
void
*
buf
,
u32
len
)
{
char
*
p
=
kmalloc
(
len
+
1
,
GFP_KERNEL
);
if
(
!
p
)
return
NULL
;
memcpy
(
p
,
buf
,
len
);
p
[
len
]
=
'\0'
;
defer_free
(
argp
,
p
);
return
p
;
}
/**
/**
* savemem - duplicate a chunk of memory for later processing
* savemem - duplicate a chunk of memory for later processing
* @argp: NFSv4 compound argument structure to be freed with
* @argp: NFSv4 compound argument structure to be freed with
...
@@ -415,12 +435,10 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval,
...
@@ -415,12 +435,10 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval,
return
nfserr_badlabel
;
return
nfserr_badlabel
;
len
+=
(
XDR_QUADLEN
(
dummy32
)
<<
2
);
len
+=
(
XDR_QUADLEN
(
dummy32
)
<<
2
);
READMEM
(
buf
,
dummy32
);
READMEM
(
buf
,
dummy32
);
label
->
data
=
kzalloc
(
dummy32
+
1
,
GFP_KERNEL
);
label
->
len
=
dummy32
;
label
->
data
=
svcxdr_dupstr
(
argp
,
buf
,
dummy32
);
if
(
!
label
->
data
)
if
(
!
label
->
data
)
return
nfserr_jukebox
;
return
nfserr_jukebox
;
label
->
len
=
dummy32
;
defer_free
(
argp
,
label
->
data
);
memcpy
(
label
->
data
,
buf
,
dummy32
);
}
}
#endif
#endif
...
@@ -597,17 +615,9 @@ nfsd4_decode_create(struct nfsd4_compoundargs *argp, struct nfsd4_create *create
...
@@ -597,17 +615,9 @@ nfsd4_decode_create(struct nfsd4_compoundargs *argp, struct nfsd4_create *create
READ_BUF
(
4
);
READ_BUF
(
4
);
create
->
cr_datalen
=
be32_to_cpup
(
p
++
);
create
->
cr_datalen
=
be32_to_cpup
(
p
++
);
READ_BUF
(
create
->
cr_datalen
);
READ_BUF
(
create
->
cr_datalen
);
/*
create
->
cr_data
=
svcxdr_dupstr
(
argp
,
p
,
create
->
cr_datalen
);
* The VFS will want a null-terminated string, and
* null-terminating in place isn't safe since this might
* end on a page boundary:
*/
create
->
cr_data
=
kmalloc
(
create
->
cr_datalen
+
1
,
GFP_KERNEL
);
if
(
!
create
->
cr_data
)
if
(
!
create
->
cr_data
)
return
nfserr_jukebox
;
return
nfserr_jukebox
;
memcpy
(
create
->
cr_data
,
p
,
create
->
cr_datalen
);
create
->
cr_data
[
create
->
cr_datalen
]
=
'\0'
;
defer_free
(
argp
,
create
->
cr_data
);
break
;
break
;
case
NF4BLK
:
case
NF4BLK
:
case
NF4CHR
:
case
NF4CHR
:
...
...
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