source:
npl/system/klibc/patches/readlink-add-f-option.patch
@
892871d
Last change on this file since 892871d was c5c522c, checked in by , 8 years ago | |
---|---|
|
|
File size: 1.3 KB |
-
usr/utils/readlink.c
From: Ben Hutchings <ben@decadent.org.uk> Date: Sat, 27 Sep 2014 15:18:21 +0100 Subject: readlink: Add -f option Bug-Debian: https://bugs.debian.org/763049 Forwarded: http://www.zytor.com/pipermail/klibc/2016-January/003886.html This is needed to support mounting non-root filesystems in initramfs-tools. Signed-off-by: Ben Hutchings <ben@decadent.org.uk> ---
a b const char *progname; 7 7 8 8 static __noreturn usage(void) 9 9 { 10 fprintf(stderr, "Usage: %s link...\n", progname);10 fprintf(stderr, "Usage: %s [-f] link...\n", progname); 11 11 exit(1); 12 12 } 13 13 14 14 int main(int argc, char *argv[]) 15 15 { 16 int c, f_flag = 0; 16 17 const char *name; 17 18 char link_name[PATH_MAX]; 18 19 int rv; 19 20 int i; 20 21 21 progname = *argv++;22 progname = argv[0]; 22 23 23 if (argc < 2) 24 do { 25 c = getopt(argc, argv, "f"); 26 if (c == EOF) 27 break; 28 switch (c) { 29 case 'f': 30 f_flag = 1; 31 break; 32 33 case '?': 34 fprintf(stderr, "%s: invalid option -%c\n", 35 progname, optopt); 36 usage(); 37 } 38 } while (1); 39 40 if (optind == argc) 24 41 usage(); 25 42 43 argv += optind; 26 44 while ((name = *argv++)) { 27 rv = readlink(name, link_name, sizeof link_name - 1); 45 if (f_flag) 46 rv = realpath(name, link_name) ? strlen(link_name) : -1; 47 else 48 rv = readlink(name, link_name, sizeof link_name - 1); 28 49 if (rv < 0) { 29 50 perror(name); 30 51 exit(1);
Note: See TracBrowser
for help on using the repository browser.