Last change
on this file since 1601 was 821, checked in by Bruno Cornec, 18 years ago |
Addition of busybox 1.2.1 as a mindi-busybox new package
This should avoid delivering binary files in mindi not built there (Fedora and Debian are quite serious about that)
|
File size:
1.1 KB
|
Rev | Line | |
---|
[821] | 1 | /*
|
---|
| 2 | * getostype.c - Get the Filesystem OS type
|
---|
| 3 | *
|
---|
| 4 | * Copyright (C) 2004,2005 Theodore Ts'o <tytso@mit.edu>
|
---|
| 5 | *
|
---|
| 6 | * This file can be redistributed under the terms of the GNU Library General
|
---|
| 7 | * Public License
|
---|
| 8 | */
|
---|
| 9 |
|
---|
| 10 | #include "e2p.h"
|
---|
| 11 | #include <string.h>
|
---|
| 12 | #include <stdlib.h>
|
---|
| 13 |
|
---|
| 14 | static const char * const os_tab[] =
|
---|
| 15 | { "Linux",
|
---|
| 16 | "Hurd",
|
---|
| 17 | "Masix",
|
---|
| 18 | "FreeBSD",
|
---|
| 19 | "Lites",
|
---|
| 20 | 0 };
|
---|
| 21 |
|
---|
| 22 | /*
|
---|
| 23 | * Convert an os_type to a string
|
---|
| 24 | */
|
---|
| 25 | char *e2p_os2string(int os_type)
|
---|
| 26 | {
|
---|
| 27 | const char *os;
|
---|
| 28 | char *ret;
|
---|
| 29 |
|
---|
| 30 | if (os_type <= EXT2_OS_LITES)
|
---|
| 31 | os = os_tab[os_type];
|
---|
| 32 | else
|
---|
| 33 | os = "(unknown os)";
|
---|
| 34 |
|
---|
| 35 | ret = bb_xstrdup(os);
|
---|
| 36 | return ret;
|
---|
| 37 | }
|
---|
| 38 |
|
---|
| 39 | /*
|
---|
| 40 | * Convert an os_type to a string
|
---|
| 41 | */
|
---|
| 42 | int e2p_string2os(char *str)
|
---|
| 43 | {
|
---|
| 44 | const char * const *cpp;
|
---|
| 45 | int i = 0;
|
---|
| 46 |
|
---|
| 47 | for (cpp = os_tab; *cpp; cpp++, i++) {
|
---|
| 48 | if (!strcasecmp(str, *cpp))
|
---|
| 49 | return i;
|
---|
| 50 | }
|
---|
| 51 | return -1;
|
---|
| 52 | }
|
---|
| 53 |
|
---|
| 54 | #ifdef TEST_PROGRAM
|
---|
| 55 | int main(int argc, char **argv)
|
---|
| 56 | {
|
---|
| 57 | char *s;
|
---|
| 58 | int i, os;
|
---|
| 59 |
|
---|
| 60 | for (i=0; i <= EXT2_OS_LITES; i++) {
|
---|
| 61 | s = e2p_os2string(i);
|
---|
| 62 | os = e2p_string2os(s);
|
---|
| 63 | printf("%d: %s (%d)\n", i, s, os);
|
---|
| 64 | if (i != os) {
|
---|
| 65 | fprintf(stderr, "Failure!\n");
|
---|
| 66 | exit(1);
|
---|
| 67 | }
|
---|
| 68 | }
|
---|
| 69 | exit(0);
|
---|
| 70 | }
|
---|
| 71 | #endif
|
---|
| 72 |
|
---|
| 73 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.