• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/fstools/probe.c

  1 /*
  2  * Copyright (C) 2016 Jo-Philipp Wich <jo@mein.io>
  3  *
  4  * This program is free software; you can redistribute it and/or modify
  5  * it under the terms of the GNU Lesser General Public License version 2.1
  6  * as published by the Free Software Foundation
  7  *
  8  * This program is distributed in the hope that it will be useful,
  9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 11  * GNU General Public License for more details.
 12  */
 13 
 14 #include <string.h>
 15 #include <libubox/utils.h>
 16 
 17 #include "probe.h"
 18 #include "libblkid-tiny/libblkid-tiny.h"
 19 
 20 static struct probe_info *
 21 probe_path_tiny(const char *path)
 22 {
 23         struct probe_info *info = NULL;
 24         struct blkid_struct_probe *pr;
 25         char *type, *dev, *uuid, *label, *version;
 26 
 27         pr = blkidtiny_new_probe();
 28         if (!pr)
 29                 return NULL;
 30 
 31         if (probe_block((char *)path, pr) == 0 && pr->id && !pr->err) {
 32                 info = calloc_a(sizeof(*info),
 33                                 &type,    strlen(pr->id->name) + 1,
 34                                 &dev,     strlen(path)         + 1,
 35                                 &uuid,    strlen(pr->uuid)     + 1,
 36                                 &label,   strlen(pr->label)    + 1,
 37                                 &version, strlen(pr->version)  + 1);
 38 
 39                 if (info) {
 40                         info->type = strcpy(type, pr->id->name);
 41                         info->dev = strcpy(dev, path);
 42 
 43                         if (pr->uuid[0])
 44                                 info->uuid = strcpy(uuid, pr->uuid);
 45 
 46                         if (pr->label[0])
 47                                 info->label = strcpy(label, pr->label);
 48 
 49                         if (pr->version[0])
 50                                 info->version = strcpy(version, pr->version);
 51                 }
 52         }
 53 
 54         blkidtiny_free_probe(pr);
 55 
 56         return info;
 57 }
 58 
 59 struct probe_info *
 60 probe_path(const char *path)
 61 {
 62         struct probe_info *info;
 63 
 64         info = probe_path_tiny(path);
 65 
 66         if (!info)
 67                 info = probe_path_libblkid(path);
 68 
 69         return info;
 70 }
 71 
 72 int
 73 make_devs(void)
 74 {
 75         return mkblkdev();
 76 }
 77 

This page was automatically generated by LXR 0.3.1.  •  OpenWrt