[Ocfs2-tools-devel] [PATCH 14/14] ocfs2-tools: mount not showing fully resolved path
Junxiao Bi
junxiao.bi at oracle.com
Wed Apr 13 01:30:03 PDT 2016
On 04/13/2016 04:12 PM, Joseph Qi wrote:
> Hi Junxiao,
>
> On 2016/4/1 11:10, Junxiao Bi wrote:
>> From: Srinivas Eeda <srinivas.eeda at oracle.com>
>>
>> In /etc/mtab, device path is not fully resolved because fgets return code
>> checked incorrectly. Device path is getting set to /dev/dm-X instead of
>> /dev/mapper/xxx.
>>
>> Signed-off-by: Srinivas Eeda <srinivas.eeda at oracle.com>
>> Reviewed-by: Junxiao Bi <junxiao.bi at oracle.com>
>> ---
>> mount.ocfs2/sundries.c | 6 +++---
>> 1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/mount.ocfs2/sundries.c b/mount.ocfs2/sundries.c
>> index 2e1b95a24214..c4e9ccd86e23 100644
>> --- a/mount.ocfs2/sundries.c
>> +++ b/mount.ocfs2/sundries.c
>> @@ -235,7 +235,7 @@ canonicalize_dm_name(const char *ptname)
>> FILE *f;
>> size_t sz;
>> char path[256], name[256], *res = NULL;
>> - int err;
>> + char *ret;
>>
>> snprintf(path, sizeof(path), "/sys/block/%s/dm/name", ptname);
>> f = fopen(path, "r");
>> @@ -243,9 +243,9 @@ canonicalize_dm_name(const char *ptname)
>> return NULL;
>>
>> /* read "<name>\n" from sysfs */
>> - err = fgets(name, sizeof(name), f);
>> + ret = fgets(name, sizeof(name), f);
>> sz = strlen(name);
>> - if (!err && sz > 1) {
>> + if (ret && sz > 1) {
> Should it be "!ret && sz > 1"?
No, fgets() return the buffer for success or null for failure.
Thanks,
Junxiao.
> I have also fixed this issue in my patchset "fix build warnings".
> https://oss.oracle.com/pipermail/ocfs2-tools-devel/2016-March/004337.html
> And now it is queued in my github repo and I am planning to push it to
> Mark's repo this week.
>
> Thanks,
> Joseph
>> name[sz - 1] = '\0';
>> snprintf(path, sizeof(path), "/dev/mapper/%s", name);
>> res = strdup(path);
>>
>
>
More information about the Ocfs2-tools-devel
mailing list