diff options
author | Eric Andersen <andersen@codepoet.org> | 2000-10-30 17:22:04 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2000-10-30 17:22:04 +0000 |
commit | ef936da7c5608c8cae553216f8661764247c2819 (patch) | |
tree | d7531d36a1dcd27c47d26707170c4711b0c73aae | |
parent | 3e07541e5fec215e2d61deb48e3dc1bb460babd1 (diff) | |
download | busybox-w32-ef936da7c5608c8cae553216f8661764247c2819.tar.gz busybox-w32-ef936da7c5608c8cae553216f8661764247c2819.tar.bz2 busybox-w32-ef936da7c5608c8cae553216f8661764247c2819.zip |
Fix uname problem that was breaking poweroff.
-rw-r--r-- | Changelog | 8 | ||||
-rw-r--r-- | mkswap.c | 18 | ||||
-rw-r--r-- | nfsmount.c | 18 | ||||
-rw-r--r-- | util-linux/mkswap.c | 18 | ||||
-rw-r--r-- | util-linux/nfsmount.c | 18 | ||||
-rw-r--r-- | utility.c | 4 |
6 files changed, 19 insertions, 65 deletions
@@ -1,3 +1,11 @@ | |||
1 | 0.48 | ||
2 | |||
3 | * Fixed uname problem causing the kernel version to be | ||
4 | mis-detected (causing problems with poweroff, init, | ||
5 | and other things). | ||
6 | |||
7 | -Erik Andersen | ||
8 | |||
1 | 0.47 | 9 | 0.47 |
2 | 10 | ||
3 | * A bug in syslogd was fixed that allowed it to potentially fork-bomb | 11 | * A bug in syslogd was fixed that allowed it to potentially fork-bomb |
@@ -63,20 +63,6 @@ static int version = -1; | |||
63 | 63 | ||
64 | #define MAKE_VERSION(p,q,r) (65536*(p) + 256*(q) + (r)) | 64 | #define MAKE_VERSION(p,q,r) (65536*(p) + 256*(q) + (r)) |
65 | 65 | ||
66 | static int linux_version_code(void) | ||
67 | { | ||
68 | struct utsname my_utsname; | ||
69 | int p, q, r; | ||
70 | |||
71 | if (uname(&my_utsname) == 0) { | ||
72 | p = atoi(strtok(my_utsname.release, ".")); | ||
73 | q = atoi(strtok(NULL, ".")); | ||
74 | r = atoi(strtok(NULL, ".")); | ||
75 | return MAKE_VERSION(p, q, r); | ||
76 | } | ||
77 | return 0; | ||
78 | } | ||
79 | |||
80 | /* | 66 | /* |
81 | * The definition of the union swap_header uses the constant PAGE_SIZE. | 67 | * The definition of the union swap_header uses the constant PAGE_SIZE. |
82 | * Unfortunately, on some architectures this depends on the hardware model, | 68 | * Unfortunately, on some architectures this depends on the hardware model, |
@@ -345,7 +331,7 @@ int mkswap_main(int argc, char **argv) | |||
345 | if (version == -1) { | 331 | if (version == -1) { |
346 | if (PAGES <= V0_MAX_PAGES) | 332 | if (PAGES <= V0_MAX_PAGES) |
347 | version = 0; | 333 | version = 0; |
348 | else if (linux_version_code() < MAKE_VERSION(2, 1, 117)) | 334 | else if (get_kernel_revision() < MAKE_VERSION(2, 1, 117)) |
349 | version = 0; | 335 | version = 0; |
350 | else if (pagesize < 2048) | 336 | else if (pagesize < 2048) |
351 | version = 0; | 337 | version = 0; |
@@ -366,7 +352,7 @@ int mkswap_main(int argc, char **argv) | |||
366 | #else | 352 | #else |
367 | if (!version) | 353 | if (!version) |
368 | maxpages = V0_MAX_PAGES; | 354 | maxpages = V0_MAX_PAGES; |
369 | else if (linux_version_code() >= MAKE_VERSION(2, 2, 1)) | 355 | else if (get_kernel_revision() >= MAKE_VERSION(2, 2, 1)) |
370 | maxpages = V1_MAX_PAGES; | 356 | maxpages = V1_MAX_PAGES; |
371 | else { | 357 | else { |
372 | maxpages = V1_OLD_MAX_PAGES; | 358 | maxpages = V1_OLD_MAX_PAGES; |
diff --git a/nfsmount.c b/nfsmount.c index abae19afe..f8735e52c 100644 --- a/nfsmount.c +++ b/nfsmount.c | |||
@@ -160,20 +160,6 @@ static char *nfs_strerror(int stat); | |||
160 | #define EX_BG 256 /* retry in background (internal only) */ | 160 | #define EX_BG 256 /* retry in background (internal only) */ |
161 | 161 | ||
162 | 162 | ||
163 | static int | ||
164 | linux_version_code(void) { | ||
165 | struct utsname my_utsname; | ||
166 | int p, q, r; | ||
167 | |||
168 | if (uname(&my_utsname) == 0) { | ||
169 | p = atoi(strtok(my_utsname.release, ".")); | ||
170 | q = atoi(strtok(NULL, ".")); | ||
171 | r = atoi(strtok(NULL, ".")); | ||
172 | return MAKE_VERSION(p,q,r); | ||
173 | } | ||
174 | return 0; | ||
175 | } | ||
176 | |||
177 | /* | 163 | /* |
178 | * nfs_mount_version according to the sources seen at compile time. | 164 | * nfs_mount_version according to the sources seen at compile time. |
179 | */ | 165 | */ |
@@ -197,7 +183,7 @@ find_kernel_nfs_mount_version(void) { | |||
197 | if (kernel_version) | 183 | if (kernel_version) |
198 | return; | 184 | return; |
199 | 185 | ||
200 | kernel_version = linux_version_code(); | 186 | kernel_version = get_kernel_revision(); |
201 | 187 | ||
202 | if (kernel_version) { | 188 | if (kernel_version) { |
203 | if (kernel_version < MAKE_VERSION(2,1,32)) | 189 | if (kernel_version < MAKE_VERSION(2,1,32)) |
@@ -796,7 +782,7 @@ int nfsmount(const char *spec, const char *node, int *flags, | |||
796 | * to avoid problems with multihomed hosts. | 782 | * to avoid problems with multihomed hosts. |
797 | * --Swen | 783 | * --Swen |
798 | */ | 784 | */ |
799 | if (linux_version_code() <= 66314 | 785 | if (get_kernel_revision() <= 66314 |
800 | && connect(fsock, (struct sockaddr *) &server_addr, | 786 | && connect(fsock, (struct sockaddr *) &server_addr, |
801 | sizeof (server_addr)) < 0) { | 787 | sizeof (server_addr)) < 0) { |
802 | perror(_("nfs connect")); | 788 | perror(_("nfs connect")); |
diff --git a/util-linux/mkswap.c b/util-linux/mkswap.c index 8a9767cca..627d04f60 100644 --- a/util-linux/mkswap.c +++ b/util-linux/mkswap.c | |||
@@ -63,20 +63,6 @@ static int version = -1; | |||
63 | 63 | ||
64 | #define MAKE_VERSION(p,q,r) (65536*(p) + 256*(q) + (r)) | 64 | #define MAKE_VERSION(p,q,r) (65536*(p) + 256*(q) + (r)) |
65 | 65 | ||
66 | static int linux_version_code(void) | ||
67 | { | ||
68 | struct utsname my_utsname; | ||
69 | int p, q, r; | ||
70 | |||
71 | if (uname(&my_utsname) == 0) { | ||
72 | p = atoi(strtok(my_utsname.release, ".")); | ||
73 | q = atoi(strtok(NULL, ".")); | ||
74 | r = atoi(strtok(NULL, ".")); | ||
75 | return MAKE_VERSION(p, q, r); | ||
76 | } | ||
77 | return 0; | ||
78 | } | ||
79 | |||
80 | /* | 66 | /* |
81 | * The definition of the union swap_header uses the constant PAGE_SIZE. | 67 | * The definition of the union swap_header uses the constant PAGE_SIZE. |
82 | * Unfortunately, on some architectures this depends on the hardware model, | 68 | * Unfortunately, on some architectures this depends on the hardware model, |
@@ -345,7 +331,7 @@ int mkswap_main(int argc, char **argv) | |||
345 | if (version == -1) { | 331 | if (version == -1) { |
346 | if (PAGES <= V0_MAX_PAGES) | 332 | if (PAGES <= V0_MAX_PAGES) |
347 | version = 0; | 333 | version = 0; |
348 | else if (linux_version_code() < MAKE_VERSION(2, 1, 117)) | 334 | else if (get_kernel_revision() < MAKE_VERSION(2, 1, 117)) |
349 | version = 0; | 335 | version = 0; |
350 | else if (pagesize < 2048) | 336 | else if (pagesize < 2048) |
351 | version = 0; | 337 | version = 0; |
@@ -366,7 +352,7 @@ int mkswap_main(int argc, char **argv) | |||
366 | #else | 352 | #else |
367 | if (!version) | 353 | if (!version) |
368 | maxpages = V0_MAX_PAGES; | 354 | maxpages = V0_MAX_PAGES; |
369 | else if (linux_version_code() >= MAKE_VERSION(2, 2, 1)) | 355 | else if (get_kernel_revision() >= MAKE_VERSION(2, 2, 1)) |
370 | maxpages = V1_MAX_PAGES; | 356 | maxpages = V1_MAX_PAGES; |
371 | else { | 357 | else { |
372 | maxpages = V1_OLD_MAX_PAGES; | 358 | maxpages = V1_OLD_MAX_PAGES; |
diff --git a/util-linux/nfsmount.c b/util-linux/nfsmount.c index abae19afe..f8735e52c 100644 --- a/util-linux/nfsmount.c +++ b/util-linux/nfsmount.c | |||
@@ -160,20 +160,6 @@ static char *nfs_strerror(int stat); | |||
160 | #define EX_BG 256 /* retry in background (internal only) */ | 160 | #define EX_BG 256 /* retry in background (internal only) */ |
161 | 161 | ||
162 | 162 | ||
163 | static int | ||
164 | linux_version_code(void) { | ||
165 | struct utsname my_utsname; | ||
166 | int p, q, r; | ||
167 | |||
168 | if (uname(&my_utsname) == 0) { | ||
169 | p = atoi(strtok(my_utsname.release, ".")); | ||
170 | q = atoi(strtok(NULL, ".")); | ||
171 | r = atoi(strtok(NULL, ".")); | ||
172 | return MAKE_VERSION(p,q,r); | ||
173 | } | ||
174 | return 0; | ||
175 | } | ||
176 | |||
177 | /* | 163 | /* |
178 | * nfs_mount_version according to the sources seen at compile time. | 164 | * nfs_mount_version according to the sources seen at compile time. |
179 | */ | 165 | */ |
@@ -197,7 +183,7 @@ find_kernel_nfs_mount_version(void) { | |||
197 | if (kernel_version) | 183 | if (kernel_version) |
198 | return; | 184 | return; |
199 | 185 | ||
200 | kernel_version = linux_version_code(); | 186 | kernel_version = get_kernel_revision(); |
201 | 187 | ||
202 | if (kernel_version) { | 188 | if (kernel_version) { |
203 | if (kernel_version < MAKE_VERSION(2,1,32)) | 189 | if (kernel_version < MAKE_VERSION(2,1,32)) |
@@ -796,7 +782,7 @@ int nfsmount(const char *spec, const char *node, int *flags, | |||
796 | * to avoid problems with multihomed hosts. | 782 | * to avoid problems with multihomed hosts. |
797 | * --Swen | 783 | * --Swen |
798 | */ | 784 | */ |
799 | if (linux_version_code() <= 66314 | 785 | if (get_kernel_revision() <= 66314 |
800 | && connect(fsock, (struct sockaddr *) &server_addr, | 786 | && connect(fsock, (struct sockaddr *) &server_addr, |
801 | sizeof (server_addr)) < 0) { | 787 | sizeof (server_addr)) < 0) { |
802 | perror(_("nfs connect")); | 788 | perror(_("nfs connect")); |
@@ -156,7 +156,9 @@ extern int get_kernel_revision(void) | |||
156 | perror("cannot get system information"); | 156 | perror("cannot get system information"); |
157 | return (0); | 157 | return (0); |
158 | } | 158 | } |
159 | sscanf(name.version, "%d.%d.%d", &major, &minor, &patch); | 159 | major = atoi(strtok(name.release, ".")); |
160 | minor = atoi(strtok(NULL, ".")); | ||
161 | patch = atoi(strtok(NULL, ".")); | ||
160 | return major * 65536 + minor * 256 + patch; | 162 | return major * 65536 + minor * 256 + patch; |
161 | } | 163 | } |
162 | #endif /* BB_INIT */ | 164 | #endif /* BB_INIT */ |