From vda at busybox.net Mon Jan 1 10:18:05 2007 From: vda at busybox.net (vda at busybox.net) Date: Mon, 1 Jan 2007 10:18:05 -0800 (PST) Subject: svn commit: trunk/busybox: coreutils shell Message-ID: <20070101181805.1EB81485BC@busybox.net> Author: vda Date: 2007-01-01 10:18:04 -0800 (Mon, 01 Jan 2007) New Revision: 17124 Log: stty: fix width of a field for ppc32 sort: fix -u to match coreutils 6.3 msh: compile fix (my fault) Modified: trunk/busybox/coreutils/sort.c trunk/busybox/coreutils/stty.c trunk/busybox/shell/msh.c Changeset: Modified: trunk/busybox/coreutils/sort.c =================================================================== --- trunk/busybox/coreutils/sort.c 2007-01-01 06:00:38 UTC (rev 17123) +++ trunk/busybox/coreutils/sort.c 2007-01-01 18:18:04 UTC (rev 17124) @@ -14,38 +14,44 @@ #include "busybox.h" -static int global_flags; - /* sort [-m][-o output][-bdfinru][-t char][-k keydef]... [file...] sort -c [-bdfinru][-t char][-k keydef][file] */ /* These are sort types */ -#define FLAG_n 1 /* Numeric sort */ -#define FLAG_g 2 /* Sort using strtod() */ -#define FLAG_M 4 /* Sort date */ +static const char OPT_STR[] = "ngMucszbrdfimS:T:o:k:t:"; +enum { + FLAG_n = 1, /* Numeric sort */ + FLAG_g = 2, /* Sort using strtod() */ + FLAG_M = 4, /* Sort date */ /* ucsz apply to root level only, not keys. b at root level implies bb */ -#define FLAG_u 8 /* Unique */ -#define FLAG_c 16 /* Check: no output, exit(!ordered) */ -#define FLAG_s 32 /* Stable sort, no ascii fallback at end */ -#define FLAG_z 64 /* Input is null terminated, not \n */ + FLAG_u = 8, /* Unique */ + FLAG_c = 0x10, /* Check: no output, exit(!ordered) */ + FLAG_s = 0x20, /* Stable sort, no ascii fallback at end */ + FLAG_z = 0x40, /* Input is null terminated, not \n */ /* These can be applied to search keys, the previous four can't */ -#define FLAG_b 128 /* Ignore leading blanks */ -#define FLAG_r 256 /* Reverse */ -#define FLAG_d 512 /* Ignore !(isalnum()|isspace()) */ -#define FLAG_f 1024 /* Force uppercase */ -#define FLAG_i 2048 /* Ignore !isprint() */ -#define FLAG_bb 32768 /* Ignore trailing blanks */ + FLAG_b = 0x80, /* Ignore leading blanks */ + FLAG_r = 0x100, /* Reverse */ + FLAG_d = 0x200, /* Ignore !(isalnum()|isspace()) */ + FLAG_f = 0x400, /* Force uppercase */ + FLAG_i = 0x800, /* Ignore !isprint() */ + FLAG_m = 0x1000, /* ignored: merge already sorted files; do not sort */ + FLAG_S = 0x2000, /* ignored: -S, --buffer-size=SIZE */ + FLAG_T = 0x4000, /* ignored: -T, --temporary-directory=DIR */ + FLAG_o = 0x8000, + FLAG_k = 0x10000, + FLAG_t = 0x20000, + FLAG_bb = 0x80000000, /* Ignore trailing blanks */ +}; - #if ENABLE_FEATURE_SORT_BIG static char key_separator; static struct sort_key { struct sort_key *next_key; /* linked list */ - unsigned short range[4]; /* start word, start char, end word, end char */ - int flags; + unsigned range[4]; /* start word, start char, end word, end char */ + unsigned flags; } *key_list; static char *get_key(char *str, struct sort_key *key, int flags) @@ -59,7 +65,7 @@ return str; } - /* Find start of key on first pass, end on second pass*/ + /* Find start of key on first pass, end on second pass */ len = strlen(str); for (j = 0; j < 2; j++) { if (!key->range[2*j]) @@ -68,19 +74,25 @@ else { end = 0; for (i = 1; i < key->range[2*j] + j; i++) { - /* Skip leading blanks or first separator */ - if (str[end]) { - if (!key_separator) - while (isspace(str[end])) end++; - } - /* Skip body of key */ - for (; str[end]; end++) { - if (key_separator) { + if (key_separator) { + /* Skip first separator */ + while (str[end] == key_separator) + end++; + /* Skip body of key */ + while (str[end]) { if (str[end] == key_separator) break; - } else { + end++; + } + } else { + /* Skip leading blanks */ + while (isspace(str[end])) + end++; + /* Skip body of key */ + while (str[end]) { if (isspace(str[end])) break; + end++; } } } @@ -140,7 +152,7 @@ } #define GET_LINE(fp) \ - ((global_flags & FLAG_z) \ + ((option_mask32 & FLAG_z) \ ? bb_get_chunk_from_file(fp, NULL) \ : xmalloc_getline(fp)) #else @@ -150,14 +162,14 @@ /* Iterate through keys list and perform comparisons */ static int compare_keys(const void *xarg, const void *yarg) { - int flags = global_flags, retval = 0; + int flags = option_mask32, retval = 0; char *x, *y; #if ENABLE_FEATURE_SORT_BIG struct sort_key *key; for (key = key_list; !retval && key; key = key->next_key) { - flags = key->flags ? key->flags : global_flags; + flags = key->flags ? key->flags : option_mask32; /* Chop out and modify key chunks, handling -dfib */ x = get_key(*(char **)xarg, key, flags); y = get_key(*(char **)yarg, key, flags); @@ -175,7 +187,11 @@ break; /* Ascii sort */ case 0: +#if ENABLE_LOCALE_SUPPORT + retval = strcoll(x, y); +#else retval = strcmp(x, y); +#endif break; #if ENABLE_FEATURE_SORT_BIG case FLAG_g: { @@ -239,74 +255,97 @@ break; } /* switch */ #endif - } + } /* for */ + /* Perform fallback sort if necessary */ - if (!retval && !(global_flags & FLAG_s)) + if (!retval && !(option_mask32 & FLAG_s)) retval = strcmp(*(char **)xarg, *(char **)yarg); if (flags & FLAG_r) return -retval; return retval; } +static unsigned str2u(char **str) +{ + unsigned long lu; + if (!isdigit((*str)[0])) + bb_error_msg_and_die("bad field specification"); + lu = strtoul(*str, str, 10); + if ((sizeof(long) > sizeof(int) && lu > INT_MAX) || !lu) + bb_error_msg_and_die("bad field specification"); + return lu; +} + int sort_main(int argc, char **argv) { - FILE *fp, *outfile = NULL; - int linecount = 0, i, flag; - char *line, **lines = NULL, *optlist = "ngMucszbrdfimS:T:o:k:t:"; - int c; + FILE *fp, *outfile = stdout; + char *line, **lines = NULL; + char *str_ignored, *str_o, *str_k, *str_t; + int i, flag; + int linecount = 0; xfunc_error_retval = 2; + /* Parse command line options */ - while ((c = getopt(argc, argv, optlist)) > 0) { - line = strchr(optlist, c); - if (!line) bb_show_usage(); - switch (*line) { + /* -o and -t can be given at most once */ + opt_complementary = "?:o--o:t--t"; + getopt32(argc, argv, OPT_STR, &str_ignored, &str_ignored, &str_o, &str_k, &str_t); #if ENABLE_FEATURE_SORT_BIG - case 'o': - if (outfile) bb_error_msg_and_die("too many -o"); - outfile = xfopen(optarg, "w"); - break; - case 't': - if (key_separator || optarg[1]) - bb_error_msg_and_die("too many -t"); - key_separator = *optarg; - break; - /* parse sort key */ - case 'k': { - struct sort_key *key = add_key(); - char *temp, *temp2; + if (option_mask32 & FLAG_o) outfile = xfopen(str_o, "w"); + if (option_mask32 & FLAG_t) { + if (!str_t[0] || str_t[1]) + bb_error_msg_and_die("bad -t parameter"); + key_separator = str_t[0]; + } + /* parse sort key */ + if (option_mask32 & FLAG_k) { + enum { + FLAG_allowed_for_k = + FLAG_n | /* Numeric sort */ + FLAG_g | /* Sort using strtod() */ + FLAG_M | /* Sort date */ + FLAG_b | /* Ignore leading blanks */ + FLAG_r | /* Reverse */ + FLAG_d | /* Ignore !(isalnum()|isspace()) */ + FLAG_f | /* Force uppercase */ + FLAG_i | /* Ignore !isprint() */ + 0 + }; + struct sort_key *key = add_key(); + const char *temp2; - temp = optarg; - for (i = 0; *temp;) { - /* Start of range */ - key->range[2*i] = (unsigned short)strtol(temp, &temp, 10); - if (*temp == '.') - key->range[(2*i)+1] = (unsigned short)strtol(temp+1, &temp, 10); - for (; *temp; temp++) { - if (*temp == ',' && !i++) { - temp++; - break; - } /* no else needed: fall through to syntax error - because comma isn't in optlist */ - temp2 = strchr(optlist, *temp); - flag = (1 << (temp2 - optlist)); - if (!temp2 || (flag > FLAG_M && flag < FLAG_b)) - bb_error_msg_and_die("unknown key option"); - /* b after ',' means strip _trailing_ space */ - if (i && flag == FLAG_b) flag = FLAG_bb; - key->flags |= flag; - } + i = 0; /* i==0 before comma, 1 after (-k3,6) */ + while (*str_k) { + /* Start of range */ + /* Cannot use bb_strtou - suffix can be a letter */ + key->range[2*i] = str2u(&str_k); + if (*str_k == '.') { + str_k++; + key->range[2*i+1] = str2u(&str_k); } - break; + while (*str_k) { + if (*str_k == ',' && !i++) { + str_k++; + break; + } /* no else needed: fall through to syntax error + because comma isn't in OPT_STR */ + temp2 = strchr(OPT_STR, *str_k); + if (!temp2) + bb_error_msg_and_die("unknown key option"); + flag = 1 << (temp2 - OPT_STR); + if (flag & ~FLAG_allowed_for_k) + bb_error_msg_and_die("unknown sort type"); + /* b after ',' means strip _trailing_ space */ + if (i && flag == FLAG_b) flag = FLAG_bb; + key->flags |= flag; + str_k++; + } } + } #endif - default: - global_flags |= (1 << (line - optlist)); - /* global b strips leading and trailing spaces */ - if (global_flags & FLAG_b) global_flags |= FLAG_bb; - break; - } - } + /* global b strips leading and trailing spaces */ + if (option_mask32 & FLAG_b) option_mask32 |= FLAG_bb; + /* Open input files and read data */ for (i = argv[optind] ? optind : optind-1; argv[i]; i++) { fp = stdin; @@ -326,8 +365,8 @@ if (!key_list) add_key()->range[0] = 1; /* handle -c */ - if (global_flags & FLAG_c) { - int j = (global_flags & FLAG_u) ? -1 : 0; + if (option_mask32 & FLAG_c) { + int j = (option_mask32 & FLAG_u) ? -1 : 0; for (i = 1; i < linecount; i++) if (compare_keys(&lines[i-1], &lines[i]) > j) { fprintf(stderr, "Check line %d\n", i); @@ -339,8 +378,12 @@ /* Perform the actual sort */ qsort(lines, linecount, sizeof(char *), compare_keys); /* handle -u */ - if (global_flags & FLAG_u) { - for (flag = 0, i = 1; i < linecount; i++) { + if (option_mask32 & FLAG_u) { + flag = 0; + /* coreutils 6.3 drop lines for which only key is the same */ + /* -- disabling last-resort compare... */ + option_mask32 |= FLAG_s; + for (i = 1; i < linecount; i++) { if (!compare_keys(&lines[flag], &lines[i])) free(lines[i]); else @@ -349,7 +392,6 @@ if (linecount) linecount = flag+1; } /* Print it */ - if (!outfile) outfile = stdout; for (i = 0; i < linecount; i++) fprintf(outfile, "%s\n", lines[i]); Modified: trunk/busybox/coreutils/stty.c =================================================================== --- trunk/busybox/coreutils/stty.c 2007-01-01 06:00:38 UTC (rev 17123) +++ trunk/busybox/coreutils/stty.c 2007-01-01 18:18:04 UTC (rev 17124) @@ -158,13 +158,18 @@ /* Each mode */ struct mode_info { - const char *name; /* Name given on command line */ - char type; /* Which structure element to change */ - char flags; /* Setting and display options */ - unsigned short mask; /* Other bits to turn off for this mode */ - unsigned long bits; /* Bits to set for this mode */ + const char *name; /* Name given on command line */ + char type; /* Which structure element to change */ + char flags; /* Setting and display options */ + /* were using short here, but ppc32 was unhappy: */ + tcflag_t mask; /* Other bits to turn off for this mode */ + tcflag_t bits; /* Bits to set for this mode */ }; +/* We can optimize it further by using name[8] instead of char *name */ +/* but beware of "if (info->name == evenp)" checks! */ +/* Need to replace them with "if (info == &mode_info[EVENP_INDX])" */ + #define MI_ENTRY(N,T,F,B,M) { N, T, F, M, B } static const struct mode_info mode_info[] = { @@ -319,9 +324,9 @@ /* Control character settings */ struct control_info { - const char *name; /* Name given on command line */ + const char *name; /* Name given on command line */ unsigned char saneval; /* Value to set for 'stty sane' */ - unsigned char offset; /* Offset in c_cc */ + unsigned char offset; /* Offset in c_cc */ }; /* Control characters */ @@ -968,9 +973,9 @@ if (bitsp) { if (reversed) - *bitsp = *bitsp & ~((unsigned long)info->mask) & ~info->bits; + *bitsp = *bitsp & ~info->mask & ~info->bits; else - *bitsp = (*bitsp & ~((unsigned long)info->mask)) | info->bits; + *bitsp = (*bitsp & ~info->mask) | info->bits; return; } Modified: trunk/busybox/shell/msh.c =================================================================== --- trunk/busybox/shell/msh.c 2007-01-01 06:00:38 UTC (rev 17123) +++ trunk/busybox/shell/msh.c 2007-01-01 18:18:04 UTC (rev 17124) @@ -4860,9 +4860,12 @@ { int c; - if (ap->aword == NULL) || (c = *ap->aword++) == 0) + if (ap->aword == NULL) return 0; - return c | QUOTE; + c = *ap->aword++; + if (c) + c |= QUOTE; + return c; } /* From vda at busybox.net Mon Jan 1 15:51:32 2007 From: vda at busybox.net (vda at busybox.net) Date: Mon, 1 Jan 2007 15:51:32 -0800 (PST) Subject: svn commit: trunk/busybox/editors Message-ID: <20070101235132.777A3485BB@busybox.net> Author: vda Date: 2007-01-01 15:51:30 -0800 (Mon, 01 Jan 2007) New Revision: 17125 Log: awk: style cleanup. A lot of rw data moved to ro (still has quite a lot of statics etc...). getopt32-ification. Modified: trunk/busybox/editors/awk.c Changeset: Sorry, the patch is too large to include (1238 lines). Please use ViewCVS to see it! http://busybox.net/cgi-bin/viewcvs.cgi?view=rev&root=svn&rev=17125 From vda at busybox.net Mon Jan 1 15:53:13 2007 From: vda at busybox.net (vda at busybox.net) Date: Mon, 1 Jan 2007 15:53:13 -0800 (PST) Subject: svn commit: trunk/busybox: coreutils editors Message-ID: <20070101235313.75FF5485BC@busybox.net> Author: vda Date: 2007-01-01 15:53:12 -0800 (Mon, 01 Jan 2007) New Revision: 17126 Log: awk: undo locale setting for numbers - or else parsing can act quite mysteriously date: add if(ENABLE_LOCALE_SUPPORT) Modified: trunk/busybox/coreutils/date.c trunk/busybox/editors/awk.c Changeset: Modified: trunk/busybox/coreutils/date.c =================================================================== --- trunk/busybox/coreutils/date.c 2007-01-01 23:51:30 UTC (rev 17125) +++ trunk/busybox/coreutils/date.c 2007-01-01 23:53:12 UTC (rev 17126) @@ -212,7 +212,8 @@ } } else if (opt & DATE_OPT_RFC2822) { /* Undo busybox.c for date -R */ - setlocale(LC_TIME, "C"); + if (ENABLE_LOCALE_SUPPORT) + setlocale(LC_TIME, "C"); strcpy(date_fmt, "%a, %d %b %Y %H:%M:%S "); i = 22; goto format_utc; Modified: trunk/busybox/editors/awk.c =================================================================== --- trunk/busybox/editors/awk.c 2007-01-01 23:51:30 UTC (rev 17125) +++ trunk/busybox/editors/awk.c 2007-01-01 23:53:12 UTC (rev 17126) @@ -2652,6 +2652,11 @@ char *vnames = (char *)vNames; /* cheat */ char *vvalues = (char *)vValues; + /* Undo busybox.c, or else strtod may eat ','! This breaks parsing: + * $1,$2 == '$1,' '$2', NOT '$1' ',' '$2' */ + if (ENABLE_LOCALE_SUPPORT) + setlocale(LC_NUMERIC, "C"); + zero_out_var(&tv); /* allocate global buffer */ From vda at busybox.net Mon Jan 1 15:53:52 2007 From: vda at busybox.net (vda at busybox.net) Date: Mon, 1 Jan 2007 15:53:52 -0800 (PST) Subject: svn commit: trunk/busybox/editors Message-ID: <20070101235352.8CC78485BC@busybox.net> Author: vda Date: 2007-01-01 15:53:52 -0800 (Mon, 01 Jan 2007) New Revision: 17127 Log: awk: style fixes Modified: trunk/busybox/editors/awk.c Changeset: Modified: trunk/busybox/editors/awk.c =================================================================== --- trunk/busybox/editors/awk.c 2007-01-01 23:53:12 UTC (rev 17126) +++ trunk/busybox/editors/awk.c 2007-01-01 23:53:52 UTC (rev 17127) @@ -848,20 +848,16 @@ int l; if (t.rollback) { - t.rollback = FALSE; } else if (concat_inserted) { - concat_inserted = FALSE; t.tclass = save_tclass; t.info = save_info; } else { - p = pos; - - readnext: + readnext: skip_spaces(&p); lineno = t.lineno; if (*p == '#') @@ -939,7 +935,7 @@ /* it's a name (var/array/function), * otherwise it's something wrong */ - if (! isalnum_(*p)) + if (!isalnum_(*p)) syntax_error(EMSG_UNEXP_TOKEN); t.string = --p; @@ -949,7 +945,7 @@ *(p-1) = '\0'; tc = TC_VARIABLE; /* also consume whitespace between functionname and bracket */ - if (! (expected & TC_VARIABLE)) skip_spaces(&p); + if (!(expected & TC_VARIABLE)) skip_spaces(&p); if (*p == '(') { tc = TC_FUNCTION; } else { @@ -1395,14 +1391,14 @@ /* gradually increasing buffer */ static void qrealloc(char **b, int n, int *size) { - if (! *b || n >= *size) + if (!*b || n >= *size) *b = xrealloc(*b, *size = n + (n>>1) + 80); } /* resize field storage space */ static void fsrealloc(int size) { - static int maxfields = 0; + static int maxfields; /* = 0;*/ int i; if (size >= maxfields) { @@ -1416,8 +1412,8 @@ } if (size < nfields) { - for (i=size; itype & VF_SPECIAL)) + if (!(v->type & VF_SPECIAL)) return; if (v == V[NF]) { @@ -1540,7 +1536,8 @@ memcpy(b+len, s, l); len += l; } - if (b) b[len] = '\0'; + if (b) + b[len] = '\0'; setvar_p(V[F0], b); is_f0_split = TRUE; @@ -1556,7 +1553,7 @@ } else if (v == V[IGNORECASE]) { icase = istrue(v); - } else { /* $n */ + } else { /* $n */ n = getvar_i(V[NF]); setvar_i(V[NF], n > v-Fields ? n : v-Fields+1); /* right here v is invalid. Just to note... */ @@ -1781,7 +1778,6 @@ /* if there was an error while sprintf, return value is negative */ if (i < j) i = j; - } b = xrealloc(b, i + 1); @@ -1965,7 +1961,7 @@ case B_up: to_xxx = toupper; -lo_cont: + lo_cont: s1 = s = xstrdup(as[0]); while (*s1) { *s1 = (*to_xxx)(*s1); @@ -2053,6 +2049,7 @@ static var *fnargs = NULL; static unsigned seed = 1; static regex_t sreg; + node *op1; var *v1; union { @@ -2072,7 +2069,7 @@ uint32_t info; } X; - if (! op) + if (!op) return setvar_s(res, NULL); v1 = nvalloc(2); @@ -2224,9 +2221,8 @@ case XC( OC_FNARG ): L.v = &fnargs[op->l.i]; - -v_cont: - res = (op->r.n) ? findvar(iamarray(L.v), R.s) : L.v; + v_cont: + res = op->r.n ? findvar(iamarray(L.v), R.s) : L.v; break; case XC( OC_IN ): @@ -2240,7 +2236,7 @@ case XC( OC_MATCH ): op1 = op->r.n; -re_cont: + re_cont: X.re = as_regex(op1, &sreg); R.i = regexec(X.re, L.s, 0, NULL, 0); if (X.re == &sreg) regfree(X.re); From vapier at busybox.net Mon Jan 1 21:42:36 2007 From: vapier at busybox.net (vapier at busybox.net) Date: Mon, 1 Jan 2007 21:42:36 -0800 (PST) Subject: svn commit: trunk/busybox/applets Message-ID: <20070102054236.50E8B485DD@busybox.net> Author: vapier Date: 2007-01-01 21:42:35 -0800 (Mon, 01 Jan 2007) New Revision: 17128 Log: convert usage compressed command into the new cmd style Modified: trunk/busybox/applets/Kbuild Changeset: Modified: trunk/busybox/applets/Kbuild =================================================================== --- trunk/busybox/applets/Kbuild 2007-01-01 23:53:52 UTC (rev 17127) +++ trunk/busybox/applets/Kbuild 2007-01-02 05:42:35 UTC (rev 17128) @@ -16,6 +16,7 @@ always := $(hostprogs-y) HOSTCFLAGS_usage.o = -I$(srctree)/include +quiet_cmd_gen_usage_compressed = GEN include/usage_compressed.h + cmd_gen_usage_compressed = $(srctree)/applets/usage_compressed include/usage_compressed.h applets include/usage_compressed.h: $(srctree)/include/usage.h applets/usage - @echo ' GEN include/usage_compressed.h' - @$(srctree)/applets/usage_compressed include/usage_compressed.h applets + $(call cmd,gen_usage_compressed) From vapier at busybox.net Mon Jan 1 21:43:31 2007 From: vapier at busybox.net (vapier at busybox.net) Date: Mon, 1 Jan 2007 21:43:31 -0800 (PST) Subject: svn commit: trunk/busybox/coreutils Message-ID: <20070102054331.A3684485DE@busybox.net> Author: vapier Date: 2007-01-01 21:43:30 -0800 (Mon, 01 Jan 2007) New Revision: 17129 Log: str2u() is only used when FEATURE_SORT_BIG is enabled Modified: trunk/busybox/coreutils/sort.c Changeset: Modified: trunk/busybox/coreutils/sort.c =================================================================== --- trunk/busybox/coreutils/sort.c 2007-01-02 05:42:35 UTC (rev 17128) +++ trunk/busybox/coreutils/sort.c 2007-01-02 05:43:30 UTC (rev 17129) @@ -265,6 +265,7 @@ return retval; } +#if ENABLE_FEATURE_SORT_BIG static unsigned str2u(char **str) { unsigned long lu; @@ -275,6 +276,7 @@ bb_error_msg_and_die("bad field specification"); return lu; } +#endif int sort_main(int argc, char **argv) { From vapier at busybox.net Mon Jan 1 21:46:19 2007 From: vapier at busybox.net (vapier at busybox.net) Date: Mon, 1 Jan 2007 21:46:19 -0800 (PST) Subject: svn commit: trunk/busybox: applets e2fsprogs scripts/kconfig script etc... Message-ID: <20070102054619.4A5CF485DE@busybox.net> Author: vapier Date: 2007-01-01 21:46:18 -0800 (Mon, 01 Jan 2007) New Revision: 17130 Log: update ignores Modified: trunk/busybox/applets/ trunk/busybox/e2fsprogs/ trunk/busybox/scripts/kconfig/ trunk/busybox/scripts/kconfig/lxdialog/ Changeset: Property changes on: trunk/busybox/applets ___________________________________________________________________ Name: svn:ignore - *.a .*.o.cmd + *.a .*.o.cmd usage .usage.cmd Property changes on: trunk/busybox/e2fsprogs ___________________________________________________________________ Name: svn:ignore + *.a .*.o.cmd Property changes on: trunk/busybox/scripts/kconfig ___________________________________________________________________ Name: svn:ignore - *.a *.o .*.o.cmd zconf.hash.c conf mconf qconf zconf.tab.c lex.zconf.c .conf.cmd + *.a *.o .*.o.cmd zconf.hash.c conf mconf qconf zconf.tab.c lex.zconf.c .conf.cmd .mconf.cmd .qconf.cmd Property changes on: trunk/busybox/scripts/kconfig/lxdialog ___________________________________________________________________ Name: svn:ignore + .*.o.cmd From vda at busybox.net Tue Jan 2 08:32:16 2007 From: vda at busybox.net (vda at busybox.net) Date: Tue, 2 Jan 2007 08:32:16 -0800 (PST) Subject: svn commit: trunk/busybox: coreutils networking/libiproute Message-ID: <20070102163216.C8EF3485BD@busybox.net> Author: vda Date: 2007-01-02 08:32:16 -0800 (Tue, 02 Jan 2007) New Revision: 17131 Log: Remove networking/libiproute/linux/pkt_sched.h (and networking/libiproute/linux/ since it become empty). Style fixes. Removed: trunk/busybox/networking/libiproute/linux/ Modified: trunk/busybox/coreutils/tail.c trunk/busybox/networking/libiproute/ip_parse_common_args.c trunk/busybox/networking/libiproute/iptunnel.c Changeset: Modified: trunk/busybox/coreutils/tail.c =================================================================== --- trunk/busybox/coreutils/tail.c 2007-01-02 05:46:18 UTC (rev 17130) +++ trunk/busybox/coreutils/tail.c 2007-01-02 16:32:16 UTC (rev 17131) @@ -163,7 +163,7 @@ * starting file position may not be the beginning of the file. * Beware of backing up too far. See example in wc.c. */ - if (!(count|from_top) && lseek(fds[i], 0, SEEK_END) >= 0) { + if (!(count | from_top) && lseek(fds[i], 0, SEEK_END) >= 0) { continue; } Modified: trunk/busybox/networking/libiproute/ip_parse_common_args.c =================================================================== --- trunk/busybox/networking/libiproute/ip_parse_common_args.c 2007-01-02 05:46:18 UTC (rev 17130) +++ trunk/busybox/networking/libiproute/ip_parse_common_args.c 2007-01-02 16:32:16 UTC (rev 17131) @@ -35,7 +35,8 @@ char *opt = argv[1]; if (strcmp(opt,"--") == 0) { - argc--; argv++; + argc--; + argv++; break; } @@ -69,7 +70,8 @@ } else { bb_show_usage(); } - argc--; argv++; + argc--; + argv++; } _SL_ = oneline ? "\\" : "\n" ; *argcp = argc; Modified: trunk/busybox/networking/libiproute/iptunnel.c =================================================================== --- trunk/busybox/networking/libiproute/iptunnel.c 2007-01-02 05:46:18 UTC (rev 17130) +++ trunk/busybox/networking/libiproute/iptunnel.c 2007-01-02 16:32:16 UTC (rev 17131) @@ -409,46 +409,46 @@ if (p->iph.tos) { SPRINT_BUF(b1); printf(" tos"); - if (p->iph.tos&1) + if (p->iph.tos & 1) printf(" inherit"); - if (p->iph.tos&~1) - printf("%c%s ", p->iph.tos&1 ? '/' : ' ', - rtnl_dsfield_n2a(p->iph.tos&~1, b1, sizeof(b1))); + if (p->iph.tos & ~1) + printf("%c%s ", p->iph.tos & 1 ? '/' : ' ', + rtnl_dsfield_n2a(p->iph.tos & ~1, b1, sizeof(b1))); } - if (!(p->iph.frag_off&htons(IP_DF))) + if (!(p->iph.frag_off & htons(IP_DF))) printf(" nopmtudisc"); - if ((p->i_flags&GRE_KEY) && (p->o_flags&GRE_KEY) && p->o_key == p->i_key) + if ((p->i_flags & GRE_KEY) && (p->o_flags & GRE_KEY) && p->o_key == p->i_key) printf(" key %s", s3); - else if ((p->i_flags|p->o_flags)&GRE_KEY) { - if (p->i_flags&GRE_KEY) + else if ((p->i_flags | p->o_flags) & GRE_KEY) { + if (p->i_flags & GRE_KEY) printf(" ikey %s ", s3); - if (p->o_flags&GRE_KEY) + if (p->o_flags & GRE_KEY) printf(" okey %s ", s4); } - if (p->i_flags&GRE_SEQ) + if (p->i_flags & GRE_SEQ) printf("%s Drop packets out of sequence.\n", _SL_); - if (p->i_flags&GRE_CSUM) + if (p->i_flags & GRE_CSUM) printf("%s Checksum in received packet is required.", _SL_); - if (p->o_flags&GRE_SEQ) + if (p->o_flags & GRE_SEQ) printf("%s Sequence packets on output.", _SL_); - if (p->o_flags&GRE_CSUM) + if (p->o_flags & GRE_CSUM) printf("%s Checksum output packets.", _SL_); } static int do_tunnels_list(struct ip_tunnel_parm *p) { char name[IFNAMSIZ]; - unsigned long rx_bytes, rx_packets, rx_errs, rx_drops, - rx_fifo, rx_frame, - tx_bytes, tx_packets, tx_errs, tx_drops, - tx_fifo, tx_colls, tx_carrier, rx_multi; + unsigned long rx_bytes, rx_packets, rx_errs, rx_drops, + rx_fifo, rx_frame, + tx_bytes, tx_packets, tx_errs, tx_drops, + tx_fifo, tx_colls, tx_carrier, rx_multi; int type; struct ip_tunnel_parm p1; - char buf[512]; FILE *fp = fopen("/proc/net/dev", "r"); + if (fp == NULL) { perror("fopen"); return -1; @@ -459,8 +459,10 @@ while (fgets(buf, sizeof(buf), fp) != NULL) { char *ptr; - buf[sizeof(buf) - 1] = 0; - if ((ptr = strchr(buf, ':')) == NULL || + + /*buf[sizeof(buf) - 1] = 0; - fgets is safe anyway */ + ptr = strchr(buf, ':'); + if (ptr == NULL || (*ptr++ = 0, sscanf(buf, "%s", name) != 1)) { bb_error_msg("wrong format of /proc/net/dev. Sorry"); return -1; @@ -541,6 +543,5 @@ } else return do_show(0, NULL); - bb_error_msg("command \"%s\" is unknown", *argv); - exit(-1); + bb_error_msg_and_die("command \"%s\" is unknown", *argv); } From vda at busybox.net Tue Jan 2 08:45:06 2007 From: vda at busybox.net (vda at busybox.net) Date: Tue, 2 Jan 2007 08:45:06 -0800 (PST) Subject: svn commit: trunk/busybox/util-linux Message-ID: <20070102164506.BD57C485D8@busybox.net> Author: vda Date: 2007-01-02 08:45:05 -0800 (Tue, 02 Jan 2007) New Revision: 17132 Log: silly style fixes Modified: trunk/busybox/util-linux/fdisk_osf.c Changeset: Modified: trunk/busybox/util-linux/fdisk_osf.c =================================================================== --- trunk/busybox/util-linux/fdisk_osf.c 2007-01-02 16:32:16 UTC (rev 17131) +++ trunk/busybox/util-linux/fdisk_osf.c 2007-01-02 16:45:05 UTC (rev 17132) @@ -43,13 +43,16 @@ #define BSD_LINUX_BOOTDIR "/usr/ucb/mdec" -#if defined (i386) || defined (__sparc__) || defined (__arm__) || defined (__m68k__) || defined (__mips__) || defined (__s390__) || defined (__sh__) || defined(__x86_64__) +#if defined(i386) || defined(__sparc__) || defined(__arm__) \ + || defined(__m68k__) || defined(__mips__) || defined(__s390__) \ + || defined(__sh__) || defined(__x86_64__) #define BSD_LABELSECTOR 1 #define BSD_LABELOFFSET 0 -#elif defined (__alpha__) || defined (__powerpc__) || defined (__ia64__) || defined (__hppa__) +#elif defined(__alpha__) || defined(__powerpc__) || defined(__ia64__) \ + || defined(__hppa__) #define BSD_LABELSECTOR 0 #define BSD_LABELOFFSET 64 -#elif defined (__s390__) || defined (__s390x__) +#elif defined(__s390__) || defined(__s390x__) #define BSD_LABELSECTOR 1 #define BSD_LABELOFFSET 0 #else @@ -258,18 +261,18 @@ static int xbsd_readlabel(struct partition *p, struct xbsd_disklabel *d); static int xbsd_writelabel(struct partition *p, struct xbsd_disklabel *d); -#if defined (__alpha__) +#if defined(__alpha__) static void alpha_bootblock_checksum(char *boot); #endif -#if !defined (__alpha__) +#if !defined(__alpha__) static int xbsd_translate_fstype(int linux_type); static void xbsd_link_part(void); static struct partition *xbsd_part; static int xbsd_part_index; #endif -#if defined (__alpha__) +#if defined(__alpha__) /* We access this through a uint64_t * when checksumming */ static char disklabelbuffer[BSD_BBSIZE] ATTRIBUTE_ALIGNED(8); #else @@ -298,36 +301,36 @@ static int btrydev(const char * dev) { - if (xbsd_readlabel (NULL, &xbsd_dlabel) == 0) + if (xbsd_readlabel(NULL, &xbsd_dlabel) == 0) return -1; printf(_("\nBSD label for device: %s\n"), dev); - xbsd_print_disklabel (0); + xbsd_print_disklabel(0); return 0; } static void bmenu(void) { - puts (_("Command action")); - puts (_("\td\tdelete a BSD partition")); - puts (_("\te\tedit drive data")); - puts (_("\ti\tinstall bootstrap")); - puts (_("\tl\tlist known filesystem types")); - puts (_("\tm\tprint this menu")); - puts (_("\tn\tadd a new BSD partition")); - puts (_("\tp\tprint BSD partition table")); - puts (_("\tq\tquit without saving changes")); - puts (_("\tr\treturn to main menu")); - puts (_("\ts\tshow complete disklabel")); - puts (_("\tt\tchange a partition's filesystem id")); - puts (_("\tu\tchange units (cylinders/sectors)")); - puts (_("\tw\twrite disklabel to disk")); -#if !defined (__alpha__) - puts (_("\tx\tlink BSD partition to non-BSD partition")); + puts(_("Command action")); + puts(_("\td\tdelete a BSD partition")); + puts(_("\te\tedit drive data")); + puts(_("\ti\tinstall bootstrap")); + puts(_("\tl\tlist known filesystem types")); + puts(_("\tm\tprint this menu")); + puts(_("\tn\tadd a new BSD partition")); + puts(_("\tp\tprint BSD partition table")); + puts(_("\tq\tquit without saving changes")); + puts(_("\tr\treturn to main menu")); + puts(_("\ts\tshow complete disklabel")); + puts(_("\tt\tchange a partition's filesystem id")); + puts(_("\tu\tchange units (cylinders/sectors)")); + puts(_("\tw\twrite disklabel to disk")); +#if !defined(__alpha__) + puts(_("\tx\tlink BSD partition to non-BSD partition")); #endif } -#if !defined (__alpha__) +#if !defined(__alpha__) static int hidden(int type) { @@ -347,7 +350,7 @@ static void bsd_select(void) { -#if !defined (__alpha__) +#if !defined(__alpha__) int t, ss; struct partition *p; @@ -376,11 +379,11 @@ return; } -#elif defined (__alpha__) +#elif defined(__alpha__) if (xbsd_readlabel(NULL, &xbsd_dlabel) == 0) if (xbsd_create_disklabel() == 0) - exit (EXIT_SUCCESS); + exit(EXIT_SUCCESS); #endif @@ -422,7 +425,7 @@ case 'w': xbsd_write_disklabel(); break; -#if !defined (__alpha__) +#if !defined(__alpha__) case 'x': xbsd_link_part(); break; @@ -458,7 +461,7 @@ if (!xbsd_check_new_partition(&i)) return; -#if !defined (__alpha__) && !defined (__powerpc__) && !defined (__hppa__) +#if !defined(__alpha__) && !defined(__powerpc__) && !defined(__hppa__) begin = get_start_sect(xbsd_part); end = begin + get_nr_sects(xbsd_part) - 1; #else @@ -475,8 +478,8 @@ snprintf(mesg, sizeof(mesg), _("Last %s or +size or +sizeM or +sizeK"), str_units(SINGULAR)); - end = read_int(bsd_cround (begin), bsd_cround (end), bsd_cround (end), - bsd_cround (begin), mesg); + end = read_int(bsd_cround(begin), bsd_cround(end), bsd_cround(end), + bsd_cround(begin), mesg); if (display_in_cyl_units) end = end * xbsd_dlabel.d_secpercyl - 1; @@ -494,7 +497,7 @@ int i, j; if (show_all) { -#if defined (__alpha__) +#if defined(__alpha__) printf("# %s:\n", disk_device); #else printf("# %s:\n", partname(disk_device, xbsd_part_index+1, 0)); @@ -587,7 +590,7 @@ static void xbsd_write_disklabel(void) { -#if defined (__alpha__) +#if defined(__alpha__) printf(_("Writing disklabel to %s.\n"), disk_device); xbsd_writelabel(NULL, &xbsd_dlabel); #else @@ -603,7 +606,7 @@ { char c; -#if defined (__alpha__) +#if defined(__alpha__) fprintf(stderr, _("%s contains no disklabel.\n"), disk_device); #else fprintf(stderr, _("%s contains no disklabel.\n"), @@ -614,14 +617,14 @@ c = read_nonempty(_("Do you want to create a disklabel? (y/n) ")); if (c == 'y' || c == 'Y') { if (xbsd_initlabel( -#if defined (__alpha__) || defined (__powerpc__) || defined (__hppa__) || \ - defined (__s390__) || defined (__s390x__) +#if defined(__alpha__) || defined(__powerpc__) || defined(__hppa__) || \ + defined(__s390__) || defined(__s390x__) NULL, &xbsd_dlabel #else xbsd_part, &xbsd_dlabel/* not used, xbsd_part_index*/ #endif ) == 1) { - xbsd_print_disklabel (1); + xbsd_print_disklabel(1); return 1; } else return 0; @@ -649,7 +652,7 @@ d = &xbsd_dlabel; -#if defined (__alpha__) || defined (__ia64__) +#if defined(__alpha__) || defined(__ia64__) d->d_secsize = edit_int(d->d_secsize ,_("bytes/sector")); d->d_nsectors = edit_int(d->d_nsectors ,_("sectors/track")); d->d_ntracks = edit_int(d->d_ntracks ,_("tracks/cylinder")); @@ -860,16 +863,16 @@ else d->d_type = BSD_DTYPE_ST506; -#if !defined (__alpha__) +#if !defined(__alpha__) d->d_flags = BSD_D_DOSPART; #else d->d_flags = 0; #endif d->d_secsize = SECTOR_SIZE; /* bytes/sector */ - d->d_nsectors = sectors; /* sectors/track */ - d->d_ntracks = heads; /* tracks/cylinder (heads) */ + d->d_nsectors = sectors; /* sectors/track */ + d->d_ntracks = heads; /* tracks/cylinder (heads) */ d->d_ncylinders = cylinders; - d->d_secpercyl = sectors * heads;/* sectors/cylinder */ + d->d_secpercyl = sectors * heads; /* sectors/cylinder */ if (d->d_secpercyl == 0) d->d_secpercyl = 1; /* avoid segfaults */ d->d_secperunit = d->d_secpercyl * d->d_ncylinders; @@ -885,19 +888,19 @@ d->d_bbsize = BSD_BBSIZE; d->d_sbsize = BSD_SBSIZE; -#if !defined (__alpha__) +#if !defined(__alpha__) d->d_npartitions = 4; - pp = &d->d_partitions[2]; /* Partition C should be - the NetBSD partition */ + pp = &d->d_partitions[2]; /* Partition C should be NetBSD partition */ + pp->p_offset = get_start_sect(p); pp->p_size = get_nr_sects(p); pp->p_fstype = BSD_FS_UNUSED; - pp = &d->d_partitions[3]; /* Partition D should be - the whole disk */ + pp = &d->d_partitions[3]; /* Partition D should be whole disk */ + pp->p_offset = 0; pp->p_size = d->d_secperunit; pp->p_fstype = BSD_FS_UNUSED; -#elif defined (__alpha__) +#elif defined(__alpha__) d->d_npartitions = 3; pp = &d->d_partitions[2]; /* Partition C should be the whole disk */ @@ -914,14 +917,14 @@ * If it has the right magic, return 1. */ static int -xbsd_readlabel (struct partition *p, struct xbsd_disklabel *d) +xbsd_readlabel(struct partition *p, struct xbsd_disklabel *d) { int t, sector; /* p is used only to get the starting sector */ -#if !defined (__alpha__) +#if !defined(__alpha__) sector = (p ? get_start_sect(p) : 0); -#elif defined (__alpha__) +#elif defined(__alpha__) sector = 0; #endif @@ -950,18 +953,18 @@ } static int -xbsd_writelabel (struct partition *p, struct xbsd_disklabel *d) +xbsd_writelabel(struct partition *p, struct xbsd_disklabel *d) { unsigned int sector; -#if !defined (__alpha__) && !defined (__powerpc__) && !defined (__hppa__) +#if !defined(__alpha__) && !defined(__powerpc__) && !defined(__hppa__) sector = get_start_sect(p) + BSD_LABELSECTOR; #else sector = BSD_LABELSECTOR; #endif d->d_checksum = 0; - d->d_checksum = xbsd_dkcksum (d); + d->d_checksum = xbsd_dkcksum(d); /* This is necessary if we want to write the bootstrap later, otherwise we'd write the old disklabel with the bootstrap. @@ -969,7 +972,7 @@ memmove(&disklabelbuffer[BSD_LABELSECTOR * SECTOR_SIZE + BSD_LABELOFFSET], d, sizeof(struct xbsd_disklabel)); -#if defined (__alpha__) && BSD_LABELSECTOR == 0 +#if defined(__alpha__) && BSD_LABELSECTOR == 0 alpha_bootblock_checksum(disklabelbuffer); if (lseek(fd, 0, SEEK_SET) == -1) fdisk_fatal(unable_to_seek); @@ -986,7 +989,7 @@ } -#if !defined (__alpha__) +#if !defined(__alpha__) static int xbsd_translate_fstype(int linux_type) { @@ -1024,12 +1027,8 @@ } #endif -#if defined (__alpha__) +#if defined(__alpha__) -#if !defined(__GLIBC__) -typedef unsigned long long uint64_t; -#endif - static void alpha_bootblock_checksum(char *boot) { From vda at busybox.net Tue Jan 2 16:39:17 2007 From: vda at busybox.net (vda at busybox.net) Date: Tue, 2 Jan 2007 16:39:17 -0800 (PST) Subject: svn commit: trunk/busybox: include util-linux Message-ID: <20070103003917.DF65448611@busybox.net> Author: vda Date: 2007-01-02 16:39:15 -0800 (Tue, 02 Jan 2007) New Revision: 17133 Log: introduce small[u]int fsck_minix: use it for flag variables. 140 bytes saved Modified: trunk/busybox/include/libbb.h trunk/busybox/util-linux/fsck_minix.c Changeset: Modified: trunk/busybox/include/libbb.h =================================================================== --- trunk/busybox/include/libbb.h 2007-01-02 16:45:05 UTC (rev 17132) +++ trunk/busybox/include/libbb.h 2007-01-03 00:39:15 UTC (rev 17133) @@ -191,6 +191,18 @@ extern int sysinfo(struct sysinfo* info); +/* Size-saving "small" ints (arch-dependent) */ +#if defined(i386) || defined (__mips__) +/* add other arches which benefit from this... */ +typedef signed char smallint; +typedef unsigned char smalluint; +#else +/* for arches where byte accesses generate larger code: */ +typedef int smallint; +typedef unsigned smalluint; +#endif + + extern void chomp(char *s); extern void trim(char *s); extern char *skip_whitespace(const char *); Modified: trunk/busybox/util-linux/fsck_minix.c =================================================================== --- trunk/busybox/util-linux/fsck_minix.c 2007-01-02 16:45:05 UTC (rev 17132) +++ trunk/busybox/util-linux/fsck_minix.c 2007-01-03 00:39:15 UTC (rev 17133) @@ -175,10 +175,6 @@ #define BLKGETSIZE _IO(0x12,96) /* return device size */ #endif -#ifndef __linux__ -#define volatile -#endif - enum { ROOT_INO = 1 }; #define UPPER(size,n) ((size+((n)-1))/(n)) @@ -197,25 +193,28 @@ static char *program_version = "1.2 - 11/11/96"; static char *device_name; static int IN; -static int repair, automatic, verbose, list, show, warn_mode, force; +static smallint repair, automatic, verbose, list, show, warn_mode, force; static int directory, regular, blockdev, chardev, links, symlinks, total; -static int changed; /* flags if the filesystem has been changed */ -static int errors_uncorrected; /* flag if some error was not corrected */ +static struct termios termios; +static smallint termios_set; + +static smallint changed; /* flags if the filesystem has been changed */ +static smallint errors_uncorrected; /* flag if some error was not corrected */ +//also smallint? static int dirsize = 16; static int namelen = 14; -static struct termios termios; -static int termios_set; static char *inode_buffer; #define Inode (((struct minix_inode *) inode_buffer)-1) #define Inode2 (((struct minix2_inode *) inode_buffer)-1) +//xzalloc? static char super_block_buffer[BLOCK_SIZE]; #define Super (*(struct minix_super_block *)super_block_buffer) #define INODES ((unsigned long)Super.s_ninodes) #ifdef CONFIG_FEATURE_MINIX2 -static int version2; +static smallint version2; #define ZONES ((unsigned long)(version2 ? Super.s_zones : Super.s_nzones)) #else #define ZONES ((unsigned long)(Super.s_nzones)) @@ -306,7 +305,8 @@ name_depth++; } -static void pop_filename(void) { +static void pop_filename(void) +{ name_depth--; if (name_depth < MAX_DEPTH) { *name_component[name_depth] = '\0'; @@ -399,7 +399,6 @@ printf("Check aborted\n"); exit(0); } - return; } /* @@ -408,7 +407,7 @@ * if an error was corrected, and returns the zone (0 for no zone * or a bad zone-number). */ -static int check_zone_nr2(uint32_t *nr, int *corrected) +static int check_zone_nr2(uint32_t *nr, smallint *corrected) { const char *msg; if (!*nr) @@ -427,7 +426,7 @@ return 0; } -static int check_zone_nr(uint16_t *nr, int *corrected) +static int check_zone_nr(uint16_t *nr, smallint *corrected) { uint32_t nr32 = *nr; int r = check_zone_nr2(&nr32, corrected); @@ -471,7 +470,7 @@ return; } if (BLOCK_SIZE * nr != lseek(IN, BLOCK_SIZE * nr, SEEK_SET)) - die("Seek failed in write_block"); + die("seek failed in write_block"); if (BLOCK_SIZE != write(IN, addr, BLOCK_SIZE)) { printf("%s: bad block in file '%s'\n", bb_msg_write_error, current_name); @@ -488,7 +487,8 @@ { uint16_t ind[BLOCK_SIZE >> 1]; uint16_t dind[BLOCK_SIZE >> 1]; - int blk_chg, block, result; + int block, result; + smallint blk_chg; if (blknr < 7) return check_zone_nr(inode->i_zone + blknr, &changed); @@ -524,7 +524,8 @@ uint32_t ind[BLOCK_SIZE >> 2]; uint32_t dind[BLOCK_SIZE >> 2]; uint32_t tind[BLOCK_SIZE >> 2]; - int blk_chg, block, result; + int block, result; + smallint blk_chg; if (blknr < 7) return check_zone_nr2(inode->i_zone + blknr, &changed); @@ -591,9 +592,9 @@ Super.s_state &= ~MINIX_ERROR_FS; if (BLOCK_SIZE != lseek(IN, BLOCK_SIZE, SEEK_SET)) - die("Seek failed in write_super_block"); + die("seek failed in write_super_block"); if (BLOCK_SIZE != write(IN, super_block_buffer, BLOCK_SIZE)) - die("Unable to write super-block"); + die("unable to write super-block"); } static void write_tables(void) @@ -601,11 +602,11 @@ write_super_block(); if (IMAPS * BLOCK_SIZE != write(IN, inode_map, IMAPS * BLOCK_SIZE)) - die("Unable to write inode map"); + die("unable to write inode map"); if (ZMAPS * BLOCK_SIZE != write(IN, zone_map, ZMAPS * BLOCK_SIZE)) - die("Unable to write zone map"); + die("unable to write zone map"); if (INODE_BUFFER_SIZE != write(IN, inode_buffer, INODE_BUFFER_SIZE)) - die("Unable to write inodes"); + die("unable to write inodes"); } static void get_dirsize(void) @@ -634,9 +635,9 @@ static void read_superblock(void) { if (BLOCK_SIZE != lseek(IN, BLOCK_SIZE, SEEK_SET)) - die("Seek failed"); + die("seek failed"); if (BLOCK_SIZE != read(IN, super_block_buffer, BLOCK_SIZE)) - die("Unable to read super block"); + die("unable to read super block"); /* already initialized to: namelen = 14; dirsize = 16; @@ -655,13 +656,13 @@ version2 = 1; #endif } else - die("Bad magic number in super-block"); + die("bad magic number in super-block"); if (ZONESIZE != 0 || BLOCK_SIZE != 1024) - die("Only 1k blocks/zones supported"); + die("only 1k blocks/zones supported"); if (IMAPS * BLOCK_SIZE * 8 < INODES + 1) - die("Bad s_imap_blocks field in super-block"); + die("bad s_imap_blocks field in super-block"); if (ZMAPS * BLOCK_SIZE * 8 < ZONES - FIRSTZONE + 1) - die("Bad s_zmap_blocks field in super-block"); + die("bad s_zmap_blocks field in super-block"); } static void read_tables(void) @@ -672,13 +673,13 @@ inode_count = xmalloc(INODES + 1); zone_count = xmalloc(ZONES); if (IMAPS * BLOCK_SIZE != read(IN, inode_map, IMAPS * BLOCK_SIZE)) - die("Unable to read inode map"); + die("unable to read inode map"); if (ZMAPS * BLOCK_SIZE != read(IN, zone_map, ZMAPS * BLOCK_SIZE)) - die("Unable to read zone map"); + die("unable to read zone map"); if (INODE_BUFFER_SIZE != read(IN, inode_buffer, INODE_BUFFER_SIZE)) - die("Unable to read inodes"); + die("unable to read inodes"); if (NORM_FIRSTZONE != FIRSTZONE) { - printf("Warning: Firstzone!=Norm_firstzone\n"); + printf("warning: firstzone!=norm_firstzone\n"); errors_uncorrected = 1; } get_dirsize(); @@ -796,7 +797,7 @@ struct minix_inode *inode = Inode + ROOT_INO; if (!inode || !S_ISDIR(inode->i_mode)) - die("Root inode isn't a directory"); + die("root inode isn't a directory"); } #ifdef CONFIG_FEATURE_MINIX2 @@ -805,11 +806,11 @@ struct minix2_inode *inode = Inode2 + ROOT_INO; if (!inode || !S_ISDIR(inode->i_mode)) - die("Root inode isn't a directory"); + die("root inode isn't a directory"); } #endif -static int add_zone(uint16_t *znr, int *corrected) +static int add_zone(uint16_t *znr, smallint *corrected) { int result; int block; @@ -840,7 +841,7 @@ } #ifdef CONFIG_FEATURE_MINIX2 -static int add_zone2(uint32_t *znr, int *corrected) +static int add_zone2(uint32_t *znr, smallint *corrected) { int result; int block; @@ -871,11 +872,12 @@ } #endif -static void add_zone_ind(uint16_t *znr, int *corrected) +static void add_zone_ind(uint16_t *znr, smallint *corrected) { static char blk[BLOCK_SIZE]; - int i, chg_blk = 0; + int i; int block; + smallint chg_blk = 0; block = add_zone(znr, corrected); if (!block) @@ -888,11 +890,12 @@ } #ifdef CONFIG_FEATURE_MINIX2 -static void add_zone_ind2(uint32_t *znr, int *corrected) +static void add_zone_ind2(uint32_t *znr, smallint *corrected) { static char blk[BLOCK_SIZE]; - int i, chg_blk = 0; + int i; int block; + smallint chg_blk = 0; block = add_zone2(znr, corrected); if (!block) @@ -905,52 +908,55 @@ } #endif -static void add_zone_dind(uint16_t *znr, int *corrected) +static void add_zone_dind(uint16_t *znr, smallint *corrected) { static char blk[BLOCK_SIZE]; - int i, blk_chg = 0; + int i; int block; + smallint chg_blk = 0; block = add_zone(znr, corrected); if (!block) return; read_block(block, blk); for (i = 0; i < (BLOCK_SIZE >> 1); i++) - add_zone_ind(i + (uint16_t *) blk, &blk_chg); - if (blk_chg) + add_zone_ind(i + (uint16_t *) blk, &chg_blk); + if (chg_blk) write_block(block, blk); } #ifdef CONFIG_FEATURE_MINIX2 -static void add_zone_dind2(uint32_t *znr, int *corrected) +static void add_zone_dind2(uint32_t *znr, smallint *corrected) { static char blk[BLOCK_SIZE]; - int i, blk_chg = 0; + int i; int block; + smallint chg_blk = 0; block = add_zone2(znr, corrected); if (!block) return; read_block(block, blk); for (i = 0; i < BLOCK_SIZE >> 2; i++) - add_zone_ind2(i + (uint32_t *) blk, &blk_chg); - if (blk_chg) + add_zone_ind2(i + (uint32_t *) blk, &chg_blk); + if (chg_blk) write_block(block, blk); } -static void add_zone_tind2(uint32_t *znr, int *corrected) +static void add_zone_tind2(uint32_t *znr, smallint *corrected) { static char blk[BLOCK_SIZE]; - int i, blk_chg = 0; + int i; int block; + smallint chg_blk = 0; block = add_zone2(znr, corrected); if (!block) return; read_block(block, blk); for (i = 0; i < BLOCK_SIZE >> 2; i++) - add_zone_dind2(i + (uint32_t *) blk, &blk_chg); - if (blk_chg) + add_zone_dind2(i + (uint32_t *) blk, &chg_blk); + if (chg_blk) write_block(block, blk); } #endif @@ -1043,7 +1049,6 @@ if (inode && S_ISDIR(inode->i_mode)) recursive_check(ino); pop_filename(); - return; } #ifdef CONFIG_FEATURE_MINIX2 @@ -1097,7 +1102,6 @@ if (inode && S_ISDIR(inode->i_mode)) recursive_check2(ino); pop_filename(); - return; } #endif @@ -1108,7 +1112,7 @@ dir = Inode + ino; if (!S_ISDIR(dir->i_mode)) - die("Internal error"); + die("internal error"); if (dir->i_size < 2 * dirsize) { printf("%s: bad directory: size<32", current_name); errors_uncorrected = 1; @@ -1125,7 +1129,7 @@ dir = Inode2 + ino; if (!S_ISDIR(dir->i_mode)) - die("Internal error"); + die("internal error"); if (dir->i_size < 2 * dirsize) { printf("%s: bad directory: size<32", current_name); errors_uncorrected = 1; @@ -1140,7 +1144,7 @@ char buffer[1024]; if (BLOCK_SIZE * i != lseek(IN, BLOCK_SIZE * i, SEEK_SET)) - die("Seek failed in bad_zone"); + die("seek failed in bad_zone"); return (BLOCK_SIZE != read(IN, buffer, BLOCK_SIZE)); } @@ -1280,10 +1284,10 @@ #endif if (INODE_SIZE * MINIX_INODES_PER_BLOCK != BLOCK_SIZE) - die("Bad inode size"); + die("bad inode size"); #ifdef CONFIG_FEATURE_MINIX2 if (INODE_SIZE2 * MINIX2_INODES_PER_BLOCK != BLOCK_SIZE) - die("Bad v2 inode size"); + die("bad v2 inode size"); #endif while (argc-- > 1) { argv++; @@ -1327,11 +1331,11 @@ check_mount(); /* trying to check a mounted filesystem? */ if (repair && !automatic) { if (!isatty(0) || !isatty(1)) - die("Need terminal for interactive repairs"); + die("need terminal for interactive repairs"); } IN = open(device_name, repair ? O_RDWR : O_RDONLY); - if (IN < 0){ - printf("Unable to open device '%s'\n", device_name); + if (IN < 0) { + printf("unable to open device '%s'\n", device_name); leave(8); } sync(); /* paranoia? */ @@ -1344,8 +1348,9 @@ * command line. */ printf("%s, %s\n", applet_name, program_version); - if (!(Super.s_state & MINIX_ERROR_FS) && - (Super.s_state & MINIX_VALID_FS) && !force) { + if (!(Super.s_state & MINIX_ERROR_FS) + && (Super.s_state & MINIX_VALID_FS) && !force + ) { if (repair) printf("%s is clean, check is skipped\n", device_name); return retcode; From vda at busybox.net Tue Jan 2 16:41:53 2007 From: vda at busybox.net (vda at busybox.net) Date: Tue, 2 Jan 2007 16:41:53 -0800 (PST) Subject: svn commit: trunk/busybox/util-linux Message-ID: <20070103004153.C0A7948611@busybox.net> Author: vda Date: 2007-01-02 16:41:53 -0800 (Tue, 02 Jan 2007) New Revision: 17134 Log: fsck_minix: optimizations. ~130 bytes Modified: trunk/busybox/util-linux/fsck_minix.c Changeset: Modified: trunk/busybox/util-linux/fsck_minix.c =================================================================== --- trunk/busybox/util-linux/fsck_minix.c 2007-01-03 00:39:15 UTC (rev 17133) +++ trunk/busybox/util-linux/fsck_minix.c 2007-01-03 00:41:53 UTC (rev 17134) @@ -122,7 +122,11 @@ uint32_t i_zone[10]; }; +/* Believe it or not, but mount.h has this one */ +#undef BLOCK_SIZE enum { + BLOCK_SIZE = 1024, + MINIX_ROOT_INO = 1, MINIX_LINK_MAX = 250, MINIX2_LINK_MAX = 65530, @@ -190,7 +194,7 @@ #define BITS_PER_BLOCK (BLOCK_SIZE<<3) -static char *program_version = "1.2 - 11/11/96"; +#define PROGRAM_VERSION "1.2 - 11/11/96" static char *device_name; static int IN; static smallint repair, automatic, verbose, list, show, warn_mode, force; @@ -335,7 +339,8 @@ printf(def ? "%s (y/n)? " : "%s (n/y)? ", string); for (;;) { fflush(stdout); - if ((c = getchar()) == EOF) { + c = getchar(); + if (c == EOF) { if (!def) errors_uncorrected = 1; return def; @@ -371,7 +376,8 @@ int cont; int fd; - if ((f = setmntent(MOUNTED, "r")) == NULL) + f = setmntent(MOUNTED, "r"); + if (f == NULL) return; while ((mnt = getmntent(f)) != NULL) if (strcmp(device_name, mnt->mnt_fsname) == 0) @@ -388,8 +394,7 @@ fd = open(MOUNTED, O_RDWR); if (fd < 0 && errno == EROFS) return; - else - close(fd); + close(fd); printf("%s is mounted. ", device_name); cont = 0; @@ -585,16 +590,14 @@ * are uncorrected errors. The filesystem valid flag is * unconditionally set if we get this far. */ - Super.s_state |= MINIX_VALID_FS; - if (errors_uncorrected) - Super.s_state |= MINIX_ERROR_FS; - else + Super.s_state |= MINIX_VALID_FS | MINIX_ERROR_FS; + if (!errors_uncorrected) Super.s_state &= ~MINIX_ERROR_FS; if (BLOCK_SIZE != lseek(IN, BLOCK_SIZE, SEEK_SET)) die("seek failed in write_super_block"); if (BLOCK_SIZE != write(IN, super_block_buffer, BLOCK_SIZE)) - die("unable to write super-block"); + die("cannot write super-block"); } static void write_tables(void) @@ -602,11 +605,11 @@ write_super_block(); if (IMAPS * BLOCK_SIZE != write(IN, inode_map, IMAPS * BLOCK_SIZE)) - die("unable to write inode map"); + die("cannot write inode map"); if (ZMAPS * BLOCK_SIZE != write(IN, zone_map, ZMAPS * BLOCK_SIZE)) - die("unable to write zone map"); + die("cannot write zone map"); if (INODE_BUFFER_SIZE != write(IN, inode_buffer, INODE_BUFFER_SIZE)) - die("unable to write inodes"); + die("cannot write inodes"); } static void get_dirsize(void) @@ -637,7 +640,7 @@ if (BLOCK_SIZE != lseek(IN, BLOCK_SIZE, SEEK_SET)) die("seek failed"); if (BLOCK_SIZE != read(IN, super_block_buffer, BLOCK_SIZE)) - die("unable to read super block"); + die("cannot read super block"); /* already initialized to: namelen = 14; dirsize = 16; @@ -673,11 +676,11 @@ inode_count = xmalloc(INODES + 1); zone_count = xmalloc(ZONES); if (IMAPS * BLOCK_SIZE != read(IN, inode_map, IMAPS * BLOCK_SIZE)) - die("unable to read inode map"); + die("cannot read inode map"); if (ZMAPS * BLOCK_SIZE != read(IN, zone_map, ZMAPS * BLOCK_SIZE)) - die("unable to read zone map"); + die("cannot read zone map"); if (INODE_BUFFER_SIZE != read(IN, inode_buffer, INODE_BUFFER_SIZE)) - die("unable to read inodes"); + die("cannot read inodes"); if (NORM_FIRSTZONE != FIRSTZONE) { printf("warning: firstzone!=norm_firstzone\n"); errors_uncorrected = 1; @@ -1024,18 +1027,16 @@ inode = get_inode(ino); pop_filename(); if (!offset) { - if (!inode || strcmp(".", name)) { - printf("%s: bad directory: '.' isn't first\n", current_name); - errors_uncorrected = 1; - } else + if (inode && LONE_CHAR(name, '.')) return; + printf("%s: bad directory: '.' isn't first\n", current_name); + errors_uncorrected = 1; } if (offset == dirsize) { - if (!inode || strcmp("..", name)) { - printf("%s: bad directory: '..' isn't second\n", current_name); - errors_uncorrected = 1; - } else + if (inode && strcmp("..", name) == 0) return; + printf("%s: bad directory: '..' isn't second\n", current_name); + errors_uncorrected = 1; } if (!inode) return; @@ -1077,18 +1078,16 @@ inode = get_inode2(ino); pop_filename(); if (!offset) { - if (!inode || strcmp(".", name)) { - printf("%s: bad directory: '.' isn't first\n", current_name); - errors_uncorrected = 1; - } else + if (inode && LONE_CHAR(name, '.')) return; + printf("%s: bad directory: '.' isn't first\n", current_name); + errors_uncorrected = 1; } if (offset == dirsize) { - if (!inode || strcmp("..", name)) { - printf("%s: bad directory: '..' isn't second\n", current_name); - errors_uncorrected = 1; - } else + if (inode && strcmp("..", name) == 0) return; + printf("%s: bad directory: '..' isn't second\n", current_name); + errors_uncorrected = 1; } if (!inode) return; @@ -1141,7 +1140,7 @@ static int bad_zone(int i) { - char buffer[1024]; + char buffer[BLOCK_SIZE]; if (BLOCK_SIZE * i != lseek(IN, BLOCK_SIZE * i, SEEK_SET)) die("seek failed in bad_zone"); @@ -1276,6 +1275,8 @@ struct termios tmp; int retcode = 0; + xfunc_exitcode = 8; + alloc_current_name(); #ifdef CONFIG_FEATURE_CLEAN_UP /* Don't bother to free memory. Exit does @@ -1289,15 +1290,14 @@ if (INODE_SIZE2 * MINIX2_INODES_PER_BLOCK != BLOCK_SIZE) die("bad v2 inode size"); #endif - while (argc-- > 1) { + while (--argc != 0) { argv++; if (argv[0][0] != '-') { if (device_name) bb_show_usage(); - else - device_name = argv[0]; - } else - while (*++argv[0]) + device_name = argv[0]; + } else { + while (*++argv[0]) { switch (argv[0][0]) { case 'l': list = 1; @@ -1325,9 +1325,12 @@ default: bb_show_usage(); } + } + } } if (!device_name) bb_show_usage(); + check_mount(); /* trying to check a mounted filesystem? */ if (repair && !automatic) { if (!isatty(0) || !isatty(1)) @@ -1335,10 +1338,9 @@ } IN = open(device_name, repair ? O_RDWR : O_RDONLY); if (IN < 0) { - printf("unable to open device '%s'\n", device_name); - leave(8); + bb_error_msg_and_die("cannot open device '%s'", device_name); } - sync(); /* paranoia? */ + /*sync(); paranoia? */ read_superblock(); /* @@ -1347,13 +1349,14 @@ * flags and whether or not the -f switch was specified on the * command line. */ - printf("%s, %s\n", applet_name, program_version); + printf("%s, "PROGRAM_VERSION"\n", applet_name); + if (!(Super.s_state & MINIX_ERROR_FS) && (Super.s_state & MINIX_VALID_FS) && !force ) { if (repair) printf("%s is clean, check is skipped\n", device_name); - return retcode; + return 0; } else if (force) printf("Forcing filesystem check on %s\n", device_name); else if (repair) From vda at busybox.net Tue Jan 2 16:43:20 2007 From: vda at busybox.net (vda at busybox.net) Date: Tue, 2 Jan 2007 16:43:20 -0800 (PST) Subject: svn commit: trunk/busybox/util-linux Message-ID: <20070103004320.6D8C448612@busybox.net> Author: vda Date: 2007-01-02 16:43:19 -0800 (Tue, 02 Jan 2007) New Revision: 17135 Log: factor out minix structures/constants into minix.h fsck_minix: optimizations Modified: trunk/busybox/util-linux/fsck_minix.c trunk/busybox/util-linux/mkfs_minix.c Changeset: Modified: trunk/busybox/util-linux/fsck_minix.c =================================================================== --- trunk/busybox/util-linux/fsck_minix.c 2007-01-03 00:41:53 UTC (rev 17134) +++ trunk/busybox/util-linux/fsck_minix.c 2007-01-03 00:43:19 UTC (rev 17135) @@ -90,162 +90,95 @@ #include "busybox.h" #include -/* - * This is the original minix inode layout on disk. - * Note the 8-bit gid and atime and ctime. - */ -struct minix_inode { - uint16_t i_mode; - uint16_t i_uid; - uint32_t i_size; - uint32_t i_time; - uint8_t i_gid; - uint8_t i_nlinks; - uint16_t i_zone[9]; -}; +#include "minix.h" -/* - * The new minix inode has all the time entries, as well as - * long block numbers and a third indirect block (7+1+1+1 - * instead of 7+1+1). Also, some previously 8-bit values are - * now 16-bit. The inode is now 64 bytes instead of 32. - */ -struct minix2_inode { - uint16_t i_mode; - uint16_t i_nlinks; - uint16_t i_uid; - uint16_t i_gid; - uint32_t i_size; - uint32_t i_atime; - uint32_t i_mtime; - uint32_t i_ctime; - uint32_t i_zone[10]; -}; +#ifndef BLKGETSIZE +#define BLKGETSIZE _IO(0x12,96) /* return device size */ +#endif -/* Believe it or not, but mount.h has this one */ -#undef BLOCK_SIZE +#ifdef UNUSED enum { - BLOCK_SIZE = 1024, - - MINIX_ROOT_INO = 1, - MINIX_LINK_MAX = 250, + MINIX1_LINK_MAX = 250, MINIX2_LINK_MAX = 65530, - MINIX_I_MAP_SLOTS = 8, MINIX_Z_MAP_SLOTS = 64, - MINIX_SUPER_MAGIC = 0x137F, /* original minix fs */ - MINIX_SUPER_MAGIC2 = 0x138F, /* minix fs, 30 char names */ - MINIX2_SUPER_MAGIC = 0x2468, /* minix V2 fs */ - MINIX2_SUPER_MAGIC2 = 0x2478, /* minix V2 fs, 30 char names */ - MINIX_VALID_FS = 0x0001, /* Clean fs. */ - MINIX_ERROR_FS = 0x0002, /* fs has errors. */ - - MINIX_INODES_PER_BLOCK = ((BLOCK_SIZE)/(sizeof (struct minix_inode))), - MINIX2_INODES_PER_BLOCK = ((BLOCK_SIZE)/(sizeof (struct minix2_inode))), - - MINIX_V1 = 0x0001, /* original minix fs */ - MINIX_V2 = 0x0002 /* minix V2 fs */ + MINIX_V1 = 0x0001, /* original minix fs */ + MINIX_V2 = 0x0002, /* minix V2 fs */ + NAME_MAX = 255, /* # chars in a file name */ }; - -#define INODE_VERSION(inode) inode->i_sb->u.minix_sb.s_version - -/* - * minix super-block data on disk - */ -struct minix_super_block { - uint16_t s_ninodes; - uint16_t s_nzones; - uint16_t s_imap_blocks; - uint16_t s_zmap_blocks; - uint16_t s_firstdatazone; - uint16_t s_log_zone_size; - uint32_t s_max_size; - uint16_t s_magic; - uint16_t s_state; - uint32_t s_zones; -}; - -struct minix_dir_entry { - uint16_t inode; - char name[0]; -}; - - -#define NAME_MAX 255 /* # chars in a file name */ - -#define MINIX_INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct minix_inode))) - -#ifndef BLKGETSIZE -#define BLKGETSIZE _IO(0x12,96) /* return device size */ #endif -enum { ROOT_INO = 1 }; - -#define UPPER(size,n) ((size+((n)-1))/(n)) -#define INODE_SIZE (sizeof(struct minix_inode)) -#ifdef CONFIG_FEATURE_MINIX2 -#define INODE_SIZE2 (sizeof(struct minix2_inode)) -#define INODE_BLOCKS UPPER(INODES, (version2 ? MINIX2_INODES_PER_BLOCK \ - : MINIX_INODES_PER_BLOCK)) +#if ENABLE_FEATURE_MINIX2 +static smallint version2; #else -#define INODE_BLOCKS UPPER(INODES, (MINIX_INODES_PER_BLOCK)) +enum { version2 = 0 }; #endif -#define INODE_BUFFER_SIZE (INODE_BLOCKS * BLOCK_SIZE) -#define BITS_PER_BLOCK (BLOCK_SIZE<<3) - #define PROGRAM_VERSION "1.2 - 11/11/96" -static char *device_name; -static int IN; static smallint repair, automatic, verbose, list, show, warn_mode, force; -static int directory, regular, blockdev, chardev, links, symlinks, total; +static smallint changed; /* is filesystem modified? */ +static smallint errors_uncorrected; /* flag if some error was not corrected */ -static struct termios termios; static smallint termios_set; +static struct termios termios; -static smallint changed; /* flags if the filesystem has been changed */ -static smallint errors_uncorrected; /* flag if some error was not corrected */ +static char *device_name; +static int IN; +static int directory, regular, blockdev, chardev, links, symlinks, total; + //also smallint? static int dirsize = 16; static int namelen = 14; static char *inode_buffer; -#define Inode (((struct minix_inode *) inode_buffer)-1) -#define Inode2 (((struct minix2_inode *) inode_buffer)-1) //xzalloc? static char super_block_buffer[BLOCK_SIZE]; +#define Inode1 (((struct minix1_inode *) inode_buffer)-1) +#define Inode2 (((struct minix2_inode *) inode_buffer)-1) + #define Super (*(struct minix_super_block *)super_block_buffer) -#define INODES ((unsigned long)Super.s_ninodes) -#ifdef CONFIG_FEATURE_MINIX2 -static smallint version2; -#define ZONES ((unsigned long)(version2 ? Super.s_zones : Super.s_nzones)) + +#if ENABLE_FEATURE_MINIX2 +# define ZONES ((unsigned)(version2 ? Super.s_zones : Super.s_nzones)) #else -#define ZONES ((unsigned long)(Super.s_nzones)) +# define ZONES ((unsigned)(Super.s_nzones)) #endif -#define IMAPS ((unsigned long)Super.s_imap_blocks) -#define ZMAPS ((unsigned long)Super.s_zmap_blocks) -#define FIRSTZONE ((unsigned long)Super.s_firstdatazone) -#define ZONESIZE ((unsigned long)Super.s_log_zone_size) -#define MAXSIZE ((unsigned long)Super.s_max_size) -#define MAGIC (Super.s_magic) -#define NORM_FIRSTZONE (2+IMAPS+ZMAPS+INODE_BLOCKS) +#define INODES ((unsigned)Super.s_ninodes) +#define IMAPS ((unsigned)Super.s_imap_blocks) +#define ZMAPS ((unsigned)Super.s_zmap_blocks) +#define FIRSTZONE ((unsigned)Super.s_firstdatazone) +#define ZONESIZE ((unsigned)Super.s_log_zone_size) +#define MAXSIZE ((unsigned)Super.s_max_size) +#define MAGIC (Super.s_magic) +/* gcc likes this more (code is smaller) than macro variant */ +static ATTRIBUTE_ALWAYS_INLINE unsigned div_roundup(unsigned size, unsigned n) +{ + return (size + n-1) / n; +} + +#if ENABLE_FEATURE_MINIX2 +#define INODE_BLOCKS div_roundup(INODES, (version2 ? MINIX2_INODES_PER_BLOCK \ + : MINIX1_INODES_PER_BLOCK)) +#else +#define INODE_BLOCKS div_roundup(INODES, MINIX1_INODES_PER_BLOCK) +#endif + +#define INODE_BUFFER_SIZE (INODE_BLOCKS * BLOCK_SIZE) +#define NORM_FIRSTZONE (2 + IMAPS + ZMAPS + INODE_BLOCKS) + static char *inode_map; static char *zone_map; static unsigned char *inode_count; static unsigned char *zone_count; -static void recursive_check(unsigned int ino); -#ifdef CONFIG_FEATURE_MINIX2 -static void recursive_check2(unsigned int ino); -#endif - static int bit(char *a, unsigned int i) { return (a[i >> 3] & (1<<(i & 7))) != 0; } + #define inode_in_use(x) (bit(inode_map,(x))) #define zone_in_use(x) (bit(zone_map,(x)-FIRSTZONE+1)) @@ -255,6 +188,12 @@ #define mark_zone(x) (setbit(zone_map,(x)-FIRSTZONE+1),changed=1) #define unmark_zone(x) (clrbit(zone_map,(x)-FIRSTZONE+1),changed=1) + +static void recursive_check(unsigned int ino); +#if ENABLE_FEATURE_MINIX2 +static void recursive_check2(unsigned int ino); +#endif + static void leave(int) ATTRIBUTE_NORETURN; static void leave(int status) { @@ -285,7 +224,7 @@ name_component[0] = ¤t_name[0]; } -#ifdef CONFIG_FEATURE_CLEAN_UP +#if ENABLE_FEATURE_CLEAN_UP /* execute this atexit() to deallocate name_list[] */ /* piptigger was here */ static void free_current_name(void) @@ -488,7 +427,7 @@ * It sets 'changed' if the inode has needed changing, and re-writes * any indirect blocks with errors. */ -static int map_block(struct minix_inode *inode, unsigned int blknr) +static int map_block(struct minix1_inode *inode, unsigned int blknr) { uint16_t ind[BLOCK_SIZE >> 1]; uint16_t dind[BLOCK_SIZE >> 1]; @@ -523,7 +462,7 @@ return result; } -#ifdef CONFIG_FEATURE_MINIX2 +#if ENABLE_FEATURE_MINIX2 static int map_block2(struct minix2_inode *inode, unsigned int blknr) { uint32_t ind[BLOCK_SIZE >> 2]; @@ -618,12 +557,12 @@ char blk[BLOCK_SIZE]; int size; -#ifdef CONFIG_FEATURE_MINIX2 +#if ENABLE_FEATURE_MINIX2 if (version2) - block = Inode2[ROOT_INO].i_zone[0]; + block = Inode2[MINIX_ROOT_INO].i_zone[0]; else #endif - block = Inode[ROOT_INO].i_zone[0]; + block = Inode1[MINIX_ROOT_INO].i_zone[0]; read_block(block, blk); for (size = 16; size < BLOCK_SIZE; size <<= 1) { if (strcmp(blk + size + 2, "..") == 0) { @@ -646,11 +585,11 @@ dirsize = 16; version2 = 0; */ - if (MAGIC == MINIX_SUPER_MAGIC) { - } else if (MAGIC == MINIX_SUPER_MAGIC2) { + if (MAGIC == MINIX1_SUPER_MAGIC) { + } else if (MAGIC == MINIX1_SUPER_MAGIC2) { namelen = 30; dirsize = 32; -#ifdef CONFIG_FEATURE_MINIX2 +#if ENABLE_FEATURE_MINIX2 } else if (MAGIC == MINIX2_SUPER_MAGIC) { version2 = 1; } else if (MAGIC == MINIX2_SUPER_MAGIC2) { @@ -687,13 +626,13 @@ } get_dirsize(); if (show) { - printf("%ld inodes\n" - "%ld blocks\n" - "Firstdatazone=%ld (%ld)\n" - "Zonesize=%d\n" - "Maxsize=%ld\n" - "Filesystem state=%d\n" - "namelen=%d\n\n", + printf("%u inodes\n" + "%u blocks\n" + "Firstdatazone=%u (%u)\n" + "Zonesize=%u\n" + "Maxsize=%u\n" + "Filesystem state=%u\n" + "namelen=%u\n\n", INODES, ZONES, FIRSTZONE, NORM_FIRSTZONE, @@ -704,17 +643,17 @@ } } -static struct minix_inode *get_inode(unsigned int nr) +static struct minix1_inode *get_inode(unsigned int nr) { - struct minix_inode *inode; + struct minix1_inode *inode; if (!nr || nr > INODES) return NULL; total++; - inode = Inode + nr; + inode = Inode1 + nr; if (!inode_count[nr]) { if (!inode_in_use(nr)) { - printf("Inode %d is marked as 'unused', but it is used " + printf("Inode1 %d is marked as 'unused', but it is used " "for file '%s'\n", nr, current_name); if (repair) { if (ask("Mark as 'in use'", 1)) @@ -749,7 +688,7 @@ return inode; } -#ifdef CONFIG_FEATURE_MINIX2 +#if ENABLE_FEATURE_MINIX2 static struct minix2_inode *get_inode2(unsigned int nr) { struct minix2_inode *inode; @@ -760,7 +699,7 @@ inode = Inode2 + nr; if (!inode_count[nr]) { if (!inode_in_use(nr)) { - printf("Inode %d is marked as 'unused', but it is used " + printf("Inode1 %d is marked as 'unused', but it is used " "for file '%s'\n", nr, current_name); if (repair) { if (ask("Mark as 'in use'", 1)) @@ -797,20 +736,22 @@ static void check_root(void) { - struct minix_inode *inode = Inode + ROOT_INO; + struct minix1_inode *inode = Inode1 + MINIX_ROOT_INO; if (!inode || !S_ISDIR(inode->i_mode)) die("root inode isn't a directory"); } -#ifdef CONFIG_FEATURE_MINIX2 +#if ENABLE_FEATURE_MINIX2 static void check_root2(void) { - struct minix2_inode *inode = Inode2 + ROOT_INO; + struct minix2_inode *inode = Inode2 + MINIX_ROOT_INO; if (!inode || !S_ISDIR(inode->i_mode)) die("root inode isn't a directory"); } +#else +void check_root2(void); #endif static int add_zone(uint16_t *znr, smallint *corrected) @@ -843,7 +784,7 @@ return block; } -#ifdef CONFIG_FEATURE_MINIX2 +#if ENABLE_FEATURE_MINIX2 static int add_zone2(uint32_t *znr, smallint *corrected) { int result; @@ -892,7 +833,7 @@ write_block(block, blk); } -#ifdef CONFIG_FEATURE_MINIX2 +#if ENABLE_FEATURE_MINIX2 static void add_zone_ind2(uint32_t *znr, smallint *corrected) { static char blk[BLOCK_SIZE]; @@ -928,7 +869,7 @@ write_block(block, blk); } -#ifdef CONFIG_FEATURE_MINIX2 +#if ENABLE_FEATURE_MINIX2 static void add_zone_dind2(uint32_t *znr, smallint *corrected) { static char blk[BLOCK_SIZE]; @@ -966,13 +907,13 @@ static void check_zones(unsigned int i) { - struct minix_inode *inode; + struct minix1_inode *inode; if (!i || i > INODES) return; if (inode_count[i] > 1) /* have we counted this file already? */ return; - inode = Inode + i; + inode = Inode1 + i; if (!S_ISDIR(inode->i_mode) && !S_ISREG(inode->i_mode) && !S_ISLNK(inode->i_mode)) return; for (i = 0; i < 7; i++) @@ -981,7 +922,7 @@ add_zone_dind(8 + inode->i_zone, &changed); } -#ifdef CONFIG_FEATURE_MINIX2 +#if ENABLE_FEATURE_MINIX2 static void check_zones2(unsigned int i) { struct minix2_inode *inode; @@ -1002,10 +943,10 @@ } #endif -static void check_file(struct minix_inode *dir, unsigned int offset) +static void check_file(struct minix1_inode *dir, unsigned int offset) { static char blk[BLOCK_SIZE]; - struct minix_inode *inode; + struct minix1_inode *inode; int ino; char *name; int block; @@ -1052,7 +993,7 @@ pop_filename(); } -#ifdef CONFIG_FEATURE_MINIX2 +#if ENABLE_FEATURE_MINIX2 static void check_file2(struct minix2_inode *dir, unsigned int offset) { static char blk[BLOCK_SIZE]; @@ -1106,10 +1047,10 @@ static void recursive_check(unsigned int ino) { - struct minix_inode *dir; + struct minix1_inode *dir; unsigned int offset; - dir = Inode + ino; + dir = Inode1 + ino; if (!S_ISDIR(dir->i_mode)) die("internal error"); if (dir->i_size < 2 * dirsize) { @@ -1120,7 +1061,7 @@ check_file(dir, offset); } -#ifdef CONFIG_FEATURE_MINIX2 +#if ENABLE_FEATURE_MINIX2 static void recursive_check2(unsigned int ino) { struct minix2_inode *dir; @@ -1152,10 +1093,10 @@ int i; for (i = 1; i <= INODES; i++) { - if (warn_mode && Inode[i].i_mode && !inode_in_use(i)) { - printf("Inode %d has non-zero mode. ", i); + if (warn_mode && Inode1[i].i_mode && !inode_in_use(i)) { + printf("Inode1 %d has non-zero mode. ", i); if (ask("Clear", 1)) { - Inode[i].i_mode = 0; + Inode1[i].i_mode = 0; changed = 1; } } @@ -1168,15 +1109,15 @@ continue; } if (!inode_in_use(i)) { - printf("Inode %d is used, but marked as 'unused' in the bitmap. ", i); + printf("Inode1 %d is used, but marked as 'unused' in the bitmap. ", i); if (ask("Set", 1)) mark_inode(i); } - if (Inode[i].i_nlinks != inode_count[i]) { - printf("Inode %d (mode=%07o), i_nlinks=%d, counted=%d. ", - i, Inode[i].i_mode, Inode[i].i_nlinks, inode_count[i]); + if (Inode1[i].i_nlinks != inode_count[i]) { + printf("Inode1 %d (mode=%07o), i_nlinks=%d, counted=%d. ", + i, Inode1[i].i_mode, Inode1[i].i_nlinks, inode_count[i]); if (ask("Set i_nlinks to count", 1)) { - Inode[i].i_nlinks = inode_count[i]; + Inode1[i].i_nlinks = inode_count[i]; changed = 1; } } @@ -1197,14 +1138,14 @@ } } -#ifdef CONFIG_FEATURE_MINIX2 +#if ENABLE_FEATURE_MINIX2 static void check_counts2(void) { int i; for (i = 1; i <= INODES; i++) { if (warn_mode && Inode2[i].i_mode && !inode_in_use(i)) { - printf("Inode %d has non-zero mode. ", i); + printf("Inode1 %d has non-zero mode. ", i); if (ask("Clear", 1)) { Inode2[i].i_mode = 0; changed = 1; @@ -1219,7 +1160,7 @@ continue; } if (!inode_in_use(i)) { - printf("Inode %d is used, but marked as 'unused' in the bitmap. ", i); + printf("Inode1 %d is used, but marked as 'unused' in the bitmap. ", i); if (ask("Set", 1)) mark_inode(i); } @@ -1254,20 +1195,22 @@ { memset(inode_count, 0, (INODES + 1) * sizeof(*inode_count)); memset(zone_count, 0, ZONES * sizeof(*zone_count)); - check_zones(ROOT_INO); - recursive_check(ROOT_INO); + check_zones(MINIX_ROOT_INO); + recursive_check(MINIX_ROOT_INO); check_counts(); } -#ifdef CONFIG_FEATURE_MINIX2 +#if ENABLE_FEATURE_MINIX2 static void check2(void) { memset(inode_count, 0, (INODES + 1) * sizeof(*inode_count)); memset(zone_count, 0, ZONES * sizeof(*zone_count)); - check_zones2(ROOT_INO); - recursive_check2(ROOT_INO); + check_zones2(MINIX_ROOT_INO); + recursive_check2(MINIX_ROOT_INO); check_counts2(); } +#else +void check2(void); #endif int fsck_minix_main(int argc, char **argv) @@ -1275,18 +1218,18 @@ struct termios tmp; int retcode = 0; - xfunc_exitcode = 8; + xfunc_error_retval = 8; alloc_current_name(); -#ifdef CONFIG_FEATURE_CLEAN_UP +#if ENABLE_FEATURE_CLEAN_UP /* Don't bother to free memory. Exit does * that automagically, so we can save a few bytes */ atexit(free_current_name); #endif - if (INODE_SIZE * MINIX_INODES_PER_BLOCK != BLOCK_SIZE) + if (INODE_SIZE1 * MINIX1_INODES_PER_BLOCK != BLOCK_SIZE) die("bad inode size"); -#ifdef CONFIG_FEATURE_MINIX2 +#if ENABLE_FEATURE_MINIX2 if (INODE_SIZE2 * MINIX2_INODES_PER_BLOCK != BLOCK_SIZE) die("bad v2 inode size"); #endif @@ -1336,10 +1279,8 @@ if (!isatty(0) || !isatty(1)) die("need terminal for interactive repairs"); } - IN = open(device_name, repair ? O_RDWR : O_RDONLY); - if (IN < 0) { - bb_error_msg_and_die("cannot open device '%s'", device_name); - } + IN = xopen(device_name, repair ? O_RDWR : O_RDONLY); + /*sync(); paranoia? */ read_superblock(); @@ -1372,36 +1313,35 @@ tcsetattr(0, TCSANOW, &tmp); termios_set = 1; } -#ifdef CONFIG_FEATURE_MINIX2 + if (version2) { check_root2(); check2(); - } else -#endif - { + } else { check_root(); check(); } + if (verbose) { int i, free_cnt; for (i = 1, free_cnt = 0; i <= INODES; i++) if (!inode_in_use(i)) free_cnt++; - printf("\n%6ld inodes used (%ld%%)\n", (INODES - free_cnt), + printf("\n%6u inodes used (%u%%)\n", (INODES - free_cnt), 100 * (INODES - free_cnt) / INODES); for (i = FIRSTZONE, free_cnt = 0; i < ZONES; i++) if (!zone_in_use(i)) free_cnt++; - printf("%6ld zones used (%ld%%)\n\n" - "%6d regular files\n" - "%6d directories\n" - "%6d character device files\n" - "%6d block device files\n" - "%6d links\n" - "%6d symbolic links\n" + printf("%6u zones used (%u%%)\n\n" + "%6u regular files\n" + "%6u directories\n" + "%6u character device files\n" + "%6u block device files\n" + "%6u links\n" + "%6u symbolic links\n" "------\n" - "%6d files\n", + "%6u files\n", (ZONES - free_cnt), 100 * (ZONES - free_cnt) / ZONES, regular, directory, chardev, blockdev, links - 2 * directory + 1, symlinks, Modified: trunk/busybox/util-linux/mkfs_minix.c =================================================================== --- trunk/busybox/util-linux/mkfs_minix.c 2007-01-03 00:41:53 UTC (rev 17134) +++ trunk/busybox/util-linux/mkfs_minix.c 2007-01-03 00:43:19 UTC (rev 17135) @@ -65,6 +65,8 @@ #include "busybox.h" #include +#include "minix.h" + #define DEBUG 0 /* If debugging, store the very same times/uids/gids for image consistency */ @@ -78,81 +80,8 @@ # define GETGID getgid() #endif -/* - * This is the original minix inode layout on disk. - * Note the 8-bit gid and atime and ctime. - */ -struct minix1_inode { - uint16_t i_mode; - uint16_t i_uid; - uint32_t i_size; - uint32_t i_time; - uint8_t i_gid; - uint8_t i_nlinks; - uint16_t i_zone[9]; -}; - -/* - * The new minix inode has all the time entries, as well as - * long block numbers and a third indirect block (7+1+1+1 - * instead of 7+1+1). Also, some previously 8-bit values are - * now 16-bit. The inode is now 64 bytes instead of 32. - */ -struct minix2_inode { - uint16_t i_mode; - uint16_t i_nlinks; - uint16_t i_uid; - uint16_t i_gid; - uint32_t i_size; - uint32_t i_atime; - uint32_t i_mtime; - uint32_t i_ctime; - uint32_t i_zone[10]; -}; - -/* - * minix super-block data on disk - */ -struct minix_super_block { - uint16_t s_ninodes; - uint16_t s_nzones; - uint16_t s_imap_blocks; - uint16_t s_zmap_blocks; - uint16_t s_firstdatazone; - uint16_t s_log_zone_size; - uint32_t s_max_size; - uint16_t s_magic; - uint16_t s_state; - uint32_t s_zones; -}; - -struct minix_dir_entry { - uint16_t inode; - char name[0]; -}; - -/* Believe it or not, but mount.h has this one */ -#undef BLOCK_SIZE enum { - BLOCK_SIZE = 1024, - BITS_PER_BLOCK = BLOCK_SIZE << 3, - - MINIX_ROOT_INO = 1, - MINIX_BAD_INO = 2, MAX_GOOD_BLOCKS = 512, - - MINIX1_SUPER_MAGIC = 0x137F, /* original minix fs */ - MINIX1_SUPER_MAGIC2 = 0x138F, /* minix fs, 30 char names */ - MINIX2_SUPER_MAGIC = 0x2468, /* minix V2 fs */ - MINIX2_SUPER_MAGIC2 = 0x2478, /* minix V2 fs, 30 char names */ - MINIX_VALID_FS = 0x0001, /* clean fs */ - MINIX_ERROR_FS = 0x0002, /* fs has errors */ - - INODE_SIZE1 = sizeof(struct minix1_inode), - INODE_SIZE2 = sizeof(struct minix2_inode), - MINIX1_INODES_PER_BLOCK = BLOCK_SIZE / sizeof(struct minix1_inode), - MINIX2_INODES_PER_BLOCK = BLOCK_SIZE / sizeof(struct minix2_inode), - TEST_BUFFER_BLOCKS = 16, }; From vda at busybox.net Tue Jan 2 16:45:06 2007 From: vda at busybox.net (vda at busybox.net) Date: Tue, 2 Jan 2007 16:45:06 -0800 (PST) Subject: svn commit: trunk/busybox/util-linux Message-ID: <20070103004506.2431B48611@busybox.net> Author: vda Date: 2007-01-02 16:45:05 -0800 (Tue, 02 Jan 2007) New Revision: 17136 Log: fbset: move variable from data to bss fsck_minix: fix fallout Modified: trunk/busybox/util-linux/fbset.c trunk/busybox/util-linux/fsck_minix.c Changeset: Modified: trunk/busybox/util-linux/fbset.c =================================================================== --- trunk/busybox/util-linux/fbset.c 2007-01-03 00:43:19 UTC (rev 17135) +++ trunk/busybox/util-linux/fbset.c 2007-01-03 00:45:05 UTC (rev 17136) @@ -61,7 +61,7 @@ #endif }; -static unsigned int g_options = 0; +static unsigned g_options; /* Stuff stolen from the kernel's fb.h */ #define FB_ACTIVATE_ALL 64 Modified: trunk/busybox/util-linux/fsck_minix.c =================================================================== --- trunk/busybox/util-linux/fsck_minix.c 2007-01-03 00:43:19 UTC (rev 17135) +++ trunk/busybox/util-linux/fsck_minix.c 2007-01-03 00:45:05 UTC (rev 17136) @@ -174,7 +174,7 @@ static unsigned char *inode_count; static unsigned char *zone_count; -static int bit(char *a, unsigned int i) +static int bit(char *a, unsigned i) { return (a[i >> 3] & (1<<(i & 7))) != 0; } @@ -189,9 +189,9 @@ #define unmark_zone(x) (clrbit(zone_map,(x)-FIRSTZONE+1),changed=1) -static void recursive_check(unsigned int ino); +static void recursive_check(unsigned ino); #if ENABLE_FEATURE_MINIX2 -static void recursive_check2(unsigned int ino); +static void recursive_check2(unsigned ino); #endif static void leave(int) ATTRIBUTE_NORETURN; @@ -381,7 +381,7 @@ /* * read-block reads block nr into the buffer at addr. */ -static void read_block(unsigned int nr, char *addr) +static void read_block(unsigned nr, char *addr) { if (!nr) { memset(addr, 0, BLOCK_SIZE); @@ -403,7 +403,7 @@ /* * write_block writes block nr to disk. */ -static void write_block(unsigned int nr, char *addr) +static void write_block(unsigned nr, char *addr) { if (!nr) return; @@ -427,7 +427,7 @@ * It sets 'changed' if the inode has needed changing, and re-writes * any indirect blocks with errors. */ -static int map_block(struct minix1_inode *inode, unsigned int blknr) +static int map_block(struct minix1_inode *inode, unsigned blknr) { uint16_t ind[BLOCK_SIZE >> 1]; uint16_t dind[BLOCK_SIZE >> 1]; @@ -463,7 +463,7 @@ } #if ENABLE_FEATURE_MINIX2 -static int map_block2(struct minix2_inode *inode, unsigned int blknr) +static int map_block2(struct minix2_inode *inode, unsigned blknr) { uint32_t ind[BLOCK_SIZE >> 2]; uint32_t dind[BLOCK_SIZE >> 2]; @@ -643,7 +643,7 @@ } } -static struct minix1_inode *get_inode(unsigned int nr) +static struct minix1_inode *get_inode(unsigned nr) { struct minix1_inode *inode; @@ -653,7 +653,7 @@ inode = Inode1 + nr; if (!inode_count[nr]) { if (!inode_in_use(nr)) { - printf("Inode1 %d is marked as 'unused', but it is used " + printf("Inode %d is marked as 'unused', but it is used " "for file '%s'\n", nr, current_name); if (repair) { if (ask("Mark as 'in use'", 1)) @@ -689,7 +689,7 @@ } #if ENABLE_FEATURE_MINIX2 -static struct minix2_inode *get_inode2(unsigned int nr) +static struct minix2_inode *get_inode2(unsigned nr) { struct minix2_inode *inode; @@ -699,7 +699,7 @@ inode = Inode2 + nr; if (!inode_count[nr]) { if (!inode_in_use(nr)) { - printf("Inode1 %d is marked as 'unused', but it is used " + printf("Inode %d is marked as 'unused', but it is used " "for file '%s'\n", nr, current_name); if (repair) { if (ask("Mark as 'in use'", 1)) @@ -905,7 +905,7 @@ } #endif -static void check_zones(unsigned int i) +static void check_zones(unsigned i) { struct minix1_inode *inode; @@ -923,7 +923,7 @@ } #if ENABLE_FEATURE_MINIX2 -static void check_zones2(unsigned int i) +static void check_zones2(unsigned i) { struct minix2_inode *inode; @@ -943,7 +943,7 @@ } #endif -static void check_file(struct minix1_inode *dir, unsigned int offset) +static void check_file(struct minix1_inode *dir, unsigned offset) { static char blk[BLOCK_SIZE]; struct minix1_inode *inode; @@ -994,7 +994,7 @@ } #if ENABLE_FEATURE_MINIX2 -static void check_file2(struct minix2_inode *dir, unsigned int offset) +static void check_file2(struct minix2_inode *dir, unsigned offset) { static char blk[BLOCK_SIZE]; struct minix2_inode *inode; @@ -1045,10 +1045,10 @@ } #endif -static void recursive_check(unsigned int ino) +static void recursive_check(unsigned ino) { struct minix1_inode *dir; - unsigned int offset; + unsigned offset; dir = Inode1 + ino; if (!S_ISDIR(dir->i_mode)) @@ -1062,10 +1062,10 @@ } #if ENABLE_FEATURE_MINIX2 -static void recursive_check2(unsigned int ino) +static void recursive_check2(unsigned ino) { struct minix2_inode *dir; - unsigned int offset; + unsigned offset; dir = Inode2 + ino; if (!S_ISDIR(dir->i_mode)) @@ -1094,7 +1094,7 @@ for (i = 1; i <= INODES; i++) { if (warn_mode && Inode1[i].i_mode && !inode_in_use(i)) { - printf("Inode1 %d has non-zero mode. ", i); + printf("Inode %d has non-zero mode. ", i); if (ask("Clear", 1)) { Inode1[i].i_mode = 0; changed = 1; @@ -1109,12 +1109,12 @@ continue; } if (!inode_in_use(i)) { - printf("Inode1 %d is used, but marked as 'unused' in the bitmap. ", i); + printf("Inode %d is used, but marked as 'unused' in the bitmap. ", i); if (ask("Set", 1)) mark_inode(i); } if (Inode1[i].i_nlinks != inode_count[i]) { - printf("Inode1 %d (mode=%07o), i_nlinks=%d, counted=%d. ", + printf("Inode %d (mode=%07o), i_nlinks=%d, counted=%d. ", i, Inode1[i].i_mode, Inode1[i].i_nlinks, inode_count[i]); if (ask("Set i_nlinks to count", 1)) { Inode1[i].i_nlinks = inode_count[i]; @@ -1145,7 +1145,7 @@ for (i = 1; i <= INODES; i++) { if (warn_mode && Inode2[i].i_mode && !inode_in_use(i)) { - printf("Inode1 %d has non-zero mode. ", i); + printf("Inode %d has non-zero mode. ", i); if (ask("Clear", 1)) { Inode2[i].i_mode = 0; changed = 1; @@ -1160,7 +1160,7 @@ continue; } if (!inode_in_use(i)) { - printf("Inode1 %d is used, but marked as 'unused' in the bitmap. ", i); + printf("Inode %d is used, but marked as 'unused' in the bitmap. ", i); if (ask("Set", 1)) mark_inode(i); } From vda at busybox.net Tue Jan 2 16:47:48 2007 From: vda at busybox.net (vda at busybox.net) Date: Tue, 2 Jan 2007 16:47:48 -0800 (PST) Subject: svn commit: trunk/busybox/util-linux Message-ID: <20070103004748.2F5544860F@busybox.net> Author: vda Date: 2007-01-02 16:47:47 -0800 (Tue, 02 Jan 2007) New Revision: 17137 Log: forgot to svn add util-linux/minix.h :( Added: trunk/busybox/util-linux/minix.h Modified: trunk/busybox/util-linux/fsck_minix.c Changeset: Modified: trunk/busybox/util-linux/fsck_minix.c =================================================================== --- trunk/busybox/util-linux/fsck_minix.c 2007-01-03 00:45:05 UTC (rev 17136) +++ trunk/busybox/util-linux/fsck_minix.c 2007-01-03 00:47:47 UTC (rev 17137) @@ -176,7 +176,7 @@ static int bit(char *a, unsigned i) { - return (a[i >> 3] & (1<<(i & 7))) != 0; + return (a[i >> 3] & (1<<(i & 7))) != 0; } #define inode_in_use(x) (bit(inode_map,(x))) Added: trunk/busybox/util-linux/minix.h =================================================================== --- trunk/busybox/util-linux/minix.h 2007-01-03 00:45:05 UTC (rev 17136) +++ trunk/busybox/util-linux/minix.h 2007-01-03 00:47:47 UTC (rev 17137) @@ -0,0 +1,76 @@ +/* + * This is the original minix inode layout on disk. + * Note the 8-bit gid and atime and ctime. + */ +struct minix1_inode { + uint16_t i_mode; + uint16_t i_uid; + uint32_t i_size; + uint32_t i_time; + uint8_t i_gid; + uint8_t i_nlinks; + uint16_t i_zone[9]; +}; + +/* + * The new minix inode has all the time entries, as well as + * long block numbers and a third indirect block (7+1+1+1 + * instead of 7+1+1). Also, some previously 8-bit values are + * now 16-bit. The inode is now 64 bytes instead of 32. + */ +struct minix2_inode { + uint16_t i_mode; + uint16_t i_nlinks; + uint16_t i_uid; + uint16_t i_gid; + uint32_t i_size; + uint32_t i_atime; + uint32_t i_mtime; + uint32_t i_ctime; + uint32_t i_zone[10]; +}; + +/* + * minix super-block data on disk + */ +struct minix_super_block { + uint16_t s_ninodes; + uint16_t s_nzones; + uint16_t s_imap_blocks; + uint16_t s_zmap_blocks; + uint16_t s_firstdatazone; + uint16_t s_log_zone_size; + uint32_t s_max_size; + uint16_t s_magic; + uint16_t s_state; + uint32_t s_zones; +}; + +struct minix_dir_entry { + uint16_t inode; + char name[0]; +}; + +/* Believe it or not, but mount.h has this one #defined */ +#undef BLOCK_SIZE + +enum { + BLOCK_SIZE = 1024, + BITS_PER_BLOCK = BLOCK_SIZE << 3, + + MINIX_ROOT_INO = 1, + MINIX_BAD_INO = 2, + + MINIX1_SUPER_MAGIC = 0x137F, /* original minix fs */ + MINIX1_SUPER_MAGIC2 = 0x138F, /* minix fs, 30 char names */ + MINIX2_SUPER_MAGIC = 0x2468, /* minix V2 fs */ + MINIX2_SUPER_MAGIC2 = 0x2478, /* minix V2 fs, 30 char names */ + MINIX_VALID_FS = 0x0001, /* clean fs */ + MINIX_ERROR_FS = 0x0002, /* fs has errors */ + + INODE_SIZE1 = sizeof(struct minix1_inode), + INODE_SIZE2 = sizeof(struct minix2_inode), + MINIX1_INODES_PER_BLOCK = BLOCK_SIZE / sizeof(struct minix1_inode), + MINIX2_INODES_PER_BLOCK = BLOCK_SIZE / sizeof(struct minix2_inode), +}; + From vda at busybox.net Tue Jan 2 17:36:44 2007 From: vda at busybox.net (vda at busybox.net) Date: Tue, 2 Jan 2007 17:36:44 -0800 (PST) Subject: svn commit: trunk/busybox/util-linux Message-ID: <20070103013644.4F3F148619@busybox.net> Author: vda Date: 2007-01-02 17:36:42 -0800 (Tue, 02 Jan 2007) New Revision: 17138 Log: fsck_minix: tiny optimization Modified: trunk/busybox/util-linux/fsck_minix.c Changeset: Modified: trunk/busybox/util-linux/fsck_minix.c =================================================================== --- trunk/busybox/util-linux/fsck_minix.c 2007-01-03 00:47:47 UTC (rev 17137) +++ trunk/busybox/util-linux/fsck_minix.c 2007-01-03 01:36:42 UTC (rev 17138) @@ -194,20 +194,14 @@ static void recursive_check2(unsigned ino); #endif -static void leave(int) ATTRIBUTE_NORETURN; -static void leave(int status) +static void die(const char *str) ATTRIBUTE_NORETURN; +static void die(const char *str) { if (termios_set) tcsetattr(0, TCSANOW, &termios); - exit(status); + bb_error_msg_and_die("%s", str); } -static void die(const char *str) -{ - bb_error_msg("%s", str); - leave(8); -} - /* File-name data */ enum { MAX_DEPTH = 32 }; static int name_depth; From vda at busybox.net Tue Jan 2 17:57:26 2007 From: vda at busybox.net (vda at busybox.net) Date: Tue, 2 Jan 2007 17:57:26 -0800 (PST) Subject: svn commit: trunk/busybox: archival archival/libunarchive include Message-ID: <20070103015726.4B62448617@busybox.net> Author: vda Date: 2007-01-02 17:57:25 -0800 (Tue, 02 Jan 2007) New Revision: 17139 Log: extern variable declaration in a .c file is heresy - fixing it Modified: trunk/busybox/archival/libunarchive/decompress_unzip.c trunk/busybox/archival/unzip.c trunk/busybox/include/unarchive.h Changeset: Modified: trunk/busybox/archival/libunarchive/decompress_unzip.c =================================================================== --- trunk/busybox/archival/libunarchive/decompress_unzip.c 2007-01-03 01:36:42 UTC (rev 17138) +++ trunk/busybox/archival/libunarchive/decompress_unzip.c 2007-01-03 01:57:25 UTC (rev 17139) @@ -45,8 +45,11 @@ } v; } huft_t; +/* Globally-visible data */ +off_t gunzip_bytes_out; /* number of output bytes */ +uint32_t gunzip_crc; + static int gunzip_src_fd; -unsigned int gunzip_bytes_out; /* number of output bytes */ static unsigned int gunzip_outbuf_count; /* bytes in output buffer */ /* gunzip_window size--must be a power of two, and @@ -55,7 +58,6 @@ static unsigned char *gunzip_window; static uint32_t *gunzip_crc_table; -uint32_t gunzip_crc; /* If BMAX needs to be larger than 16, then h and x[] should be ulg. */ #define BMAX 16 /* maximum bit length of any code (16 for explode) */ Modified: trunk/busybox/archival/unzip.c =================================================================== --- trunk/busybox/archival/unzip.c 2007-01-03 01:36:42 UTC (rev 17138) +++ trunk/busybox/archival/unzip.c 2007-01-03 01:57:25 UTC (rev 17139) @@ -32,9 +32,6 @@ #define ZIP_CDS_END_MAGIC SWAP_LE32(0x06054b50) #define ZIP_DD_MAGIC SWAP_LE32(0x08074b50) -extern unsigned int gunzip_crc; -extern unsigned int gunzip_bytes_out; - typedef union { unsigned char raw[26]; struct { Modified: trunk/busybox/include/unarchive.h =================================================================== --- trunk/busybox/include/unarchive.h 2007-01-03 01:36:42 UTC (rev 17138) +++ trunk/busybox/include/unarchive.h 2007-01-03 01:57:25 UTC (rev 17139) @@ -64,6 +64,11 @@ } archive_handle_t; + +extern uint32_t gunzip_crc; +extern off_t gunzip_bytes_out; + + extern archive_handle_t *init_handle(void); extern char filter_accept_all(archive_handle_t *archive_handle); From vda at busybox.net Tue Jan 2 18:56:02 2007 From: vda at busybox.net (vda at busybox.net) Date: Tue, 2 Jan 2007 18:56:02 -0800 (PST) Subject: svn commit: trunk/busybox: include init libbb miscutils networking etc... Message-ID: <20070103025602.63E9E4860B@busybox.net> Author: vda Date: 2007-01-02 18:56:00 -0800 (Tue, 02 Jan 2007) New Revision: 17140 Log: convert calloc to xzalloc fix sleep-on-die option Modified: trunk/busybox/include/libbb.h trunk/busybox/init/init.c trunk/busybox/libbb/error_msg_and_die.c trunk/busybox/libbb/fflush_stdout_and_exit.c trunk/busybox/libbb/herror_msg_and_die.c trunk/busybox/libbb/perror_msg_and_die.c trunk/busybox/miscutils/crond.c trunk/busybox/networking/httpd.c trunk/busybox/util-linux/fdisk_sgi.c Changeset: Modified: trunk/busybox/include/libbb.h =================================================================== --- trunk/busybox/include/libbb.h 2007-01-03 01:57:25 UTC (rev 17139) +++ trunk/busybox/include/libbb.h 2007-01-03 02:56:00 UTC (rev 17140) @@ -397,6 +397,7 @@ extern int logmode; extern int die_sleep; extern int xfunc_error_retval; +extern void sleep_and_die(void) ATTRIBUTE_NORETURN; extern void bb_show_usage(void) ATTRIBUTE_NORETURN ATTRIBUTE_EXTERNALLY_VISIBLE; extern void bb_error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))); extern void bb_error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2))); Modified: trunk/busybox/init/init.c =================================================================== --- trunk/busybox/init/init.c 2007-01-03 01:57:25 UTC (rev 17139) +++ trunk/busybox/init/init.c 2007-01-03 02:56:00 UTC (rev 17140) @@ -19,7 +19,7 @@ #include "init_shared.h" -#ifdef CONFIG_SYSLOGD +#if ENABLE_SYSLOGD # include #endif @@ -60,7 +60,7 @@ #define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin" #endif -#if defined CONFIG_FEATURE_INIT_COREDUMPS +#if ENABLE_FEATURE_INIT_COREDUMPS /* * When a file named CORE_ENABLE_FLAG_FILE exists, setrlimit is called * before processes are spawned to set core file size as unlimited. @@ -121,7 +121,7 @@ static struct init_action *init_action_list = NULL; static char console[CONSOLE_BUFF_SIZE] = CONSOLE_DEV; -#ifndef CONFIG_SYSLOGD +#if !ENABLE_SYSLOGD static char *log_console = VC_5; #endif #if !ENABLE_DEBUG_INIT @@ -132,7 +132,7 @@ LOG = 0x1, CONSOLE = 0x2, -#if defined CONFIG_FEATURE_EXTRA_QUIET +#if ENABLE_FEATURE_EXTRA_QUIET MAYBE_CONSOLE = 0x0, #else MAYBE_CONSOLE = CONSOLE, @@ -162,11 +162,13 @@ static void shutdown_signal(int sig); #endif +#if !ENABLE_DEBUG_INIT static void loop_forever(void) { while (1) sleep(1); } +#endif /* Print a message to the specified device. * Device may be bitwise-or'd from LOG | CONSOLE */ @@ -182,7 +184,7 @@ va_list arguments; int l; RESERVE_CONFIG_BUFFER(msg, 1024); -#ifndef CONFIG_SYSLOGD +#if !ENABLE_SYSLOGD static int log_fd = -1; #endif @@ -191,7 +193,7 @@ l = vsnprintf(msg + 1, 1024 - 2, fmt, arguments) + 1; va_end(arguments); -#ifdef CONFIG_SYSLOGD +#if ENABLE_SYSLOGD /* Log the message to syslogd */ if (device & LOG) { /* don`t out "\r\n" */ @@ -313,7 +315,7 @@ } if (fd < 0) { /* Perhaps we should panic here? */ -#ifndef CONFIG_SYSLOGD +#if !ENABLE_SYSLOGD log_console = #endif safe_strncpy(console, bb_dev_null, sizeof(console)); @@ -325,7 +327,7 @@ * if TERM is set to linux (the default) */ if (s == NULL || strcmp(s, "linux") == 0) putenv("TERM=vt102"); -#ifndef CONFIG_SYSLOGD +#if !ENABLE_SYSLOGD log_console = console; #endif } else { @@ -510,7 +512,7 @@ cmd[0][0] = '-'; strcpy(cmd[0] + 1, s); } -#ifdef CONFIG_FEATURE_INIT_SCTTY +#if ENABLE_FEATURE_INIT_SCTTY /* Establish this process as session leader and * (attempt) to make the tty (if any) a controlling tty. */ @@ -543,7 +545,7 @@ message(LOG, "Starting pid %d, console %s: '%s'", getpid(), a->terminal, cmdpath); -#if defined CONFIG_FEATURE_INIT_COREDUMPS +#if ENABLE_FEATURE_INIT_COREDUMPS { struct stat sb; if (stat(CORE_ENABLE_FLAG_FILE, &sb) == 0) { @@ -622,11 +624,12 @@ /* We have to fork here, since the kernel calls do_exit(0) in * linux/kernel/sys.c, which can cause the machine to panic when * the init process is killed.... */ - if ((pid = fork()) == 0) { + pid = vfork(); + if (pid == 0) { /* child */ reboot(magic); _exit(0); } - waitpid (pid, NULL, 0); + waitpid(pid, NULL, 0); } static void shutdown_system(void) @@ -746,7 +749,6 @@ sleep(2); init_reboot(rb); - loop_forever(); } @@ -785,11 +787,7 @@ if (strcmp(cons, bb_dev_null) == 0 && (action & ASKFIRST)) return; - new_action = calloc((size_t) (1), sizeof(struct init_action)); - if (!new_action) { - message(LOG | CONSOLE, "Memory allocation failure"); - loop_forever(); - } + new_action = xzalloc(sizeof(struct init_action)); /* Append to the end of the list */ for (a = last = init_action_list; a; a = a->next) { @@ -841,7 +839,7 @@ */ static void parse_inittab(void) { -#ifdef CONFIG_FEATURE_USE_INITTAB +#if ENABLE_FEATURE_USE_INITTAB FILE *file; char buf[INIT_BUFFS_SIZE], lineAsRead[INIT_BUFFS_SIZE]; char tmpConsole[CONSOLE_BUFF_SIZE]; @@ -870,7 +868,7 @@ new_init_action(SYSINIT, INIT_SCRIPT, ""); return; -#ifdef CONFIG_FEATURE_USE_INITTAB +#if ENABLE_FEATURE_USE_INITTAB } while (fgets(buf, INIT_BUFFS_SIZE, file) != NULL) { @@ -941,10 +939,10 @@ } fclose(file); return; -#endif /* CONFIG_FEATURE_USE_INITTAB */ +#endif /* FEATURE_USE_INITTAB */ } -#ifdef CONFIG_FEATURE_USE_INITTAB +#if ENABLE_FEATURE_USE_INITTAB static void reload_signal(int sig ATTRIBUTE_UNUSED) { struct init_action *a, *tmp; @@ -969,13 +967,15 @@ run_actions(RESPAWN); return; } -#endif /* CONFIG_FEATURE_USE_INITTAB */ +#endif /* FEATURE_USE_INITTAB */ int init_main(int argc, char **argv) { struct init_action *a; pid_t wpid; + die_sleep = 30 * 24*60*60; /* if xmalloc will ever die... */ + if (argc > 1 && !strcmp(argv[1], "-q")) { return kill(1,SIGHUP); } @@ -1062,7 +1062,7 @@ parse_inittab(); } -#ifdef CONFIG_SELINUX +#if ENABLE_SELINUX if (getenv("SELINUX_INIT") == NULL) { int enforce = 0; @@ -1092,12 +1092,12 @@ /* Next run anything to be run only once */ run_actions(ONCE); -#ifdef CONFIG_FEATURE_USE_INITTAB +#if ENABLE_FEATURE_USE_INITTAB /* Redefine SIGHUP to reread /etc/inittab */ signal(SIGHUP, reload_signal); #else signal(SIGHUP, SIG_IGN); -#endif /* CONFIG_FEATURE_USE_INITTAB */ +#endif /* FEATURE_USE_INITTAB */ /* Now run the looping stuff for the rest of forever */ Modified: trunk/busybox/libbb/error_msg_and_die.c =================================================================== --- trunk/busybox/libbb/error_msg_and_die.c 2007-01-03 01:57:25 UTC (rev 17139) +++ trunk/busybox/libbb/error_msg_and_die.c 2007-01-03 02:56:00 UTC (rev 17140) @@ -15,6 +15,13 @@ int die_sleep; +void sleep_and_die(void) +{ + if (die_sleep) + sleep(die_sleep); + exit(xfunc_error_retval); +} + void bb_error_msg_and_die(const char *s, ...) { va_list p; @@ -22,7 +29,5 @@ va_start(p, s); bb_verror_msg(s, p, NULL); va_end(p); - if (die_sleep) - sleep(die_sleep); - exit(xfunc_error_retval); + sleep_and_die(); } Modified: trunk/busybox/libbb/fflush_stdout_and_exit.c =================================================================== --- trunk/busybox/libbb/fflush_stdout_and_exit.c 2007-01-03 01:57:25 UTC (rev 17139) +++ trunk/busybox/libbb/fflush_stdout_and_exit.c 2007-01-03 02:56:00 UTC (rev 17140) @@ -15,10 +15,7 @@ void fflush_stdout_and_exit(int retval) { - if (fflush(stdout)) { - retval = xfunc_error_retval; - } - if (die_sleep) - sleep(die_sleep); + if (fflush(stdout)) + sleep_and_die(); exit(retval); } Modified: trunk/busybox/libbb/herror_msg_and_die.c =================================================================== --- trunk/busybox/libbb/herror_msg_and_die.c 2007-01-03 01:57:25 UTC (rev 17139) +++ trunk/busybox/libbb/herror_msg_and_die.c 2007-01-03 02:56:00 UTC (rev 17140) @@ -19,7 +19,5 @@ va_start(p, s); bb_vherror_msg(s, p); va_end(p); - if (die_sleep) - sleep(die_sleep); - exit(xfunc_error_retval); + sleep_and_die(); } Modified: trunk/busybox/libbb/perror_msg_and_die.c =================================================================== --- trunk/busybox/libbb/perror_msg_and_die.c 2007-01-03 01:57:25 UTC (rev 17139) +++ trunk/busybox/libbb/perror_msg_and_die.c 2007-01-03 02:56:00 UTC (rev 17140) @@ -20,7 +20,5 @@ va_start(p, s); bb_vperror_msg(s, p); va_end(p); - if (die_sleep) - sleep(die_sleep); - exit(xfunc_error_retval); + sleep_and_die(); } Modified: trunk/busybox/miscutils/crond.c =================================================================== --- trunk/busybox/miscutils/crond.c 2007-01-03 01:57:25 UTC (rev 17139) +++ trunk/busybox/miscutils/crond.c 2007-01-03 02:56:00 UTC (rev 17140) @@ -542,7 +542,7 @@ struct stat sbuf; if (fstat(fileno(fi), &sbuf) == 0 && sbuf.st_uid == DaemonUid) { - CronFile *file = calloc(1, sizeof(CronFile)); + CronFile *file = xzalloc(sizeof(CronFile)); CronLine **pline; file->cf_User = strdup(fileName); @@ -586,7 +586,7 @@ FixDayDow(&line); - *pline = calloc(1, sizeof(CronLine)); + *pline = xzalloc(sizeof(CronLine)); **pline = line; /* copy command */ Modified: trunk/busybox/networking/httpd.c =================================================================== --- trunk/busybox/networking/httpd.c 2007-01-03 01:57:25 UTC (rev 17139) +++ trunk/busybox/networking/httpd.c 2007-01-03 02:56:00 UTC (rev 17140) @@ -499,7 +499,7 @@ continue; if (*p0 == 'A' || *p0 == 'D') { /* storing current config IP line */ - pip = calloc(1, sizeof(Htaccess_IP)); + pip = xzalloc(sizeof(Htaccess_IP)); if (pip) { if (scan_ip_mask(c, &(pip->ip), &(pip->mask))) { /* syntax IP{/mask} error detected, protect all */ @@ -570,7 +570,7 @@ || ENABLE_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES \ || ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR /* storing current config line */ - cur = calloc(1, sizeof(Htaccess) + strlen(p0)); + cur = xzalloc(sizeof(Htaccess) + strlen(p0)); if (cur) { cf = strcpy(cur->before_colon, p0); c = strchr(cf, ':'); Modified: trunk/busybox/util-linux/fdisk_sgi.c =================================================================== --- trunk/busybox/util-linux/fdisk_sgi.c 2007-01-03 01:57:25 UTC (rev 17139) +++ trunk/busybox/util-linux/fdisk_sgi.c 2007-01-03 02:56:00 UTC (rev 17140) @@ -869,7 +869,7 @@ static sgiinfo * fill_sgiinfo(void) { - sgiinfo *info = calloc(1, sizeof(sgiinfo)); + sgiinfo *info = xzalloc(sizeof(sgiinfo)); info->magic = SGI_SSWAP32(SGI_INFO_MAGIC); info->b1 = SGI_SSWAP32(-1); From vda at busybox.net Tue Jan 2 18:58:56 2007 From: vda at busybox.net (vda at busybox.net) Date: Tue, 2 Jan 2007 18:58:56 -0800 (PST) Subject: svn commit: trunk/busybox/util-linux Message-ID: <20070103025856.69DD648616@busybox.net> Author: vda Date: 2007-01-02 18:58:54 -0800 (Tue, 02 Jan 2007) New Revision: 17141 Log: fdisk: remove 8k buffer from bss - OSF labels are not THAT common anyway Modified: trunk/busybox/util-linux/fdisk.c trunk/busybox/util-linux/fdisk_osf.c trunk/busybox/util-linux/fdisk_sgi.c Changeset: Modified: trunk/busybox/util-linux/fdisk.c =================================================================== --- trunk/busybox/util-linux/fdisk.c 2007-01-03 02:56:00 UTC (rev 17140) +++ trunk/busybox/util-linux/fdisk.c 2007-01-03 02:58:54 UTC (rev 17141) @@ -2715,7 +2715,7 @@ static void -try(const char *device, int user_specified) +trydev(const char *device, int user_specified) { int gb; @@ -2736,7 +2736,7 @@ return; } #if ENABLE_FEATURE_OSF_LABEL - if (btrydev(device) < 0) + if (bsd_trydev(device) < 0) #endif printf(_("Disk %s doesn't contain a valid " "partition table\n"), device); @@ -2780,7 +2780,7 @@ if (isdigit(s[-1])) continue; sprintf(devname, "/dev/%s", ptname); - try(devname, 0); + trydev(devname, 0); } #if ENABLE_FEATURE_CLEAN_UP fclose(procpt); @@ -2865,7 +2865,7 @@ #endif listing = 1; for (k = 0; k < argc; k++) - try(argv[k], 1); + trydev(argv[k], 1); } else { /* we no longer have default device names */ /* but, we can use /proc/partitions instead */ Modified: trunk/busybox/util-linux/fdisk_osf.c =================================================================== --- trunk/busybox/util-linux/fdisk_osf.c 2007-01-03 02:56:00 UTC (rev 17140) +++ trunk/busybox/util-linux/fdisk_osf.c 2007-01-03 02:58:54 UTC (rev 17141) @@ -272,12 +272,9 @@ static int xbsd_part_index; #endif -#if defined(__alpha__) /* We access this through a uint64_t * when checksumming */ -static char disklabelbuffer[BSD_BBSIZE] ATTRIBUTE_ALIGNED(8); -#else -static char disklabelbuffer[BSD_BBSIZE]; -#endif +/* hopefully xmalloc gives us required alignment */ +static char *disklabelbuffer; /*[BSD_BBSIZE]*/ static struct xbsd_disklabel xbsd_dlabel; @@ -299,7 +296,7 @@ } static int -btrydev(const char * dev) +bsd_trydev(const char * dev) { if (xbsd_readlabel(NULL, &xbsd_dlabel) == 0) return -1; @@ -309,7 +306,7 @@ } static void -bmenu(void) +bsd_menu(void) { puts(_("Command action")); puts(_("\td\tdelete a BSD partition")); @@ -431,7 +428,7 @@ break; #endif default: - bmenu(); + bsd_menu(); break; } } @@ -921,6 +918,9 @@ { int t, sector; + if (!disklabelbuffer) + disklabelbuffer = xmalloc(BSD_BBSIZE); + /* p is used only to get the starting sector */ #if !defined(__alpha__) sector = (p ? get_start_sect(p) : 0); Modified: trunk/busybox/util-linux/fdisk_sgi.c =================================================================== --- trunk/busybox/util-linux/fdisk_sgi.c 2007-01-03 02:56:00 UTC (rev 17140) +++ trunk/busybox/util-linux/fdisk_sgi.c 2007-01-03 02:58:54 UTC (rev 17141) @@ -808,42 +808,43 @@ } memset(MBRbuffer, 0, sizeof(MBRbuffer)); + /* fields with '//' are already zeroed out by memset above */ + sgilabel->magic = SGI_SSWAP32(SGI_LABEL_MAGIC); - sgilabel->boot_part = SGI_SSWAP16(0); + //sgilabel->boot_part = SGI_SSWAP16(0); sgilabel->swap_part = SGI_SSWAP16(1); - /* sizeof(sgilabel->boot_file) = 16 > 6 */ - memset(sgilabel->boot_file, 0, 16); - strcpy((char*)sgilabel->boot_file, "/unix"); + //memset(sgilabel->boot_file, 0, 16); + strcpy((char*)sgilabel->boot_file, "/unix"); /* sizeof(sgilabel->boot_file) == 16 > 6 */ - sgilabel->devparam.skew = (0); - sgilabel->devparam.gap1 = (0); - sgilabel->devparam.gap2 = (0); - sgilabel->devparam.sparecyl = (0); + //sgilabel->devparam.skew = (0); + //sgilabel->devparam.gap1 = (0); + //sgilabel->devparam.gap2 = (0); + //sgilabel->devparam.sparecyl = (0); sgilabel->devparam.pcylcount = SGI_SSWAP16(geometry.cylinders); - sgilabel->devparam.head_vol0 = SGI_SSWAP16(0); + //sgilabel->devparam.head_vol0 = SGI_SSWAP16(0); + /* tracks/cylinder (heads) */ sgilabel->devparam.ntrks = SGI_SSWAP16(geometry.heads); - /* tracks/cylinder (heads) */ - sgilabel->devparam.cmd_tag_queue_depth = (0); - sgilabel->devparam.unused0 = (0); - sgilabel->devparam.unused1 = SGI_SSWAP16(0); + //sgilabel->devparam.cmd_tag_queue_depth = (0); + //sgilabel->devparam.unused0 = (0); + //sgilabel->devparam.unused1 = SGI_SSWAP16(0); + /* sectors/track */ sgilabel->devparam.nsect = SGI_SSWAP16(geometry.sectors); - /* sectors/track */ sgilabel->devparam.bytes = SGI_SSWAP16(512); sgilabel->devparam.ilfact = SGI_SSWAP16(1); sgilabel->devparam.flags = SGI_SSWAP32(TRACK_FWD| IGNORE_ERRORS|RESEEK); - sgilabel->devparam.datarate = SGI_SSWAP32(0); + //sgilabel->devparam.datarate = SGI_SSWAP32(0); sgilabel->devparam.retries_on_error = SGI_SSWAP32(1); - sgilabel->devparam.ms_per_word = SGI_SSWAP32(0); - sgilabel->devparam.xylogics_gap1 = SGI_SSWAP16(0); - sgilabel->devparam.xylogics_syncdelay = SGI_SSWAP16(0); - sgilabel->devparam.xylogics_readdelay = SGI_SSWAP16(0); - sgilabel->devparam.xylogics_gap2 = SGI_SSWAP16(0); - sgilabel->devparam.xylogics_readgate = SGI_SSWAP16(0); - sgilabel->devparam.xylogics_writecont = SGI_SSWAP16(0); - memset( &(sgilabel->directory), 0, sizeof(struct volume_directory)*15 ); - memset( &(sgilabel->partitions), 0, sizeof(struct sgi_partinfo)*16 ); + //sgilabel->devparam.ms_per_word = SGI_SSWAP32(0); + //sgilabel->devparam.xylogics_gap1 = SGI_SSWAP16(0); + //sgilabel->devparam.xylogics_syncdelay = SGI_SSWAP16(0); + //sgilabel->devparam.xylogics_readdelay = SGI_SSWAP16(0); + //sgilabel->devparam.xylogics_gap2 = SGI_SSWAP16(0); + //sgilabel->devparam.xylogics_readgate = SGI_SSWAP16(0); + //sgilabel->devparam.xylogics_writecont = SGI_SSWAP16(0); + //memset( &(sgilabel->directory), 0, sizeof(struct volume_directory)*15 ); + //memset( &(sgilabel->partitions), 0, sizeof(struct sgi_partinfo)*16 ); current_label_type = label_sgi; partitions = 16; sgi_volumes = 15; From vda at busybox.net Tue Jan 2 19:16:00 2007 From: vda at busybox.net (vda at busybox.net) Date: Tue, 2 Jan 2007 19:16:00 -0800 (PST) Subject: svn commit: trunk/busybox/findutils Message-ID: <20070103031600.A964F48616@busybox.net> Author: vda Date: 2007-01-02 19:15:58 -0800 (Tue, 02 Jan 2007) New Revision: 17142 Log: find: fix misplaced #else (fix by Harald Kuthe ) Modified: trunk/busybox/findutils/find.c Changeset: Modified: trunk/busybox/findutils/find.c =================================================================== --- trunk/busybox/findutils/find.c 2007-01-03 02:58:54 UTC (rev 17141) +++ trunk/busybox/findutils/find.c 2007-01-03 03:15:58 UTC (rev 17142) @@ -551,14 +551,15 @@ for (i = 1; i < firstopt; i++) { /* not xstat(): shouldn't bomb out on * "find not_exist exist -xdev" */ - if (stat(argv[i], &stbuf)) stbuf.st_dev = -1L; + if (stat(argv[i], &stbuf)) + stbuf.st_dev = -1L; xdev_dev[i-1] = stbuf.st_dev; } } argp[0] = "-a"; } +#endif argp++; -#endif } actions = parse_params(&argv[firstopt]); From bugs at busybox.net Wed Jan 3 03:59:26 2007 From: bugs at busybox.net (bugs at busybox.net) Date: Wed, 3 Jan 2007 03:59:26 -0800 Subject: [BusyBox 0001140]: wget host header missing port Message-ID: The following issue has been SUBMITTED. ====================================================================== http://busybox.net/bugs/view.php?id=1140 ====================================================================== Reported By: stan Assigned To: BusyBox ====================================================================== Project: BusyBox Issue ID: 1140 Category: Networking Support Reproducibility: always Severity: minor Priority: normal Status: assigned ====================================================================== Date Submitted: 01-03-2007 03:59 PST Last Modified: 01-03-2007 03:59 PST ====================================================================== Summary: wget host header missing port Description: The port isn't included in the host header when it is different to port 80. Relevant line: fprintf(sfp, "Host: %s\r\nUser-Agent: Wget\r\n", target.host); ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 01-03-07 03:59 stan New Issue 01-03-07 03:59 stan Status new => assigned 01-03-07 03:59 stan Assigned To => BusyBox ====================================================================== From bugs at busybox.net Wed Jan 3 08:25:57 2007 From: bugs at busybox.net (bugs at busybox.net) Date: Wed, 3 Jan 2007 08:25:57 -0800 Subject: [BusyBox 0001074]: msh Umlauts Problem Message-ID: <3a46d95feda8802d6a05121f3ffea30a@bugs.busybox.net> A NOTE has been added to this issue. ====================================================================== http://busybox.net/bugs/view.php?id=1074 ====================================================================== Reported By: zapp Assigned To: BusyBox ====================================================================== Project: BusyBox Issue ID: 1074 Category: Other Reproducibility: always Severity: minor Priority: normal Status: assigned ====================================================================== Date Submitted: 10-19-2006 08:17 PDT Last Modified: 01-03-2007 08:25 PST ====================================================================== Summary: msh Umlauts Problem Description: msh has problems with german umlauts (maybe other 8bit chars, too). Reproduce: # loadkeys de-latin1 # echo '?' D # touch testfile-???.txt # ls testfile* testfile-dv|.txt ====================================================================== ---------------------------------------------------------------------- vda - 01-03-07 08:25 ---------------------------------------------------------------------- I can't reproduce it - don't know how to type that characters. Can you attach a testcase in the form of shell script? Issue History Date Modified Username Field Change ====================================================================== 10-19-06 08:17 zapp New Issue 10-19-06 08:17 zapp Status new => assigned 10-19-06 08:17 zapp Assigned To => BusyBox 01-03-07 08:25 vda Note Added: 0001950 ====================================================================== From vda at busybox.net Wed Jan 3 12:07:07 2007 From: vda at busybox.net (vda at busybox.net) Date: Wed, 3 Jan 2007 12:07:07 -0800 (PST) Subject: svn commit: trunk/busybox/coreutils Message-ID: <20070103200707.4C9AF48628@busybox.net> Author: vda Date: 2007-01-03 12:07:06 -0800 (Wed, 03 Jan 2007) New Revision: 17145 Log: chown: fix handling of "user.group" notation Modified: trunk/busybox/coreutils/chown.c Changeset: Modified: trunk/busybox/coreutils/chown.c =================================================================== --- trunk/busybox/coreutils/chown.c 2007-01-03 14:11:16 UTC (rev 17144) +++ trunk/busybox/coreutils/chown.c 2007-01-03 20:07:06 UTC (rev 17145) @@ -13,8 +13,7 @@ #include "busybox.h" -static uid_t uid = -1; -static gid_t gid = -1; +static struct bb_uidgid_t ugid = { -1, -1 }; static int (*chown_func)(const char *, uid_t, gid_t) = chown; @@ -38,12 +37,14 @@ // if (depth ... && S_ISLNK(statbuf->st_mode)) .... if (!chown_func(fileName, - (uid == (uid_t)-1) ? statbuf->st_uid : uid, - (gid == (gid_t)-1) ? statbuf->st_gid : gid)) { + (ugid.uid == (uid_t)-1) ? statbuf->st_uid : ugid.uid, + (ugid.gid == (gid_t)-1) ? statbuf->st_gid : ugid.gid) + ) { if (OPT_VERBOSE - || (OPT_CHANGED && (statbuf->st_uid != uid || statbuf->st_gid != gid)) + || (OPT_CHANGED && (statbuf->st_uid != ugid.uid || statbuf->st_gid != ugid.gid)) ) { - printf("changed ownership of '%s' to %u:%u\n", fileName, uid, gid); + printf("changed ownership of '%s' to %u:%u\n", + fileName, ugid.uid, ugid.gid); } return TRUE; } @@ -65,23 +66,21 @@ /* First, check if there is a group name here */ groupName = strchr(*argv, '.'); /* deprecated? */ - if (!groupName) { + if (!groupName) groupName = strchr(*argv, ':'); - } + else + *groupName = ':'; /* replace '.' with ':' */ /* First, try parsing "user[:[group]]" */ if (!groupName) { /* "user" */ - uid = get_ug_id(*argv, xuname2uid); + ugid.uid = get_ug_id(*argv, xuname2uid); } else if (groupName == *argv) { /* ":group" */ - gid = get_ug_id(groupName + 1, xgroup2gid); + ugid.gid = get_ug_id(groupName + 1, xgroup2gid); } else { - struct bb_uidgid_t ugid; if (!groupName[1]) /* "user:" */ *groupName = '\0'; if (!get_uidgid(&ugid, *argv, 1)) bb_error_msg_and_die("unknown user/group %s", *argv); - uid = ugid.uid; - gid = ugid.gid; } /* Ok, ready to do the deed now */ From bugs at busybox.net Wed Jan 3 12:07:35 2007 From: bugs at busybox.net (bugs at busybox.net) Date: Wed, 3 Jan 2007 12:07:35 -0800 Subject: [BusyBox 0001139]: "chown" can't process "uname.gname" as before Message-ID: <6cf686c76af676c055e6b2489cee6c97@bugs.busybox.net> The following issue has been CLOSED ====================================================================== http://busybox.net/bugs/view.php?id=1139 ====================================================================== Reported By: rockeychu Assigned To: BusyBox ====================================================================== Project: BusyBox Issue ID: 1139 Category: Standards Compliance Reproducibility: always Severity: minor Priority: normal Status: closed Resolution: open Fixed in Version: ====================================================================== Date Submitted: 12-29-2006 18:54 PST Last Modified: 01-03-2007 12:07 PST ====================================================================== Summary: "chown" can't process "uname.gname" as before Description: I know it could be deprecated soon after, but for compatible consideration, it can be corrected with following patch: Index: coreutils/chown.c =================================================================== --- coreutils/chown.c (revision 17103) +++ coreutils/chown.c (working copy) @@ -68,6 +68,7 @@ if (!groupName) { groupName = strchr(*argv, ':'); } + else groupName[0] = ':'; /* replace '.' with ':' */ /* First, try parsing "user[:[group]]" */ if (!groupName) { /* "user" */ ====================================================================== ---------------------------------------------------------------------- vda - 01-03-07 12:07 ---------------------------------------------------------------------- Fixed in rev 17145, thanks! Issue History Date Modified Username Field Change ====================================================================== 12-29-06 18:54 rockeychu New Issue 12-29-06 18:54 rockeychu Status new => assigned 12-29-06 18:54 rockeychu Assigned To => BusyBox 01-03-07 12:07 vda Status assigned => closed 01-03-07 12:07 vda Note Added: 0001951 ====================================================================== From vda at busybox.net Wed Jan 3 13:55:51 2007 From: vda at busybox.net (vda at busybox.net) Date: Wed, 3 Jan 2007 13:55:51 -0800 (PST) Subject: svn commit: trunk/busybox/networking Message-ID: <20070103215551.E4A1548625@busybox.net> Author: vda Date: 2007-01-03 13:55:50 -0800 (Wed, 03 Jan 2007) New Revision: 17146 Log: ftpgetput: fix PASV mode, fix xatou0induced breakage, improve error message, guard against garbage from remote server being printed. ~20 bytes code growth Modified: trunk/busybox/networking/ftpgetput.c Changeset: Modified: trunk/busybox/networking/ftpgetput.c =================================================================== --- trunk/busybox/networking/ftpgetput.c 2007-01-03 20:07:06 UTC (rev 17145) +++ trunk/busybox/networking/ftpgetput.c 2007-01-03 21:55:50 UTC (rev 17146) @@ -25,15 +25,28 @@ static char verbose_flag; static char do_continue; +static void ftp_die(const char *msg, const char *remote) ATTRIBUTE_NORETURN; +static void ftp_die(const char *msg, const char *remote) +{ + /* Guard against garbage from remote server */ + const char *cp = remote; + while (*cp >= ' ' && *cp < '\x7f') cp++; + bb_error_msg_and_die("unexpected server response%s%s: %.*s", + msg ? " to " : "", msg ? msg : "", + (int)(cp - remote), remote); +} + + static int ftpcmd(const char *s1, const char *s2, FILE *stream, char *buf) { + unsigned n; if (verbose_flag) { bb_error_msg("cmd %s%s", s1, s2); } if (s1) { if (s2) { - fprintf(stream, "%s%s\r\n", s1, s2); + fprintf(stream, "%s %s\r\n", s1, s2); } else { fprintf(stream, "%s\r\n", s1); } @@ -50,14 +63,23 @@ } } while (!isdigit(buf[0]) || buf[3] != ' '); - return xatou(buf); + buf[3] = '\0'; + n = xatou(buf); + buf[3] = ' '; + return n; } -static int xconnect_ftpdata(ftp_host_info_t *server, const char *buf) +static int xconnect_ftpdata(ftp_host_info_t *server, char *buf) { char *buf_ptr; unsigned short port_num; + /* Response is "NNN garbageN1,N2,N3,N4,P1,P2[)garbage] + * Server's IP is N1.N2.N3.N4 (we ignore it) + * Server's port for data connection is P1*256+P2 */ + buf_ptr = strrchr(buf, ')'); + if (buf_ptr) *buf_ptr = '\0'; + buf_ptr = strrchr(buf, ','); *buf_ptr = '\0'; port_num = xatoul_range(buf_ptr + 1, 0, 255); @@ -78,24 +100,25 @@ /* Connect to the command socket */ control_stream = fdopen(xconnect_tcp_v4(server->s_in), "r+"); if (control_stream == NULL) { - bb_perror_msg_and_die("cannot open control stream"); + /* Extremely unlikely */ + bb_perror_nomsg_and_die(); } if (ftpcmd(NULL, NULL, control_stream, buf) != 220) { - bb_error_msg_and_die("%s", buf + 4); + ftp_die(NULL, buf); } /* Login to the server */ - switch (ftpcmd("USER ", server->user, control_stream, buf)) { + switch (ftpcmd("USER", server->user, control_stream, buf)) { case 230: break; case 331: - if (ftpcmd("PASS ", server->password, control_stream, buf) != 230) { - bb_error_msg_and_die("PASS error: %s", buf + 4); + if (ftpcmd("PASS", server->password, control_stream, buf) != 230) { + ftp_die("PASS", buf); } break; default: - bb_error_msg_and_die("USER error: %s", buf + 4); + ftp_die("USER", buf); } ftpcmd("TYPE I", NULL, control_stream, buf); @@ -121,14 +144,14 @@ /* Connect to the data socket */ if (ftpcmd("PASV", NULL, control_stream, buf) != 227) { - bb_error_msg_and_die("PASV error: %s", buf + 4); + ftp_die("PASV", buf); } fd_data = xconnect_ftpdata(server, buf); - if (ftpcmd("SIZE ", server_path, control_stream, buf) == 213) { + if (ftpcmd("SIZE", server_path, control_stream, buf) == 213) { //filesize = BB_STRTOOFF(buf + 4, NULL, 10); //if (errno || filesize < 0) - // bb_error_msg_and_die("SIZE error: %s", buf + 4); + // ftp_die("SIZE", buf); } else { do_continue = 0; } @@ -160,8 +183,8 @@ } } - if (ftpcmd("RETR ", server_path, control_stream, buf) > 150) { - bb_error_msg_and_die("RETR error: %s", buf + 4); + if (ftpcmd("RETR", server_path, control_stream, buf) > 150) { + ftp_die("RETR", buf); } /* only make a local file if we know that one exists on the remote server */ @@ -185,7 +208,7 @@ /* close it all down */ close(fd_data); if (ftpcmd(NULL, NULL, control_stream, buf) != 226) { - bb_error_msg_and_die("ftp error: %s", buf + 4); + ftp_die(NULL, buf); } ftpcmd("QUIT", NULL, control_stream, buf); @@ -209,7 +232,7 @@ /* Connect to the data socket */ if (ftpcmd("PASV", NULL, control_stream, buf) != 227) { - bb_error_msg_and_die("PASV error: %s", buf + 4); + ftp_die("PASV", buf); } fd_data = xconnect_ftpdata(server, buf); @@ -219,7 +242,7 @@ fd_local = xopen(local_path, O_RDONLY); fstat(fd_local, &sbuf); - sprintf(buf, "ALLO %lu", (unsigned long)sbuf.st_size); + sprintf(buf, "ALLO %"OFF_FMT"u", sbuf.st_size); response = ftpcmd(buf, NULL, control_stream, buf); switch (response) { case 200: @@ -227,18 +250,18 @@ break; default: close(fd_local); - bb_error_msg_and_die("ALLO error: %s", buf + 4); + ftp_die("ALLO", buf); break; } } - response = ftpcmd("STOR ", server_path, control_stream, buf); + response = ftpcmd("STOR", server_path, control_stream, buf); switch (response) { case 125: case 150: break; default: close(fd_local); - bb_error_msg_and_die("STOR error: %s", buf + 4); + ftp_die("STOR", buf); } /* transfer the file */ @@ -249,7 +272,7 @@ /* close it all down */ close(fd_data); if (ftpcmd(NULL, NULL, control_stream, buf) != 226) { - bb_error_msg_and_die("error: %s", buf + 4); + ftp_die("close", buf); } ftpcmd("QUIT", NULL, control_stream, buf); @@ -278,21 +301,24 @@ { /* content-length of the file */ unsigned opt; - char *port = "ftp"; + const char *port = "ftp"; /* socket to ftp server */ FILE *control_stream; struct sockaddr_in s_in; - /* continue a prev transfer (-c) */ + /* continue previous transfer (-c) */ ftp_host_info_t *server; - int (*ftp_action)(ftp_host_info_t *, FILE *, const char *, char *) = NULL; +#if ENABLE_FTPPUT && !ENABLE_FTPGET +# define ftp_action ftp_send +#elif ENABLE_FTPGET && !ENABLE_FTPPUT +# define ftp_action ftp_receive +#else + int (*ftp_action)(ftp_host_info_t *, FILE *, const char *, char *) = ftp_send; /* Check to see if the command is ftpget or ftput */ - if (ENABLE_FTPPUT && (!ENABLE_FTPGET || applet_name[3] == 'p')) { - ftp_action = ftp_send; - } - if (ENABLE_FTPGET && (!ENABLE_FTPPUT || applet_name[3] == 'g')) { + if (applet_name[3] == 'g') { ftp_action = ftp_receive; } +#endif /* Set default values */ server = xmalloc(sizeof(ftp_host_info_t)); @@ -306,13 +332,11 @@ #if ENABLE_FEATURE_FTPGETPUT_LONG_OPTIONS applet_long_options = ftpgetput_long_options; #endif + opt_complementary = "=3"; /* must have 3 params */ opt = getopt32(argc, argv, "cvu:p:P:", &server->user, &server->password, &port); + argv += optind; /* Process the non-option command line arguments */ - if (argc - optind != 3) { - bb_show_usage(); - } - if (opt & FTPGETPUT_OPT_CONTINUE) { do_continue = 1; } @@ -324,15 +348,15 @@ * sites (i.e. ftp.us.debian.org) use round-robin DNS * and we want to connect to only one IP... */ server->s_in = &s_in; - bb_lookup_host(&s_in, argv[optind]); + bb_lookup_host(&s_in, argv[0]); s_in.sin_port = bb_lookup_port(port, "tcp", 21); if (verbose_flag) { printf("Connecting to %s[%s]:%d\n", - argv[optind], inet_ntoa(s_in.sin_addr), ntohs(s_in.sin_port)); + argv[0], inet_ntoa(s_in.sin_addr), ntohs(s_in.sin_port)); } /* Connect/Setup/Configure the FTP session */ control_stream = ftp_login(server); - return ftp_action(server, control_stream, argv[optind + 1], argv[optind + 2]); + return ftp_action(server, control_stream, argv[1], argv[2]); } From bugs at busybox.net Wed Jan 3 13:56:16 2007 From: bugs at busybox.net (bugs at busybox.net) Date: Wed, 3 Jan 2007 13:56:16 -0800 Subject: [BusyBox 0001125]: "ftpget" and "ftpput" can't access FTP server, and can't fetch ftp files with PASV mode (with patch) Message-ID: The following issue has been CLOSED ====================================================================== http://busybox.net/bugs/view.php?id=1125 ====================================================================== Reported By: rockeychu Assigned To: BusyBox ====================================================================== Project: BusyBox Issue ID: 1125 Category: Networking Support Reproducibility: always Severity: crash Priority: normal Status: closed Resolution: open Fixed in Version: ====================================================================== Date Submitted: 12-21-2006 19:58 PST Last Modified: 01-03-2007 13:56 PST ====================================================================== Summary: "ftpget" and "ftpput" can't access FTP server, and can't fetch ftp files with PASV mode (with patch) Description: "ftpget" & "ftpput" can't access FTP server, and can't fetch ftp files with PASV mode. This happened since Revision 16684, the same problem as previous "wget" when introduced saner bb_strtoXX. patch as following: Index: networking/ftpgetput.c =================================================================== --- networking/ftpgetput.c (revision 17039) +++ networking/ftpgetput.c (working copy) @@ -49,6 +49,8 @@ *buf_ptr = '\0'; } } while (!isdigit(buf[0]) || buf[3] != ' '); + + buf[3] = '\0'; return xatou(buf); } @@ -58,6 +60,9 @@ char *buf_ptr; unsigned short port_num; + buf_ptr = strrchr(buf, ')'); + if (buf_ptr) *buf_ptr = '\0'; + buf_ptr = strrchr(buf, ','); *buf_ptr = '\0'; port_num = xatoul_range(buf_ptr + 1, 0, 255); @@ -123,7 +128,7 @@ if (ftpcmd("PASV", NULL, contr