This is needed to support mounting non-root filesystems in
initramfs-tools.
Signed-off-by: Ben Hutchings <ben at decadent.org.uk>
---
initramfs-tools 0.117 only works with busybox; this should allow it to
work with klibc again.
Ben.
--- a/usr/utils/readlink.c
+++ b/usr/utils/readlink.c
@@ -7,24 +7,45 @@ const char *progname;
static __noreturn usage(void)
{
- fprintf(stderr, "Usage: %s link...\n", progname);
+ fprintf(stderr, "Usage: %s [-f] link...\n", progname);
exit(1);
}
int main(int argc, char *argv[])
{
+ int c, f_flag = 0;
const char *name;
char link_name[PATH_MAX];
int rv;
int i;
- progname = *argv++;
+ progname = argv[0];
- if (argc < 2)
+ do {
+ c = getopt(argc, argv, "f");
+ if (c == EOF)
+ break;
+ switch (c) {
+ case 'f':
+ f_flag = 1;
+ break;
+
+ case '?':
+ fprintf(stderr, "%s: invalid option -%c\n",
+ progname, optopt);
+ usage();
+ }
+ } while (1);
+
+ if (optind == argc)
usage();
+ argv += optind;
while ((name = *argv++)) {
- rv = readlink(name, link_name, sizeof link_name - 1);
+ if (f_flag)
+ rv = realpath(name, link_name) ? strlen(link_name) : -1;
+ else
+ rv = readlink(name, link_name, sizeof link_name - 1);
if (rv < 0) {
perror(name);
exit(1);
--
Ben Hutchings
The two most common things in the universe are hydrogen and stupidity.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 811 bytes
Desc: This is a digitally signed message part
URL:
<http://www.zytor.com/pipermail/klibc/attachments/20140927/b0fbe20c/attachment.sig>