Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F106939139
D47956.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D47956.diff
View Options
diff --git a/sys/fs/tmpfs/tmpfs.h b/sys/fs/tmpfs/tmpfs.h
--- a/sys/fs/tmpfs/tmpfs.h
+++ b/sys/fs/tmpfs/tmpfs.h
@@ -448,11 +448,10 @@
* NFS code.
*/
struct tmpfs_fid_data {
+ unsigned short tfd_len;
ino_t tfd_id;
unsigned long tfd_gen;
-};
-_Static_assert(sizeof(struct tmpfs_fid_data) <= MAXFIDSZ,
- "(struct tmpfs_fid_data) is larger than (struct fid).fid_data");
+} __packed;
struct tmpfs_dir_cursor {
struct tmpfs_dirent *tdc_current;
diff --git a/sys/fs/tmpfs/tmpfs_vfsops.c b/sys/fs/tmpfs/tmpfs_vfsops.c
--- a/sys/fs/tmpfs/tmpfs_vfsops.c
+++ b/sys/fs/tmpfs/tmpfs_vfsops.c
@@ -585,29 +585,25 @@
tmpfs_fhtovp(struct mount *mp, struct fid *fhp, int flags,
struct vnode **vpp)
{
- struct tmpfs_fid_data tfd;
+ struct tmpfs_fid_data *tfd;
struct tmpfs_mount *tmp;
struct tmpfs_node *node;
int error;
- if (fhp->fid_len != sizeof(tfd))
+ if (fhp->fid_len != sizeof(*tfd))
return (EINVAL);
- /*
- * Copy from fid_data onto the stack to avoid unaligned pointer use.
- * See the comment in sys/mount.h on struct fid for details.
- */
- memcpy(&tfd, fhp->fid_data, fhp->fid_len);
+ tfd = (struct tmpfs_fid_data *)fhp;
tmp = VFS_TO_TMPFS(mp);
- if (tfd.tfd_id >= tmp->tm_nodes_max)
+ if (tfd->tfd_id >= tmp->tm_nodes_max)
return (EINVAL);
TMPFS_LOCK(tmp);
LIST_FOREACH(node, &tmp->tm_nodes_used, tn_entries) {
- if (node->tn_id == tfd.tfd_id &&
- node->tn_gen == tfd.tfd_gen) {
+ if (node->tn_id == tfd->tfd_id &&
+ node->tn_gen == tfd->tfd_gen) {
tmpfs_ref_node(node);
break;
}
diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c
--- a/sys/fs/tmpfs/tmpfs_vnops.c
+++ b/sys/fs/tmpfs/tmpfs_vnops.c
@@ -1706,23 +1706,15 @@
};
*/
{
- struct tmpfs_fid_data tfd;
+ struct tmpfs_fid_data *const tfd = (struct tmpfs_fid_data *)ap->a_fhp;
struct tmpfs_node *node;
- struct fid *fhp;
_Static_assert(sizeof(struct tmpfs_fid_data) <= sizeof(struct fid),
"struct tmpfs_fid_data cannot be larger than struct fid");
node = VP_TO_TMPFS_NODE(ap->a_vp);
- fhp = ap->a_fhp;
- fhp->fid_len = sizeof(tfd);
-
- /*
- * Copy into fid_data from the stack to avoid unaligned pointer use.
- * See the comment in sys/mount.h on struct fid for details.
- */
- tfd.tfd_id = node->tn_id;
- tfd.tfd_gen = node->tn_gen;
- memcpy(fhp->fid_data, &tfd, fhp->fid_len);
+ tfd->tfd_len = sizeof(*tfd);
+ tfd->tfd_gen = node->tn_gen;
+ tfd->tfd_id = node->tn_id;
return (0);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jan 8, 6:50 PM (1 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15725450
Default Alt Text
D47956.diff (2 KB)
Attached To
Mode
D47956: tmpfs: Rework file handles
Attached
Detach File
Event Timeline
Log In to Comment