Annotation of /trunk/mkinitrd-magellan/busybox/libbb/kernel_version.c
Parent Directory | Revision Log
Revision 984 -
(hide annotations)
(download)
Sun May 30 11:32:42 2010 UTC (14 years ago) by niro
File MIME type: text/plain
File size: 866 byte(s)
Sun May 30 11:32:42 2010 UTC (14 years ago) by niro
File MIME type: text/plain
File size: 866 byte(s)
-updated to busybox-1.16.1 and enabled blkid/uuid support in default config
1 | niro | 532 | /* vi: set sw=4 ts=4: */ |
2 | /* | ||
3 | * Utility routines. | ||
4 | * | ||
5 | * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> | ||
6 | * | ||
7 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. | ||
8 | */ | ||
9 | |||
10 | #include "libbb.h" | ||
11 | niro | 984 | /* After libbb.h, since it needs sys/types.h on some systems */ |
12 | #include <sys/utsname.h> /* for uname(2) */ | ||
13 | niro | 532 | |
14 | niro | 984 | |
15 | niro | 532 | /* Returns current kernel version encoded as major*65536 + minor*256 + patch, |
16 | * so, for example, to check if the kernel is greater than 2.2.11: | ||
17 | * | ||
18 | * if (get_linux_version_code() > KERNEL_VERSION(2,2,11)) { <stuff> } | ||
19 | */ | ||
20 | niro | 816 | int FAST_FUNC get_linux_version_code(void) |
21 | niro | 532 | { |
22 | struct utsname name; | ||
23 | char *s; | ||
24 | int i, r; | ||
25 | |||
26 | if (uname(&name) == -1) { | ||
27 | niro | 984 | bb_perror_msg("can't get system information"); |
28 | niro | 532 | return 0; |
29 | } | ||
30 | |||
31 | s = name.release; | ||
32 | r = 0; | ||
33 | for (i = 0; i < 3; i++) { | ||
34 | r = r * 256 + atoi(strtok(s, ".")); | ||
35 | s = NULL; | ||
36 | } | ||
37 | return r; | ||
38 | } |