btrfs-progs: btrfs_scan_block_devices is unused function delete it
authorAnand Jain <anand.jain@oracle.com>
Tue, 7 Oct 2014 00:08:31 +0000 (08:08 +0800)
committerDavid Sterba <dsterba@suse.cz>
Thu, 14 May 2015 13:41:06 +0000 (15:41 +0200)
After Patch:
 remove BTRFS_SCAN_PROC scan method
There isn't any consumer for btrfs_scan_block_devices() so delete it.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
utils.c
utils.h

diff --git a/utils.c b/utils.c
index b175b01..4b8a826 100644 (file)
--- a/utils.c
+++ b/utils.c
@@ -1709,94 +1709,6 @@ int set_label(const char *btrfs_dev, const char *label)
        return ret;
 }
 
-int btrfs_scan_block_devices(int run_ioctl)
-{
-
-       struct stat st;
-       int ret;
-       int fd;
-       struct btrfs_fs_devices *tmp_devices;
-       u64 num_devices;
-       FILE *proc_partitions;
-       int i;
-       char buf[1024];
-       char fullpath[110];
-       int scans = 0;
-       int special;
-
-scan_again:
-       proc_partitions = fopen("/proc/partitions","r");
-       if (!proc_partitions) {
-               fprintf(stderr, "Unable to open '/proc/partitions' for scanning\n");
-               return -ENOENT;
-       }
-       /* skip the header */
-       for (i = 0; i < 2; i++)
-               if (!fgets(buf, 1023, proc_partitions)) {
-                       fprintf(stderr,
-                               "Unable to read '/proc/partitions' for scanning\n");
-                       fclose(proc_partitions);
-                       return -ENOENT;
-               }
-
-       strcpy(fullpath,"/dev/");
-       while(fgets(buf, 1023, proc_partitions)) {
-               ret = sscanf(buf," %*d %*d %*d %99s", fullpath + 5);
-               if (ret != 1) {
-                       fprintf(stderr,
-                               "failed to scan device name from /proc/partitions\n");
-                       break;
-               }
-
-               /*
-                * multipath and MD devices may register as a btrfs filesystem
-                * both through the original block device and through
-                * the special (/dev/mapper or /dev/mdX) entry.
-                * This scans the special entries last
-                */
-               special = strncmp(fullpath, "/dev/dm-", strlen("/dev/dm-")) == 0;
-               if (!special)
-                       special = strncmp(fullpath, "/dev/md", strlen("/dev/md")) == 0;
-
-               if (scans == 0 && special)
-                       continue;
-               if (scans > 0 && !special)
-                       continue;
-
-               ret = lstat(fullpath, &st);
-               if (ret < 0) {
-                       fprintf(stderr, "failed to stat %s\n", fullpath);
-                       continue;
-               }
-               if (!S_ISBLK(st.st_mode)) {
-                       continue;
-               }
-
-               fd = open(fullpath, O_RDONLY);
-               if (fd < 0) {
-                       if (errno != ENOMEDIUM)
-                               fprintf(stderr, "failed to open %s: %s\n",
-                                       fullpath, strerror(errno));
-                       continue;
-               }
-               ret = btrfs_scan_one_device(fd, fullpath, &tmp_devices,
-                                           &num_devices,
-                                           BTRFS_SUPER_INFO_OFFSET, 0);
-               if (ret == 0 && run_ioctl > 0) {
-                       btrfs_register_one_device(fullpath);
-               }
-               close(fd);
-       }
-
-       fclose(proc_partitions);
-
-       if (scans == 0) {
-               scans++;
-               goto scan_again;
-       }
-       return 0;
-}
-
 /*
  * Unsafe subvolume check.
  *
diff --git a/utils.h b/utils.h
index b2748c0..5657c74 100644 (file)
--- a/utils.h
+++ b/utils.h
@@ -121,7 +121,6 @@ int pretty_size_snprintf(u64 size, char *str, size_t str_bytes, unsigned unit_mo
        })
 
 int get_mountpt(char *dev, char *mntpt, size_t size);
-int btrfs_scan_block_devices(int run_ioctl);
 u64 parse_size(char *s);
 u64 parse_qgroupid(const char *p);
 u64 arg_strtou64(const char *str);