add HUGE sample uClibc for full LTP
[buildroot.git] / package / busybox / busybox-1.7.0-readlink.patch
blob56596336f201ef26b9a66c8cf987060c731d513d
1 diff -urN busybox-1.7.0/applets/applets.c busybox-1.7.0-readlink/applets/applets.c
2 --- busybox-1.7.0/applets/applets.c 2007-08-24 11:50:02.000000000 +0100
3 +++ busybox-1.7.0-readlink/applets/applets.c 2007-09-06 17:41:38.000000000 +0100
4 @@ -546,7 +546,7 @@
5 help:
6 output_width = 80;
7 if (ENABLE_FEATURE_AUTOWIDTH) {
8 - /* Obtain the terminal width. */
9 + /* Obtain the terminal width */
10 get_terminal_width_height(0, &output_width, NULL);
12 /* leading tab and room to wrap */
13 @@ -580,12 +580,11 @@
15 if (ENABLE_FEATURE_INSTALLER && strcmp(argv[1], "--install") == 0) {
16 const char *busybox;
17 - busybox = xmalloc_readlink_or_warn(bb_busybox_exec_path);
18 + busybox = xmalloc_readlink(bb_busybox_exec_path);
19 if (!busybox)
20 busybox = bb_busybox_exec_path;
21 /* -s makes symlinks */
22 - install_links(busybox,
23 - argv[2] && strcmp(argv[2], "-s") == 0);
24 + install_links(busybox, argv[2] && strcmp(argv[2], "-s") == 0);
25 return 0;
28 diff -urN busybox-1.7.0/include/libbb.h busybox-1.7.0-readlink/include/libbb.h
29 --- busybox-1.7.0/include/libbb.h 2007-08-24 11:49:55.000000000 +0100
30 +++ busybox-1.7.0-readlink/include/libbb.h 2007-09-06 17:41:38.000000000 +0100
31 @@ -248,9 +248,10 @@
32 DIR *xopendir(const char *path);
33 DIR *warn_opendir(const char *path);
35 -char *xrealloc_getcwd_or_warn(char *cwd);
36 +/* UNUSED: char *xmalloc_realpath(const char *path); */
37 +char *xmalloc_readlink(const char *path);
38 char *xmalloc_readlink_or_warn(const char *path);
39 -char *xmalloc_realpath(const char *path);
40 +char *xrealloc_getcwd_or_warn(char *cwd);
43 //TODO: signal(sid, f) is the same? then why?
44 @@ -316,8 +317,8 @@
46 /* Create stream socket, and allocate suitable lsa.
47 * (lsa of correct size and lsa->sa.sa_family (AF_INET/AF_INET6))
48 - * af == AF_UNSPEC will result in trying to create IPv6, and
49 - * if kernel doesn't support it, IPv4.
50 + * af == AF_UNSPEC will result in trying to create IPv6 socket,
51 + * and if kernel doesn't support it, IPv4.
53 int xsocket_type(len_and_sockaddr **lsap, USE_FEATURE_IPV6(int af,) int sock_type);
54 int xsocket_stream(len_and_sockaddr **lsap);
55 diff -urN busybox-1.7.0/libbb/xreadlink.c busybox-1.7.0-readlink/libbb/xreadlink.c
56 --- busybox-1.7.0/libbb/xreadlink.c 2007-08-24 11:49:51.000000000 +0100
57 +++ busybox-1.7.0-readlink/libbb/xreadlink.c 2007-09-06 17:41:38.000000000 +0100
58 @@ -10,8 +10,7 @@
59 * NOTE: This function returns a malloced char* that you will have to free
60 * yourself. You have been warned.
63 -char *xmalloc_readlink_or_warn(const char *path)
64 +char *xmalloc_readlink(const char *path)
66 enum { GROWBY = 80 }; /* how large we will grow strings by */
68 @@ -20,20 +19,30 @@
70 do {
71 buf = xrealloc(buf, bufsize += GROWBY);
72 - readsize = readlink(path, buf, bufsize); /* 1st try */
73 + readsize = readlink(path, buf, bufsize);
74 if (readsize == -1) {
75 - bb_perror_msg("%s", path);
76 free(buf);
77 return NULL;
79 - }
80 - while (bufsize < readsize + 1);
81 + } while (bufsize < readsize + 1);
83 buf[readsize] = '\0';
85 return buf;
88 +char *xmalloc_readlink_or_warn(const char *path)
90 + char *buf = xmalloc_readlink(path);
91 + if (!buf) {
92 + /* EINVAL => "file: Invalid argument" => puzzled user */
93 + bb_error_msg("%s: cannot read link (not a symlink?)", path);
94 + }
95 + return buf;
98 +/* UNUSED */
99 +#if 0
100 char *xmalloc_realpath(const char *path)
102 #if defined(__GLIBC__) && !defined(__UCLIBC__)
103 @@ -46,3 +55,4 @@
104 return xstrdup(realpath(path, buf));
105 #endif
107 +#endif