xfs
[Top] [All Lists]

[PATCH 4/7] libxcmd: fix mount option parsing to find rt/log devices

To: david@xxxxxxxxxxxxx, darrick.wong@xxxxxxxxxx
Subject: [PATCH 4/7] libxcmd: fix mount option parsing to find rt/log devices
From: "Darrick J. Wong" <darrick.wong@xxxxxxxxxx>
Date: Tue, 23 Aug 2016 19:24:50 -0700
Cc: linux-xfs@xxxxxxxxxxxxxxx, xfs@xxxxxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <147200546481.15538.12724000421579716885.stgit@xxxxxxxxxxxxxxxx>
References: <147200546481.15538.12724000421579716885.stgit@xxxxxxxxxxxxxxxx>
User-agent: StGit/0.17.1-dirty
It turns out that glibc's hasmntopt implementation returns NULL
if the opt parameter ends with an equals ('=').  Therefore, we
cannot directly search for the option 'rtdev='; we must instead
have hasmntopt look for 'rtdev' and look for the trailing equals
sign ourselves.  This fixes xfs_info's reporting of external
log and realtime device paths, and xfs_scrub will need it for
data block scrubbing of realtime extents.

Signed-off-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx>
---
 libxcmd/paths.c |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)


diff --git a/libxcmd/paths.c b/libxcmd/paths.c
index 71af25f..b08985f 100644
--- a/libxcmd/paths.c
+++ b/libxcmd/paths.c
@@ -234,10 +234,17 @@ fs_extract_mount_options(
 {
        char            *fslog, *fsrt;
 
-       /* Extract log device and realtime device from mount options */
-       if ((fslog = hasmntopt(mnt, "logdev=")))
+       /*
+        * Extract log device and realtime device from mount options.
+        *
+        * Note: the glibc hasmntopt implementation requires that the
+        * character in mnt_opts immediately after the search string
+        * must be a NULL ('\0'), a comma (','), or an equals ('=').
+        * Therefore we cannot search for 'logdev=' directly.
+        */
+       if ((fslog = hasmntopt(mnt, "logdev")) && fslog[6] == '=')
                fslog += 7;
-       if ((fsrt = hasmntopt(mnt, "rtdev=")))
+       if ((fsrt = hasmntopt(mnt, "rtdev")) && fsrt[5] == '=')
                fsrt += 6;
 
        /* Do this only after we've finished processing mount options */

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