Opened 11 years ago

Closed 11 years ago

#696 closed defect (fixed)

LVM check

Reported by: victor gattegno Owned by: Bruno Cornec
Priority: normal Milestone: 3.0.4
Component: mondo Version: 3.0.3
Severity: normal Keywords: LVM
Cc: victor gattegno, rue

Description

About mondo 3.0.3, in libmondo-devices.c, line 1909 :

mr_asprintf(&command, "mount 2>/dev/null|grep -E \"/dev/mapper/%s-|/dev/%s/\"|awk '{printf(\"%%s \",$3)}END{print \"\"}'", VG, VG);

I think that it should be :

mr_asprintf(&command, "mount 2>/dev/null|grep -E \"/dev/mapper/%s|/dev/%s\"|awk '{printf(\"%%s \",$3)}END{print \"\"}'", VG, VG);

Change History (4)

comment:1 by victor gattegno, 11 years ago

Sorry, it was right, if we have for example /dev/mapper/VGDD0-LVDD0 then %s=VGDD0.

But, after awk, shouldn't it be the following ?

(print instead of printf, and I added a third VG for the third %s)

mr_asprintf(&command, "mount 2>/dev/null|grep -E \"/dev/mapper/%s-|/dev/%s/\"|awk '{print(\"%%s \",$3)}END{print \"\"}'", VG, VG, VG);

Example :

# mount 2>/dev/null|grep -E "/dev/mapper/VGDD0-|/dev/VGDD0/"
/dev/mapper/VGDD0-LVDD0 on /mnt/data0 type ext3 (rw)

# mount 2>/dev/null|grep -E "/dev/mapper/VGDD0-|/dev/VGDD0/" |awk '{print("%VGDD0 ",$3)}END{print ""}' 
%VGDD0  /mnt/data0
Version 3, edited 11 years ago by victor gattegno (previous) (next) (diff)

comment:2 by victor gattegno, 11 years ago

Also I don't see why %%s in the awk, instead, it should be %s

Example, with %%s we get a wrong result:

# mount 2>/dev/null|grep -E "/dev/mapper/VGDD" |awk '{printf("%%s ", $3)}END{print ""}'
%s %s %s %s 

And with %s we get the good result:

# mount 2>/dev/null|grep -E "/dev/mapper/VGDD" |awk '{printf("%s ", $3)}END{print ""}' 
/mnt/data0 /mnt/data1 /mnt/data2 /mnt/data3
Last edited 11 years ago by victor gattegno (previous) (diff)

comment:3 by victor gattegno, 11 years ago

So two modifications should be done, if you agree.

Last edited 11 years ago by victor gattegno (previous) (diff)

comment:4 by Bruno Cornec, 11 years ago

Resolution: fixed
Status: newclosed

I agree with the first one, not the second. For the second in C, you need to prepend a % by another % sign to be correct, thus the double %%

Wrt the first part, it is now in rev [3152], thanks for tracking it down !

Note: See TracTickets for help on using tickets.