xfs
[Top] [All Lists]

[PATCH 12/15] xfs: make dir2 ftype offset pointers explicit

To: xfs@xxxxxxxxxxx
Subject: [PATCH 12/15] xfs: make dir2 ftype offset pointers explicit
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Tue, 29 Oct 2013 22:11:55 +1100
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1383045118-31107-1-git-send-email-david@xxxxxxxxxxxxx>
References: <1383045118-31107-1-git-send-email-david@xxxxxxxxxxxxx>
From: Dave Chinner <dchinner@xxxxxxxxxx>

Rather than hiding the ftype field size accounting inside the dirent
padding for the ".." and first entry offset functions for v2
directory formats, add explicit functions that calculate it
correctly.

Signed-off-by: Dave Chinner <dchinner@xxxxxxxxxx>
---
 fs/xfs/xfs_da_format.c | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/fs/xfs/xfs_da_format.c b/fs/xfs/xfs_da_format.c
index 5991b26..5a5767c 100644
--- a/fs/xfs/xfs_da_format.c
+++ b/fs/xfs/xfs_da_format.c
@@ -334,6 +334,25 @@ xfs_dir2_data_first_entry_p(
 }
 
 static struct xfs_dir2_data_entry *
+xfs_dir2_ftype_data_dotdot_entry_p(
+       struct xfs_dir2_data_hdr *hdr)
+{
+       return (struct xfs_dir2_data_entry *)
+               ((char *)hdr + sizeof(struct xfs_dir2_data_hdr) +
+                               XFS_DIR3_DATA_ENTSIZE(1));
+}
+
+static struct xfs_dir2_data_entry *
+xfs_dir2_ftype_data_first_entry_p(
+       struct xfs_dir2_data_hdr *hdr)
+{
+       return (struct xfs_dir2_data_entry *)
+               ((char *)hdr + sizeof(struct xfs_dir2_data_hdr) +
+                               XFS_DIR3_DATA_ENTSIZE(1) +
+                               XFS_DIR3_DATA_ENTSIZE(2));
+}
+
+static struct xfs_dir2_data_entry *
 xfs_dir3_data_dot_entry_p(
        struct xfs_dir2_data_hdr *hdr)
 {
@@ -762,8 +781,8 @@ const struct xfs_dir_ops xfs_dir2_ftype_ops = {
        .data_entry_offset = sizeof(struct xfs_dir2_data_hdr),
 
        .data_dot_entry_p = xfs_dir2_data_dot_entry_p,
-       .data_dotdot_entry_p = xfs_dir2_data_dotdot_entry_p,
-       .data_first_entry_p = xfs_dir2_data_first_entry_p,
+       .data_dotdot_entry_p = xfs_dir2_ftype_data_dotdot_entry_p,
+       .data_first_entry_p = xfs_dir2_ftype_data_first_entry_p,
        .data_entry_p = xfs_dir2_data_entry_p,
        .data_unused_p = xfs_dir2_data_unused_p,
 
-- 
1.8.4.rc3

<Prev in Thread] Current Thread [Next in Thread>