1 diff -urN fsarchiver-0.6.8-a/src/devinfo.c fsarchiver-0.6.8-b/src/devinfo.c
2 --- fsarchiver-0.6.8-a/src/devinfo.c 2010-02-19 22:38:33.000000000 +0000
3 +++ fsarchiver-0.6.8-b/src/devinfo.c 2010-02-28 16:42:04.000000000 +0000
8 -int get_devinfo(struct s_devinfo *outdev, char *indevname)
9 +int get_devinfo(struct s_devinfo *outdev, char *indevname, int min, int maj)
11 char sysblkdevname[512];
12 blkid_tag_iterate iter;
14 // get short name ("/dev/sda1" -> "sda1")
15 snprintf(outdev->devname, sizeof(outdev->devname), "%s", indevname+5); // skip "/dev/"
17 + // get long name if there is one (eg: LVM / devmapper)
18 + snprintf(outdev->longname, sizeof(outdev->longname), "%s", indevname);
19 + if ((dirdesc=opendir("/dev/mapper"))!=NULL)
22 + while (((dir=readdir(dirdesc)) != NULL) && found==false)
24 + snprintf(temp, sizeof(temp), "/dev/mapper/%s", dir->d_name);
25 + if ((stat64(temp, &statbuf)==0) && S_ISBLK(statbuf.st_mode) &&
26 + (major(statbuf.st_rdev)==maj) && (minor(statbuf.st_rdev)==min))
28 + snprintf(outdev->longname, sizeof(outdev->longname), "%s", temp);
35 // get device basic info (size, major, minor)
36 - if (((fd=open64(indevname, O_RDONLY|O_LARGEFILE))<0) ||
37 + if (((fd=open64(outdev->longname, O_RDONLY|O_LARGEFILE))<0) ||
38 ((outdev->devsize=lseek64(fd, 0, SEEK_END))<0) ||
39 - (stat64(indevname, &statbuf)!=0) ||
40 + (fstat64(fd, &statbuf)!=0) ||
41 (!S_ISBLK(statbuf.st_mode)) ||
45 blkid_cache cache = NULL;
46 if (blkid_get_cache(&cache, NULL) < 0)
48 - if ((dev=blkid_get_dev(cache, indevname, BLKID_DEV_NORMAL))!=NULL)
49 + if ((dev=blkid_get_dev(cache, outdev->longname, BLKID_DEV_NORMAL))!=NULL)
51 iter = blkid_tag_iterate_begin(dev);
52 while (blkid_tag_next(iter, &type, &value)==0)
54 // workaround: blkid < 1.41 don't know ext4 and say it is ext3 instead
55 if (strcmp(outdev->fsname, "ext3")==0)
57 - if (ext3_test(indevname)==true)
58 + if (ext3_test(outdev->longname)==true)
59 snprintf(outdev->fsname, sizeof(outdev->fsname), "ext3");
60 else // cannot run ext4_test(): it would fail on an ext4 when e2fsprogs < 1.41
61 snprintf(outdev->fsname, sizeof(outdev->fsname), "ext4");
64 blkid_put_cache(cache); // free memory allocated by blkid_get_cache
66 - // get long name if there is one (eg: LVM / devmapper)
67 - snprintf(outdev->longname, sizeof(outdev->longname), "%s", indevname);
68 - if ((dirdesc=opendir("/dev/mapper"))!=NULL)
71 - while (((dir=readdir(dirdesc)) != NULL) && found==false)
73 - snprintf(temp, sizeof(temp), "/dev/mapper/%s", dir->d_name);
74 - if ((stat64(temp, &statbuf)==0) && S_ISBLK(statbuf.st_mode) && (statbuf.st_rdev==outdev->rdev))
76 - snprintf(outdev->longname, sizeof(outdev->longname), "%s", temp);
85 diff -urN fsarchiver-0.6.8-a/src/devinfo.h fsarchiver-0.6.8-b/src/devinfo.h
86 --- fsarchiver-0.6.8-a/src/devinfo.h 2010-02-19 22:38:33.000000000 +0000
87 +++ fsarchiver-0.6.8-b/src/devinfo.h 2010-02-28 16:42:04.000000000 +0000
92 -int get_devinfo(struct s_devinfo *outdev, char *indevname);
93 +int get_devinfo(struct s_devinfo *outdev, char *indevname, int min, int maj);
95 #endif // __DEVINFO_H__
96 diff -urN fsarchiver-0.6.8-a/src/fs_ntfs.c fsarchiver-0.6.8-b/src/fs_ntfs.c
97 --- fsarchiver-0.6.8-a/src/fs_ntfs.c 2010-02-19 22:38:33.000000000 +0000
98 +++ fsarchiver-0.6.8-b/src/fs_ntfs.c 2010-02-28 16:42:04.000000000 +0000
102 // get device label from common code in libbklid
103 - if (get_devinfo(&devinfo, devname)!=0)
104 + if (get_devinfo(&devinfo, devname, -1, -1)!=0)
105 { errprintf("get_devinfo(%s) failed\n", devname);
108 diff -urN fsarchiver-0.6.8-a/src/oper_probe.c fsarchiver-0.6.8-b/src/oper_probe.c
109 --- fsarchiver-0.6.8-a/src/oper_probe.c 2010-02-19 22:38:33.000000000 +0000
110 +++ fsarchiver-0.6.8-b/src/oper_probe.c 2010-02-28 16:42:04.000000000 +0000
112 if ((strlen(devname)==0) || (atoi(major)==0 && atoi(minor)==0))
114 snprintf(longname, sizeof(longname), "/dev/%s", devname);
115 - if (get_devinfo(&tmpdev, longname)!=0)
116 + if (get_devinfo(&tmpdev, longname, atoi(minor), atoi(major))!=0)
117 continue; // to to the next part
119 // check that this device is not already in the list
121 struct s_diskinfo partinfo[]=
123 {false, "[%-16s] ", "[=====DEVICE=====] "},
124 - {false, "[%-11s] ", "[==FILESYS==] "},
125 - {false, "[%-17s] ", "[======LABEL======] "},
126 + {false, "[%-11.11s] ", "[==FILESYS==] "},
127 + {false, "[%-17.17s] ", "[======LABEL======] "},
128 {false, "[%12s] ", "[====SIZE====] "},
129 {false, "[%3s] ", "[MAJ] "},
130 {false, "[%3s] ", "[MIN] "},