mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-05-14 04:19:34 +08:00
nfsclient: Next attempt to fix 64-bit targets
In serporidok use the same structures used to hand over to the XDR encode/decode routines. We must not mix packed and unpacked structures. Update #4025.
This commit is contained in:
parent
d964a6703c
commit
03d7f76a81
@ -397,71 +397,36 @@ DirInfo dip;
|
|||||||
|
|
||||||
/* Macro for accessing serporid fields
|
/* Macro for accessing serporid fields
|
||||||
*/
|
*/
|
||||||
#define SERP_ARGS(node) ((node)->serporid.serporid_u.serporid.arg_u)
|
#define SERP_ARGS(node) ((node)->serporid.serporid)
|
||||||
#define SERP_ATTR(node) ((node)->serporid.serporid_u.serporid.attributes)
|
#define SERP_ATTR(node) ((node)->serporid.serporid.attributes)
|
||||||
#define SERP_FILE(node) ((node)->serporid.serporid_u.serporid.file)
|
#define SERP_FILE(node) ((node)->serporid.serporid.file)
|
||||||
|
|
||||||
/*
|
|
||||||
* FIXME: The use of the serporid structure with several embedded unions to
|
|
||||||
* split up the specific NFS request/response structures is quite a hack. It
|
|
||||||
* breaks on 64-bit targets due to the presence of pointer members which affect
|
|
||||||
* the overall alignment. Use a packed serporidok structure to hopefully fix
|
|
||||||
* this issue.
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct serporidok {
|
typedef struct serporidok {
|
||||||
fattr attributes;
|
fattr attributes;
|
||||||
nfs_fh file;
|
|
||||||
union {
|
union {
|
||||||
struct {
|
nfs_fh file;
|
||||||
filename name;
|
diropargs diroparg;
|
||||||
} diroparg;
|
sattrargs sattrarg;
|
||||||
struct {
|
readargs readarg;
|
||||||
sattr attributes;
|
writeargs writearg;
|
||||||
} sattrarg;
|
createargs createarg;
|
||||||
struct {
|
renameargs renamearg;
|
||||||
uint32_t offset;
|
linkargs linkarg;
|
||||||
uint32_t count;
|
symlinkargs symlinkarg;
|
||||||
uint32_t totalcount;
|
readdirargs readdirarg;
|
||||||
} readarg;
|
};
|
||||||
struct {
|
} serporidok;
|
||||||
uint32_t beginoffset;
|
|
||||||
uint32_t offset;
|
|
||||||
uint32_t totalcount;
|
|
||||||
struct {
|
|
||||||
uint32_t data_len;
|
|
||||||
char* data_val;
|
|
||||||
} data;
|
|
||||||
} writearg;
|
|
||||||
struct {
|
|
||||||
filename name;
|
|
||||||
sattr attributes;
|
|
||||||
} createarg;
|
|
||||||
struct {
|
|
||||||
filename name;
|
|
||||||
diropargs to;
|
|
||||||
} renamearg;
|
|
||||||
struct {
|
|
||||||
diropargs to;
|
|
||||||
} linkarg;
|
|
||||||
struct {
|
|
||||||
filename name;
|
|
||||||
nfspath to;
|
|
||||||
sattr attributes;
|
|
||||||
} symlinkarg;
|
|
||||||
struct {
|
|
||||||
nfscookie cookie;
|
|
||||||
uint32_t count;
|
|
||||||
} readdirarg;
|
|
||||||
} arg_u;
|
|
||||||
} RTEMS_PACKED serporidok;
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The nfsstat is an enum, so has an integer alignment. The serporid contains
|
||||||
|
* pointers, so has at least a pointer alignment. The packed attribute ensures
|
||||||
|
* that there is no gap between the status and serporid members on 64-bit
|
||||||
|
* targets.
|
||||||
|
*/
|
||||||
typedef struct serporid {
|
typedef struct serporid {
|
||||||
nfsstat status;
|
nfsstat status;
|
||||||
union {
|
|
||||||
serporidok serporid;
|
serporidok serporid;
|
||||||
} serporid_u;
|
} RTEMS_PACKED serporid;
|
||||||
} serporid;
|
|
||||||
|
|
||||||
/* an XDR routine to encode/decode the inverted diropres
|
/* an XDR routine to encode/decode the inverted diropres
|
||||||
* into an nfsnodestat;
|
* into an nfsnodestat;
|
||||||
@ -493,7 +458,7 @@ xdr_serporid(XDR *xdrs, serporid *objp)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
switch (objp->status) {
|
switch (objp->status) {
|
||||||
case NFS_OK:
|
case NFS_OK:
|
||||||
if (!xdr_serporidok(xdrs, &objp->serporid_u.serporid))
|
if (!xdr_serporidok(xdrs, &objp->serporid))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -2040,7 +2005,7 @@ char *dupname;
|
|||||||
|
|
||||||
rtems_clock_get_tod_timeval(&now);
|
rtems_clock_get_tod_timeval(&now);
|
||||||
|
|
||||||
SERP_ARGS(node).createarg.name = dupname;
|
SERP_ARGS(node).createarg.where.name = dupname;
|
||||||
SERP_ARGS(node).createarg.attributes.mode = mode;
|
SERP_ARGS(node).createarg.attributes.mode = mode;
|
||||||
SERP_ARGS(node).createarg.attributes.uid = nfs->uid;
|
SERP_ARGS(node).createarg.attributes.uid = nfs->uid;
|
||||||
SERP_ARGS(node).createarg.attributes.gid = nfs->gid;
|
SERP_ARGS(node).createarg.attributes.gid = nfs->gid;
|
||||||
@ -2134,7 +2099,7 @@ char *dupname;
|
|||||||
|
|
||||||
rtems_clock_get_tod_timeval(&now);
|
rtems_clock_get_tod_timeval(&now);
|
||||||
|
|
||||||
SERP_ARGS(node).symlinkarg.name = dupname;
|
SERP_ARGS(node).symlinkarg.from.name = dupname;
|
||||||
SERP_ARGS(node).symlinkarg.to = (nfspath) target;
|
SERP_ARGS(node).symlinkarg.to = (nfspath) target;
|
||||||
|
|
||||||
SERP_ARGS(node).symlinkarg.attributes.mode = S_IFLNK | S_IRWXU | S_IRWXG | S_IRWXO;
|
SERP_ARGS(node).symlinkarg.attributes.mode = S_IFLNK | S_IRWXU | S_IRWXG | S_IRWXO;
|
||||||
@ -2231,7 +2196,7 @@ static int nfs_rename(
|
|||||||
nfs_fh *toDirDst = &SERP_ARGS(oldParentNode).renamearg.to.dir;
|
nfs_fh *toDirDst = &SERP_ARGS(oldParentNode).renamearg.to.dir;
|
||||||
nfsstat status;
|
nfsstat status;
|
||||||
|
|
||||||
SERP_ARGS(oldParentNode).renamearg.name = oldNode->str;
|
SERP_ARGS(oldParentNode).renamearg.from.name = oldNode->str;
|
||||||
SERP_ARGS(oldParentNode).renamearg.to.name = dupname;
|
SERP_ARGS(oldParentNode).renamearg.to.name = dupname;
|
||||||
memcpy(toDirDst, toDirSrc, sizeof(*toDirDst));
|
memcpy(toDirDst, toDirSrc, sizeof(*toDirDst));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user