2 * devname.c --- Support function to translate a user provided string
3 * identifying a device to an actual device path
5 * Copyright (C) 2022 Red Hat, Inc., Lukas Czerner <lczerner@redhat.com>
8 * This file may be redistributed under the terms of the GNU Public
19 #include "nls-enable.h"
22 * blkid_get_devname() is primarily intended for parsing "NAME=value"
23 * tokens. It will return the device matching the specified token, NULL if
24 * nothing is found, or copy of the string if it's not in "NAME=value"
26 * get_devname() takes the same parameters and works the same way as
27 * blkid_get_devname() except it can handle '=' in the file name.
29 char *get_devname(blkid_cache cache
, const char *token
, const char *value
)
38 ret
= blkid_get_devname(cache
, token
, value
);
42 if (access(token
, F_OK
) == 0)
45 ret
= blkid_get_devname(cache
, token
, NULL
);
48 * In case of collision prefer the result from
49 * blkid_get_devname() to avoid a file masking file system with
52 if (is_file
&& (strcmp(ret
, token
) != 0)) {
54 _("Collision found: '%s' refers to both '%s' "
55 "and a file '%s'. Using '%s'!\n"),
56 token
, ret
, token
, ret
);