initial commit: 1.5.0
[systemrescuecd.git] / portage-overlay / sys-fs / fsarchiver / files / fsarchiver-0.6.8-01-probe-lvm.patch
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
4 @@ -35,7 +35,7 @@
5  #include "fs_ext2.h"
6  #include "error.h"
7  
8 -int get_devinfo(struct s_devinfo *outdev, char *indevname)
9 +int get_devinfo(struct s_devinfo *outdev, char *indevname, int min, int maj)
10  {
11      char sysblkdevname[512];
12      blkid_tag_iterate iter;
13 @@ -67,10 +67,28 @@
14      // get short name ("/dev/sda1" -> "sda1")
15      snprintf(outdev->devname, sizeof(outdev->devname), "%s", indevname+5); // skip "/dev/"
16      
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)
20 +    {
21 +        found=false;
22 +        while (((dir=readdir(dirdesc)) != NULL) && found==false)
23 +        {
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))
27 +            {
28 +                snprintf(outdev->longname, sizeof(outdev->longname), "%s", temp);
29 +                found=true;
30 +            }
31 +        }
32 +        closedir(dirdesc);
33 +    }
34 +    
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)) ||
42          (close(fd)<0))
43          return -1;
44 @@ -106,7 +124,7 @@
45      blkid_cache cache = NULL;
46      if (blkid_get_cache(&cache, NULL) < 0)
47          return -1;
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)
50      {
51          iter = blkid_tag_iterate_begin(dev);
52          while (blkid_tag_next(iter, &type, &value)==0)
53 @@ -123,7 +141,7 @@
54          // workaround: blkid < 1.41 don't know ext4 and say it is ext3 instead
55          if (strcmp(outdev->fsname, "ext3")==0)
56          {
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");
62 @@ -131,22 +149,5 @@
63      }
64      blkid_put_cache(cache); // free memory allocated by blkid_get_cache
65      
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)
69 -    {
70 -        found=false;
71 -        while (((dir=readdir(dirdesc)) != NULL) && found==false)
72 -        {
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))
75 -            {   
76 -                snprintf(outdev->longname, sizeof(outdev->longname), "%s", temp);
77 -                found=true;
78 -            }
79 -        }
80 -        closedir(dirdesc);
81 -    }
82 -    
83      return 0;
84  }
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
88 @@ -36,6 +36,6 @@
89      u64  rdev;
90  };
91  
92 -int get_devinfo(struct s_devinfo *outdev, char *indevname);
93 +int get_devinfo(struct s_devinfo *outdev, char *indevname, int min, int maj);
94  
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
99 @@ -94,7 +94,7 @@
100      }
101      
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);
106          return -1;
107      }
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
111 @@ -89,7 +89,7 @@
112              if ((strlen(devname)==0) || (atoi(major)==0 && atoi(minor)==0))
113                  continue;
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
118              
119              // check that this device is not already in the list
120 @@ -136,8 +136,8 @@
121  struct s_diskinfo partinfo[]=
122  {
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] "},