volume_id: code shrink
function old new delta resolve_mount_spec 87 158 +71 mount_main 1211 1219 +8 fsck_device 453 451 -2 findfs_main 76 74 -2 blkid_main 41 39 -2 display_uuid_cache 109 105 -4 get_devname_from_uuid 56 - -56 get_devname_from_label 62 - -62 ------------------------------------------------------------------------------ (add/remove: 0/2 grow/shrink: 2/4 up/down: 79/-128) Total: -49 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
@@ -17,16 +17,16 @@
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
int FAST_FUNC add_to_uuid_cache(const char *device);
|
||||
void FAST_FUNC display_uuid_cache(int scan_devices);
|
||||
|
||||
char *get_devname_from_label(const char *spec);
|
||||
char *get_devname_from_uuid(const char *spec);
|
||||
void display_uuid_cache(int scan_devices);
|
||||
|
||||
//static: char *get_devname_from_label(const char *spec);
|
||||
//static: char *get_devname_from_uuid(const char *spec);
|
||||
/* Returns:
|
||||
* 0: no UUID= or LABEL= prefix found
|
||||
* 1: UUID= or LABEL= prefix found. In this case,
|
||||
* *fsname is replaced if device with such UUID or LABEL is found.
|
||||
* The new string is malloced. The old string is NOT freed!
|
||||
* *fsname is NOT replaced in "LABEL=notfound" case! [FIXME: return 2 in this case to make distinguishable?]
|
||||
*/
|
||||
int resolve_mount_spec(char **fsname);
|
||||
int add_to_uuid_cache(const char *device);
|
||||
int FAST_FUNC resolve_mount_spec(char **fsname);
|
||||
|
||||
@@ -47,12 +47,13 @@ int findfs_main(int argc UNUSED_PARAM, char **argv)
|
||||
/* Otherwise, handle LABEL=xxx and UUID=xxx,
|
||||
* fail on anything else */
|
||||
if (!resolve_mount_spec(argv))
|
||||
bb_show_usage();
|
||||
bb_show_usage(); /* not in LABEL= or UUID= form */
|
||||
}
|
||||
|
||||
if (*argv != dev) {
|
||||
puts(*argv);
|
||||
return 0;
|
||||
}
|
||||
// util-linux 2.41.1 says: "findfs: unable to resolve 'LABEL=bogus'"
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -230,7 +230,8 @@ get_spec_by_volume_label(const char *s, int *major, int *minor)
|
||||
#endif // UNUSED
|
||||
|
||||
/* Used by blkid */
|
||||
void display_uuid_cache(int scan_devices)
|
||||
|
||||
void FAST_FUNC display_uuid_cache(int scan_devices)
|
||||
{
|
||||
struct uuidCache_s *uc;
|
||||
|
||||
@@ -250,7 +251,7 @@ void display_uuid_cache(int scan_devices)
|
||||
}
|
||||
}
|
||||
|
||||
int add_to_uuid_cache(const char *device)
|
||||
int FAST_FUNC add_to_uuid_cache(const char *device)
|
||||
{
|
||||
char *uuid = uuid; /* for compiler */
|
||||
char *label = label;
|
||||
@@ -272,10 +273,8 @@ int add_to_uuid_cache(const char *device)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Used by mount and findfs */
|
||||
|
||||
char *get_devname_from_label(const char *spec)
|
||||
/* Used by mount, findfs, swapon, fsck */
|
||||
static char *get_devname_from_label(const char *spec)
|
||||
{
|
||||
struct uuidCache_s *uc;
|
||||
|
||||
@@ -288,8 +287,7 @@ char *get_devname_from_label(const char *spec)
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *get_devname_from_uuid(const char *spec)
|
||||
static char *get_devname_from_uuid(const char *spec)
|
||||
{
|
||||
struct uuidCache_s *uc;
|
||||
|
||||
@@ -303,15 +301,14 @@ char *get_devname_from_uuid(const char *spec)
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int resolve_mount_spec(char **fsname)
|
||||
int FAST_FUNC resolve_mount_spec(char **fsname)
|
||||
{
|
||||
char *tmp = *fsname;
|
||||
|
||||
if (is_prefixed_with(*fsname, "UUID="))
|
||||
tmp = get_devname_from_uuid(*fsname + 5);
|
||||
else if (is_prefixed_with(*fsname, "LABEL="))
|
||||
tmp = get_devname_from_label(*fsname + 6);
|
||||
if (is_prefixed_with(tmp, "UUID="))
|
||||
tmp = get_devname_from_uuid(tmp + 5);
|
||||
else if (is_prefixed_with(tmp, "LABEL="))
|
||||
tmp = get_devname_from_label(tmp + 6);
|
||||
|
||||
if (tmp == *fsname)
|
||||
return 0; /* no UUID= or LABEL= prefix found */
|
||||
|
||||
Reference in New Issue
Block a user