diff -urN fsarchiver-0.6.8-a/src/devinfo.c fsarchiver-0.6.8-b/src/devinfo.c --- fsarchiver-0.6.8-a/src/devinfo.c 2010-02-19 22:38:33.000000000 +0000 +++ fsarchiver-0.6.8-b/src/devinfo.c 2010-02-28 16:42:04.000000000 +0000 @@ -35,7 +35,7 @@ #include "fs_ext2.h" #include "error.h" -int get_devinfo(struct s_devinfo *outdev, char *indevname) +int get_devinfo(struct s_devinfo *outdev, char *indevname, int min, int maj) { char sysblkdevname[512]; blkid_tag_iterate iter; @@ -67,10 +67,28 @@ // get short name ("/dev/sda1" -> "sda1") snprintf(outdev->devname, sizeof(outdev->devname), "%s", indevname+5); // skip "/dev/" + // get long name if there is one (eg: LVM / devmapper) + snprintf(outdev->longname, sizeof(outdev->longname), "%s", indevname); + if ((dirdesc=opendir("/dev/mapper"))!=NULL) + { + found=false; + while (((dir=readdir(dirdesc)) != NULL) && found==false) + { + snprintf(temp, sizeof(temp), "/dev/mapper/%s", dir->d_name); + if ((stat64(temp, &statbuf)==0) && S_ISBLK(statbuf.st_mode) && + (major(statbuf.st_rdev)==maj) && (minor(statbuf.st_rdev)==min)) + { + snprintf(outdev->longname, sizeof(outdev->longname), "%s", temp); + found=true; + } + } + closedir(dirdesc); + } + // get device basic info (size, major, minor) - if (((fd=open64(indevname, O_RDONLY|O_LARGEFILE))<0) || + if (((fd=open64(outdev->longname, O_RDONLY|O_LARGEFILE))<0) || ((outdev->devsize=lseek64(fd, 0, SEEK_END))<0) || - (stat64(indevname, &statbuf)!=0) || + (fstat64(fd, &statbuf)!=0) || (!S_ISBLK(statbuf.st_mode)) || (close(fd)<0)) return -1; @@ -106,7 +124,7 @@ blkid_cache cache = NULL; if (blkid_get_cache(&cache, NULL) < 0) return -1; - if ((dev=blkid_get_dev(cache, indevname, BLKID_DEV_NORMAL))!=NULL) + if ((dev=blkid_get_dev(cache, outdev->longname, BLKID_DEV_NORMAL))!=NULL) { iter = blkid_tag_iterate_begin(dev); while (blkid_tag_next(iter, &type, &value)==0) @@ -123,7 +141,7 @@ // workaround: blkid < 1.41 don't know ext4 and say it is ext3 instead if (strcmp(outdev->fsname, "ext3")==0) { - if (ext3_test(indevname)==true) + if (ext3_test(outdev->longname)==true) snprintf(outdev->fsname, sizeof(outdev->fsname), "ext3"); else // cannot run ext4_test(): it would fail on an ext4 when e2fsprogs < 1.41 snprintf(outdev->fsname, sizeof(outdev->fsname), "ext4"); @@ -131,22 +149,5 @@ } blkid_put_cache(cache); // free memory allocated by blkid_get_cache - // get long name if there is one (eg: LVM / devmapper) - snprintf(outdev->longname, sizeof(outdev->longname), "%s", indevname); - if ((dirdesc=opendir("/dev/mapper"))!=NULL) - { - found=false; - while (((dir=readdir(dirdesc)) != NULL) && found==false) - { - snprintf(temp, sizeof(temp), "/dev/mapper/%s", dir->d_name); - if ((stat64(temp, &statbuf)==0) && S_ISBLK(statbuf.st_mode) && (statbuf.st_rdev==outdev->rdev)) - { - snprintf(outdev->longname, sizeof(outdev->longname), "%s", temp); - found=true; - } - } - closedir(dirdesc); - } - return 0; } diff -urN fsarchiver-0.6.8-a/src/devinfo.h fsarchiver-0.6.8-b/src/devinfo.h --- fsarchiver-0.6.8-a/src/devinfo.h 2010-02-19 22:38:33.000000000 +0000 +++ fsarchiver-0.6.8-b/src/devinfo.h 2010-02-28 16:42:04.000000000 +0000 @@ -36,6 +36,6 @@ u64 rdev; }; -int get_devinfo(struct s_devinfo *outdev, char *indevname); +int get_devinfo(struct s_devinfo *outdev, char *indevname, int min, int maj); #endif // __DEVINFO_H__ diff -urN fsarchiver-0.6.8-a/src/fs_ntfs.c fsarchiver-0.6.8-b/src/fs_ntfs.c --- fsarchiver-0.6.8-a/src/fs_ntfs.c 2010-02-19 22:38:33.000000000 +0000 +++ fsarchiver-0.6.8-b/src/fs_ntfs.c 2010-02-28 16:42:04.000000000 +0000 @@ -94,7 +94,7 @@ } // get device label from common code in libbklid - if (get_devinfo(&devinfo, devname)!=0) + if (get_devinfo(&devinfo, devname, -1, -1)!=0) { errprintf("get_devinfo(%s) failed\n", devname); return -1; } diff -urN fsarchiver-0.6.8-a/src/oper_probe.c fsarchiver-0.6.8-b/src/oper_probe.c --- fsarchiver-0.6.8-a/src/oper_probe.c 2010-02-19 22:38:33.000000000 +0000 +++ fsarchiver-0.6.8-b/src/oper_probe.c 2010-02-28 16:42:04.000000000 +0000 @@ -89,7 +89,7 @@ if ((strlen(devname)==0) || (atoi(major)==0 && atoi(minor)==0)) continue; snprintf(longname, sizeof(longname), "/dev/%s", devname); - if (get_devinfo(&tmpdev, longname)!=0) + if (get_devinfo(&tmpdev, longname, atoi(minor), atoi(major))!=0) continue; // to to the next part // check that this device is not already in the list @@ -136,8 +136,8 @@ struct s_diskinfo partinfo[]= { {false, "[%-16s] ", "[=====DEVICE=====] "}, - {false, "[%-11s] ", "[==FILESYS==] "}, - {false, "[%-17s] ", "[======LABEL======] "}, + {false, "[%-11.11s] ", "[==FILESYS==] "}, + {false, "[%-17.17s] ", "[======LABEL======] "}, {false, "[%12s] ", "[====SIZE====] "}, {false, "[%3s] ", "[MAJ] "}, {false, "[%3s] ", "[MIN] "},