Changeset 2725 in MondoRescue for branches/2.2.9/mindi-busybox/e2fsprogs


Ignore:
Timestamp:
Feb 25, 2011, 9:26:54 PM (13 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.18.3 to avoid problems with the tar command which is now failing on recent versions with busybox 1.7.3
Location:
branches/2.2.9/mindi-busybox/e2fsprogs
Files:
9 added
91 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.9/mindi-busybox/e2fsprogs/Config.in

    r1765 r2725  
     1# DO NOT EDIT. This file is generated from Config.src
    12#
    23# For a description of the syntax of this configuration file,
     
    67menu "Linux Ext2 FS Progs"
    78
     9
     10
    811config CHATTR
    912    bool "chattr"
    10     default n
     13    default y
    1114    help
    1215      chattr changes the file attributes on a second extended file system.
    1316
    1417### config E2FSCK
    15 ###     bool "e2fsck"
    16 ###     default n
    17 ###     help
    18 ###       e2fsck is used to check Linux second extended file systems (ext2fs).
    19 ###       e2fsck also supports ext2 filesystems countaining a journal (ext3).
    20 ###       The normal compat symlinks 'fsck.ext2' and 'fsck.ext3' are also
    21 ###       provided.
     18### bool "e2fsck"
     19### default y
     20### help
     21###   e2fsck is used to check Linux second extended file systems (ext2fs).
     22###   e2fsck also supports ext2 filesystems countaining a journal (ext3).
     23###   The normal compat symlinks 'fsck.ext2' and 'fsck.ext3' are also
     24###   provided.
    2225
    2326config FSCK
    2427    bool "fsck"
    25     default n
     28    default y
    2629    help
    2730      fsck is used to check and optionally repair one or more filesystems.
     
    3134config LSATTR
    3235    bool "lsattr"
    33     default n
     36    default y
     37    depends on PLATFORM_LINUX
    3438    help
    3539      lsattr lists the file attributes on a second extended file system.
    3640
    3741### config MKE2FS
    38 ###     bool "mke2fs"
    39 ###     default n
    40 ###     help
    41 ###       mke2fs is used to create an ext2/ext3 filesystem. The normal compat
    42 ###       symlinks 'mkfs.ext2' and 'mkfs.ext3' are also provided.
     42### bool "mke2fs"
     43### default y
     44### help
     45###   mke2fs is used to create an ext2/ext3 filesystem. The normal compat
     46###   symlinks 'mkfs.ext2' and 'mkfs.ext3' are also provided.
    4347
    44 ### config TUNE2FS
    45 ###     bool "tune2fs"
    46 ###     default n
    47 ###     help
    48 ###       tune2fs allows the system administrator to adjust various tunable
    49 ###       filesystem parameters on Linux ext2/ext3 filesystems.
     48config TUNE2FS
     49    bool "tune2fs"
     50    default n  # off: it is too limited compared to upstream version
     51    help
     52      tune2fs allows the system administrator to adjust various tunable
     53      filesystem parameters on Linux ext2/ext3 filesystems.
    5054
    5155### config E2LABEL
    52 ###     bool "e2label"
    53 ###     default n
    54 ###     depends on TUNE2FS
    55 ###     help
    56 ###       e2label will display or change the filesystem label on the ext2
    57 ###       filesystem located on device.
     56### bool "e2label"
     57### default y
     58### depends on TUNE2FS
     59### help
     60###   e2label will display or change the filesystem label on the ext2
     61###   filesystem located on device.
    5862
     63### NB: this one is now provided by util-linux/volume_id/*
    5964### config FINDFS
    60 ###     bool "findfs"
    61 ###     default n
    62 ###     depends on TUNE2FS
    63 ###     help
    64 ###       findfs will search the disks in the system looking for a filesystem
    65 ###       which has a label matching label or a UUID equal to uuid.
     65### bool "findfs"
     66### default y
     67### depends on TUNE2FS
     68### help
     69###   findfs will search the disks in the system looking for a filesystem
     70###   which has a label matching label or a UUID equal to uuid.
    6671
    6772endmenu
  • branches/2.2.9/mindi-busybox/e2fsprogs/Kbuild

    r1765 r2725  
     1# DO NOT EDIT. This file is generated from Kbuild.src
    12# Makefile for busybox
    23#
    34# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
    45#
    5 # Licensed under the GPL v2, see the file LICENSE in this tarball.
     6# Licensed under GPLv2, see file LICENSE in this source tree.
    67
    78lib-y:=
     9
     10
    811
    912lib-$(CONFIG_CHATTR) += chattr.o e2fs_lib.o
    1013lib-$(CONFIG_LSATTR) += lsattr.o e2fs_lib.o
    1114
    12 lib-$(CONFIG_FSCK) += fsck.o
     15lib-$(CONFIG_FSCK)    += fsck.o
     16lib-$(CONFIG_TUNE2FS) += tune2fs.o
  • branches/2.2.9/mindi-busybox/e2fsprogs/chattr.c

    r1765 r2725  
    3838static unsigned long get_flag(char c)
    3939{
    40     /* Two separate vectors take less space than vector of structs */
    41     static const char flags_letter[] ALIGN1 = "ASDacdijsutT";
    42     static const unsigned long flags_val[] = {
    43         /* A */ EXT2_NOATIME_FL,
    44         /* S */ EXT2_SYNC_FL,
    45         /* D */ EXT2_DIRSYNC_FL,
    46         /* a */ EXT2_APPEND_FL,
    47         /* c */ EXT2_COMPR_FL,
    48         /* d */ EXT2_NODUMP_FL,
    49         /* i */ EXT2_IMMUTABLE_FL,
    50         /* j */ EXT3_JOURNAL_DATA_FL,
    51         /* s */ EXT2_SECRM_FL,
    52         /* u */ EXT2_UNRM_FL,
    53         /* t */ EXT2_NOTAIL_FL,
    54         /* T */ EXT2_TOPDIR_FL,
    55     };
    56     const char *fp;
    57 
    58     for (fp = flags_letter; *fp; fp++)
    59         if (*fp == c)
    60             return flags_val[fp - flags_letter];
     40    const char *fp = strchr(e2attr_flags_sname_chattr, c);
     41    if (fp)
     42        return e2attr_flags_value_chattr[fp - e2attr_flags_sname_chattr];
    6143    bb_show_usage();
    6244}
     
    8668static void change_attributes(const char *name, struct globals *gp);
    8769
    88 static int chattr_dir_proc(const char *dir_name, struct dirent *de, void *gp)
     70static int FAST_FUNC chattr_dir_proc(const char *dir_name, struct dirent *de, void *gp)
    8971{
    9072    char *path = concat_subpath_file(dir_name, de->d_name);
     
    143125}
    144126
    145 int chattr_main(int argc, char **argv);
    146 int chattr_main(int argc, char **argv)
     127int chattr_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
     128int chattr_main(int argc UNUSED_PARAM, char **argv)
    147129{
    148130    struct globals g;
  • branches/2.2.9/mindi-busybox/e2fsprogs/e2fs_defs.h

    r1765 r2725  
    1111 */
    1212
    13 #ifndef _LINUX_EXT2_FS_H
    14 #define _LINUX_EXT2_FS_H
     13#ifndef LINUX_EXT2_FS_H
     14#define LINUX_EXT2_FS_H 1
    1515
    1616/*
     
    559559                     ~EXT2_DIR_ROUND)
    560560
    561 #endif  /* _LINUX_EXT2_FS_H */
     561#endif
  • branches/2.2.9/mindi-busybox/e2fsprogs/e2fs_lib.c

    r1765 r2725  
    33 * See README for additional information
    44 *
    5  * This file can be redistributed under the terms of the GNU Library General
    6  * Public License
     5 * Licensed under GPLv2, see file LICENSE in this source tree.
    76 */
    87
     
    3029/* Iterate a function on each entry of a directory */
    3130int iterate_on_dir(const char *dir_name,
    32         int (*func)(const char *, struct dirent *, void *),
    33         void * private)
     31        int FAST_FUNC (*func)(const char *, struct dirent *, void *),
     32        void *private)
    3433{
    3534    DIR *dir;
    36     struct dirent *de, *dep;
    37     int max_len, len;
    38 
    39     max_len = PATH_MAX + sizeof(struct dirent);
    40     de = xmalloc(max_len+1);
    41     memset(de, 0, max_len+1);
     35    struct dirent *de;
    4236
    4337    dir = opendir(dir_name);
    4438    if (dir == NULL) {
    45         free(de);
    4639        return -1;
    4740    }
    48     while ((dep = readdir(dir))) {
    49         len = sizeof(struct dirent);
    50         if (len < dep->d_reclen)
    51             len = dep->d_reclen;
    52         if (len > max_len)
    53             len = max_len;
    54         memcpy(de, dep, len);
     41    while ((de = readdir(dir)) != NULL) {
    5542        func(dir_name, de, private);
    5643    }
    5744    closedir(dir);
    58     free(de);
    5945    return 0;
    6046}
     
    6854    IF_LONG_IS_WIDER(int ver;)
    6955
    70     fd = open(name, O_NONBLOCK);
     56    fd = open(name, O_RDONLY | O_NONBLOCK);
    7157    if (fd == -1)
    7258        return -1;
     
    11096        goto notsupp;
    11197    }
    112     fd = open(name, O_NONBLOCK); /* neither read nor write asked for */
     98    fd = open(name, O_RDONLY | O_NONBLOCK); /* neither read nor write asked for */
    11399    if (fd == -1)
    114100        return -1;
     
    142128
    143129/* Print file attributes on an ext2 file system */
    144 struct flags_name {
    145     unsigned long   flag;
    146     char        short_name;
    147     const char  *long_name;
     130const uint32_t e2attr_flags_value[] = {
     131#ifdef ENABLE_COMPRESSION
     132    EXT2_COMPRBLK_FL,
     133    EXT2_DIRTY_FL,
     134    EXT2_NOCOMPR_FL,
     135    EXT2_ECOMPR_FL,
     136#endif
     137    EXT2_INDEX_FL,
     138    EXT2_SECRM_FL,
     139    EXT2_UNRM_FL,
     140    EXT2_SYNC_FL,
     141    EXT2_DIRSYNC_FL,
     142    EXT2_IMMUTABLE_FL,
     143    EXT2_APPEND_FL,
     144    EXT2_NODUMP_FL,
     145    EXT2_NOATIME_FL,
     146    EXT2_COMPR_FL,
     147    EXT3_JOURNAL_DATA_FL,
     148    EXT2_NOTAIL_FL,
     149    EXT2_TOPDIR_FL
    148150};
    149151
    150 /* TODO: apart from I and (disabled) COMPRESSION flags, this
    151  * is a duplicate of a table from chattr. Merge? */
    152 static const struct flags_name flags_array[] = {
    153     { EXT2_SECRM_FL, 's', "Secure_Deletion" },
    154     { EXT2_UNRM_FL, 'u' , "Undelete" },
    155     { EXT2_SYNC_FL, 'S', "Synchronous_Updates" },
    156     { EXT2_DIRSYNC_FL, 'D', "Synchronous_Directory_Updates" },
    157     { EXT2_IMMUTABLE_FL, 'i', "Immutable" },
    158     { EXT2_APPEND_FL, 'a', "Append_Only" },
    159     { EXT2_NODUMP_FL, 'd', "No_Dump" },
    160     { EXT2_NOATIME_FL, 'A', "No_Atime" },
    161     { EXT2_COMPR_FL, 'c', "Compression_Requested" },
     152const char e2attr_flags_sname[] =
    162153#ifdef ENABLE_COMPRESSION
    163     { EXT2_COMPRBLK_FL, 'B', "Compressed_File" },
    164     { EXT2_DIRTY_FL, 'Z', "Compressed_Dirty_File" },
    165     { EXT2_NOCOMPR_FL, 'X', "Compression_Raw_Access" },
    166     { EXT2_ECOMPR_FL, 'E', "Compression_Error" },
    167 #endif
    168     { EXT3_JOURNAL_DATA_FL, 'j', "Journaled_Data" },
    169     { EXT2_INDEX_FL, 'I', "Indexed_directory" },
    170     { EXT2_NOTAIL_FL, 't', "No_Tailmerging" },
    171     { EXT2_TOPDIR_FL, 'T', "Top_of_Directory_Hierarchies" },
    172     { 0, '\0', NULL }
    173 };
    174 
    175 void print_flags(FILE *f, unsigned long flags, unsigned options)
    176 {
    177     const struct flags_name *fp;
    178 
     154    "BZXE"
     155#endif
     156    "I"
     157    "suSDiadAcjtT";
     158
     159static const char e2attr_flags_lname[] =
     160#ifdef ENABLE_COMPRESSION
     161    "Compressed_File" "\0"
     162    "Compressed_Dirty_File" "\0"
     163    "Compression_Raw_Access" "\0"
     164    "Compression_Error" "\0"
     165#endif
     166    "Indexed_directory" "\0"
     167    "Secure_Deletion" "\0"
     168    "Undelete" "\0"
     169    "Synchronous_Updates" "\0"
     170    "Synchronous_Directory_Updates" "\0"
     171    "Immutable" "\0"
     172    "Append_Only" "\0"
     173    "No_Dump" "\0"
     174    "No_Atime" "\0"
     175    "Compression_Requested" "\0"
     176    "Journaled_Data" "\0"
     177    "No_Tailmerging" "\0"
     178    "Top_of_Directory_Hierarchies" "\0"
     179    /* Another trailing NUL is added by compiler */;
     180
     181void print_e2flags(FILE *f, unsigned long flags, unsigned options)
     182{
     183    const uint32_t *fv;
     184    const char *fn;
     185
     186    fv = e2attr_flags_value;
    179187    if (options & PFOPT_LONG) {
    180188        int first = 1;
    181         for (fp = flags_array; fp->short_name; fp++) {
    182             if (flags & fp->flag) {
     189        fn = e2attr_flags_lname;
     190        do {
     191            if (flags & *fv) {
    183192                if (!first)
    184193                    fputs(", ", f);
    185                 fputs(fp->long_name, f);
     194                fputs(fn, f);
    186195                first = 0;
    187196            }
    188         }
     197            fv++;
     198            fn += strlen(fn) + 1;
     199        } while (*fn);
    189200        if (first)
    190201            fputs("---", f);
    191202    } else {
    192         for (fp = flags_array; fp->short_name; fp++) {
     203        fn = e2attr_flags_sname;
     204        do  {
    193205            char c = '-';
    194             if (flags & fp->flag)
    195                 c = fp->short_name;
     206            if (flags & *fv)
     207                c = *fn;
    196208            fputc(c, f);
    197         }
    198     }
    199 }
     209            fv++;
     210            fn++;
     211        } while (*fn);
     212    }
     213}
  • branches/2.2.9/mindi-busybox/e2fsprogs/e2fs_lib.h

    r1765 r2725  
    1010#include "e2fs_defs.h"
    1111
     12PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
     13
    1214/* Iterate a function on each entry of a directory */
    1315int iterate_on_dir(const char *dir_name,
    14         int (*func)(const char *, struct dirent *, void *),
     16        int FAST_FUNC (*func)(const char *, struct dirent *, void *),
    1517        void *private);
    1618
     
    2830#define PFOPT_LONG  1
    2931/* Print file attributes on an ext2 file system */
    30 void print_flags(FILE *f, unsigned long flags, unsigned options);
     32void print_e2flags(FILE *f, unsigned long flags, unsigned options);
     33
     34extern const uint32_t e2attr_flags_value[];
     35extern const char e2attr_flags_sname[];
     36
     37/* If you plan to ENABLE_COMPRESSION, see e2fs_lib.c and chattr.c - */
     38/* make sure that chattr doesn't accept bad options! */
     39#ifdef ENABLE_COMPRESSION
     40#define e2attr_flags_value_chattr (&e2attr_flags_value[5])
     41#define e2attr_flags_sname_chattr (&e2attr_flags_sname[5])
     42#else
     43#define e2attr_flags_value_chattr (&e2attr_flags_value[1])
     44#define e2attr_flags_sname_chattr (&e2attr_flags_sname[1])
     45#endif
     46
     47POP_SAVED_FUNCTION_VISIBILITY
  • branches/2.2.9/mindi-busybox/e2fsprogs/fsck.c

    r1765 r2725  
    2121 *      2001, 2002, 2003, 2004, 2005 by  Theodore Ts'o.
    2222 *
    23  * %Begin-Header%
    24  * This file may be redistributed under the terms of the GNU Public
    25  * License.
    26  * %End-Header%
     23 * Licensed under GPLv2, see file LICENSE in this source tree.
    2724 */
    2825
     
    4037#include "libbb.h"
    4138
     39/* "progress indicator" code is somewhat buggy and ext[23] specific.
     40 * We should be filesystem agnostic. IOW: there should be a well-defined
     41 * API for fsck.something, NOT ad-hoc hacks in generic fsck. */
     42#define DO_PROGRESS_INDICATOR 0
     43
     44/* fsck 1.41.4 (27-Jan-2009) manpage says:
     45 * 0   - No errors
     46 * 1   - File system errors corrected
     47 * 2   - System should be rebooted
     48 * 4   - File system errors left uncorrected
     49 * 8   - Operational error
     50 * 16  - Usage or syntax error
     51 * 32  - Fsck canceled by user request
     52 * 128 - Shared library error
     53 */
    4254#define EXIT_OK          0
    4355#define EXIT_NONDESTRUCT 1
     
    5163 * Internal structure for mount table entries.
    5264 */
    53 
    5465struct fs_info {
    5566    struct fs_info *next;
     
    5869    char    *type;
    5970    char    *opts;
    60     int freq;
    6171    int passno;
    6272    int flags;
     
    7282    int pid;
    7383    int flags;
    74     int exit_status;
     84#if DO_PROGRESS_INDICATOR
    7585    time_t  start_time;
     86#endif
    7687    char    *prog;
    77     char    *type;
    7888    char    *device;
    7989    char    *base_device; /* /dev/hda for /dev/hdaN etc */
     
    103113#define BASE_MD "/dev/md"
    104114
    105 static char **devices;
    106115static char **args;
    107 static int num_devices;
    108116static int num_args;
    109117static int verbose;
     
    116124static smallint fs_type_negated;
    117125
    118 static volatile smallint cancel_requested;
    119 static smallint doall;
    120126static smallint noexecute;
    121127static smallint serialize;
    122128static smallint skip_root;
    123129/* static smallint like_mount; */
    124 static smallint notitle;
    125130static smallint parallel_root;
    126131static smallint force_all_parallel;
    127132
    128 /* "progress indicator" code is somewhat buggy and ext[23] specific.
    129  * We should be filesystem agnostic. IOW: there should be a well-defined
    130  * API for fsck.something, NOT ad-hoc hacks in generic fsck. */
    131 #define DO_PROGRESS_INDICATOR 0
    132133#if DO_PROGRESS_INDICATOR
    133134static smallint progress;
     
    169170    int len;
    170171#endif
    171     cp = str = xstrdup(device);
    172 
    173     /* Skip over /dev/; if it's not present, give up. */
    174     if (strncmp(cp, "/dev/", 5) != 0)
     172    str = xstrdup(device);
     173
     174    /* Skip over "/dev/"; if it's not present, give up */
     175    cp = skip_dev_pfx(str);
     176    if (cp == str)
    175177        goto errout;
    176     cp += 5;
    177178
    178179    /*
     
    274275static struct fs_info *create_fs_device(const char *device, const char *mntpnt,
    275276                    const char *type, const char *opts,
    276                     int freq, int passno)
     277                    int passno)
    277278{
    278279    struct fs_info *fs;
     
    281282    fs->device = xstrdup(device);
    282283    fs->mountpt = xstrdup(mntpnt);
     284    if (strchr(type, ','))
     285        type = (char *)"auto";
    283286    fs->type = xstrdup(type);
    284287    fs->opts = xstrdup(opts ? opts : "");
    285     fs->freq = freq;
    286     fs->passno = passno;
     288    fs->passno = passno < 0 ? 1 : passno;
    287289    /*fs->flags = 0; */
    288290    /*fs->next = NULL; */
     
    297299}
    298300
    299 static void strip_line(char *line)
    300 {
    301     char *p = line + strlen(line) - 1;
    302 
    303     while (*line) {
    304         if (*p != '\n' && *p != '\r')
    305             break;
    306         *p-- = '\0';
    307     }
    308 }
    309 
    310 static char *parse_word(char **buf)
    311 {
    312     char *word, *next;
    313 
    314     word = *buf;
    315     if (*word == '\0')
    316         return NULL;
    317 
    318     word = skip_whitespace(word);
    319     next = skip_non_whitespace(word);
    320     if (*next)
    321         *next++ = '\0';
    322     *buf = next;
    323     return word;
    324 }
    325 
    326 static void parse_escape(char *word)
    327 {
    328     char *q, c;
    329     const char *p;
    330 
    331     if (!word)
    332         return;
    333 
    334     for (p = q = word; *p; q++) {
    335         c = *p++;
    336         if (c != '\\') {
    337             *q = c;
    338         } else {
    339             *q = bb_process_escape_sequence(&p);
    340         }
    341     }
    342     *q = '\0';
    343 }
    344 
    345 static int parse_fstab_line(char *line, struct fs_info **ret_fs)
    346 {
    347     char *device, *mntpnt, *type, *opts, *freq, *passno, *cp;
    348     struct fs_info *fs;
    349 
    350     *ret_fs = 0;
    351     strip_line(line);
    352     cp = strchr(line, '#');
    353     if (cp)
    354         *cp = '\0'; /* Ignore everything after the comment char */
    355     cp = line;
    356 
    357     device = parse_word(&cp);
    358     if (!device) return 0; /* Allow blank lines */
    359     mntpnt = parse_word(&cp);
    360     type = parse_word(&cp);
    361     opts = parse_word(&cp);
    362     freq = parse_word(&cp);
    363     passno = parse_word(&cp);
    364 
    365     if (!mntpnt || !type)
    366         return -1;
    367 
    368     parse_escape(device);
    369     parse_escape(mntpnt);
    370     parse_escape(type);
    371     parse_escape(opts);
    372     parse_escape(freq);
    373     parse_escape(passno);
    374 
    375     if (strchr(type, ','))
    376         type = NULL;
    377 
    378     fs = create_fs_device(device, mntpnt, type ? type : "auto", opts,
    379                 freq ? atoi(freq) : -1,
    380                 passno ? atoi(passno) : -1);
    381     *ret_fs = fs;
    382     return 0;
    383 }
    384 
    385301/* Load the filesystem database from /etc/fstab */
    386302static void load_fs_info(const char *filename)
    387303{
    388     FILE *f;
    389     int lineno = 0;
    390     int old_fstab = 1;
     304    FILE *fstab;
     305    struct mntent mte;
    391306    struct fs_info *fs;
    392307
    393     f = fopen_or_warn(filename, "r");
    394     if (f == NULL) {
     308    fstab = setmntent(filename, "r");
     309    if (!fstab) {
     310        bb_perror_msg("can't read '%s'", filename);
    395311        return;
    396312    }
    397     while (1) {
    398         int r;
    399         char *buf = xmalloc_getline(f);
    400         if (!buf) break;
    401         r = parse_fstab_line(buf, &fs);
    402         free(buf);
    403         lineno++;
    404         if (r < 0) {
    405             bb_error_msg("WARNING: bad format "
    406                 "on line %d of %s", lineno, filename);
    407             continue;
    408         }
    409         if (!fs)
    410             continue;
    411         if (fs->passno < 0)
    412             fs->passno = 0;
    413         else
    414             old_fstab = 0;
    415     }
    416     fclose(f);
    417 
    418     if (old_fstab) {
    419         fputs("\007"
    420 "WARNING: Your /etc/fstab does not contain the fsck passno field.\n"
    421 "I will kludge around things for you, but you should fix\n"
    422 "your /etc/fstab file as soon as you can.\n\n", stderr);
    423         for (fs = filesys_info; fs; fs = fs->next) {
    424             fs->passno = 1;
    425         }
    426     }
     313
     314    // Loop through entries
     315    while (getmntent_r(fstab, &mte, bb_common_bufsiz1, COMMON_BUFSIZE)) {
     316        //bb_info_msg("CREATE[%s][%s][%s][%s][%d]", mte.mnt_fsname, mte.mnt_dir,
     317        //  mte.mnt_type, mte.mnt_opts,
     318        //  mte.mnt_passno);
     319        fs = create_fs_device(mte.mnt_fsname, mte.mnt_dir,
     320            mte.mnt_type, mte.mnt_opts,
     321            mte.mnt_passno);
     322    }
     323    endmntent(fstab);
    427324}
    428325
     
    461358 * Send a signal to all outstanding fsck child processes
    462359 */
    463 static void kill_all_if_cancel_requested(void)
     360static void kill_all_if_got_signal(void)
    464361{
    465362    static smallint kill_sent;
     
    467364    struct fsck_instance *inst;
    468365
    469     if (!cancel_requested || kill_sent)
     366    if (!bb_got_signal || kill_sent)
    470367        return;
    471368
     
    480377/*
    481378 * Wait for one child process to exit; when it does, unlink it from
    482  * the list of executing child processes, and return it.
    483  */
    484 static struct fsck_instance *wait_one(int flags)
     379 * the list of executing child processes, free, and return its exit status.
     380 * If there is no exited child, return -1.
     381 */
     382static int wait_one(int flags)
    485383{
    486384    int status;
     
    490388
    491389    if (!instance_list)
    492         return NULL;
    493 
    494     if (noexecute) {
    495         inst = instance_list;
    496         prev = NULL;
    497 #ifdef RANDOM_DEBUG
    498         while (inst->next && (random() & 1)) {
    499             prev = inst;
    500             inst = inst->next;
    501         }
    502 #endif
    503         inst->exit_status = 0;
    504         goto ret_inst;
    505     }
    506 
    507     inst = prev = NULL; /* for gcc */
    508     do {
     390        return -1;
     391    /* if (noexecute) { already returned -1; } */
     392
     393    while (1) {
    509394        pid = waitpid(-1, &status, flags);
    510         kill_all_if_cancel_requested();
    511         if (pid == 0 && (flags & WNOHANG))
    512             return NULL;
     395        kill_all_if_got_signal();
     396        if (pid == 0) /* flags == WNOHANG and no children exited */
     397            return -1;
    513398        if (pid < 0) {
    514             if (errno == EINTR || errno == EAGAIN)
     399            if (errno == EINTR)
    515400                continue;
    516             if (errno == ECHILD) {
    517                 bb_error_msg("wait: no more child process?!?");
    518                 return NULL;
     401            if (errno == ECHILD) { /* paranoia */
     402                bb_error_msg("wait: no more children");
     403                return -1;
    519404            }
    520405            bb_perror_msg("wait");
     
    523408        prev = NULL;
    524409        inst = instance_list;
    525         while (inst) {
     410        do {
    526411            if (inst->pid == pid)
    527                 break;
     412                goto child_died;
    528413            prev = inst;
    529414            inst = inst->next;
    530         }
    531     } while (!inst);
     415        } while (inst);
     416    }
     417 child_died:
    532418
    533419    if (WIFEXITED(status))
     
    537423        status = EXIT_UNCORRECTED;
    538424        if (sig != SIGINT) {
    539             printf("Warning... %s %s exited "
    540                 "with signal %d\n",
     425            printf("Warning: %s %s terminated "
     426                "by signal %d\n",
    541427                inst->prog, inst->device, sig);
    542428            status = EXIT_ERROR;
     
    547433        status = EXIT_ERROR;
    548434    }
    549     inst->exit_status = status;
    550435
    551436#if DO_PROGRESS_INDICATOR
     
    576461#endif
    577462
    578  ret_inst:
    579463    if (prev)
    580464        prev->next = inst->next;
     
    583467    if (verbose > 1)
    584468        printf("Finished with %s (exit status %d)\n",
    585                inst->device, inst->exit_status);
     469               inst->device, status);
    586470    num_running--;
    587     return inst;
    588 }
    589 
    590 #define FLAG_WAIT_ALL           0
    591 #define FLAG_WAIT_ATLEAST_ONE   1
     471    free_instance(inst);
     472
     473    return status;
     474}
     475
    592476/*
    593477 * Wait until all executing child processes have exited; return the
    594478 * logical OR of all of their exit code values.
    595479 */
     480#define FLAG_WAIT_ALL           0
     481#define FLAG_WAIT_ATLEAST_ONE   WNOHANG
    596482static int wait_many(int flags)
    597483{
    598     struct fsck_instance *inst;
     484    int exit_status;
    599485    int global_status = 0;
    600486    int wait_flags = 0;
    601487
    602     while ((inst = wait_one(wait_flags))) {
    603         global_status |= inst->exit_status;
    604         free_instance(inst);
    605 #ifdef RANDOM_DEBUG
    606         if (noexecute && (flags & WNOHANG) && !(random() % 3))
    607             break;
    608 #endif
    609         if (flags & FLAG_WAIT_ATLEAST_ONE)
    610             wait_flags = WNOHANG;
     488    while ((exit_status = wait_one(wait_flags)) != -1) {
     489        global_status |= exit_status;
     490        wait_flags |= flags;
    611491    }
    612492    return global_status;
     
    617497 * child processes we are waiting for.
    618498 */
    619 static void execute(const char *type, const char *device, const char *mntpt,
    620         int interactive)
    621 {
    622     char *argv[num_args + 4]; /* see count below: */
    623     int argc;
     499static void execute(const char *type, const char *device,
     500        const char *mntpt /*, int interactive */)
     501{
    624502    int i;
    625503    struct fsck_instance *inst;
    626504    pid_t pid;
    627505
    628     inst = xzalloc(sizeof(*inst));
    629 
    630     argv[0] = xasprintf("fsck.%s", type); /* 1 */
    631     for (i = 0; i < num_args; i++)
    632         argv[i+1] = args[i]; /* num_args */
    633     argc = num_args + 1;
     506    args[0] = xasprintf("fsck.%s", type);
    634507
    635508#if DO_PROGRESS_INDICATOR
     
    638511         || strcmp(type, "ext3") == 0
    639512        ) {
    640             argv[argc++] = xasprintf("-C%d", progress_fd); /* 1 */
     513            args[XXX] = xasprintf("-C%d", progress_fd); /* 1 */
    641514            inst->flags |= FLAG_PROGRESS;
    642515        }
     
    644517#endif
    645518
    646     argv[argc++] = xstrdup(device); /* 1 */
    647     argv[argc] = NULL; /* 1 */
     519    args[num_args - 2] = (char*)device;
     520    /* args[num_args - 1] = NULL; - already is */
    648521
    649522    if (verbose || noexecute) {
    650         printf("[%s (%d) -- %s]", argv[0], num_running,
     523        printf("[%s (%d) -- %s]", args[0], num_running,
    651524                    mntpt ? mntpt : device);
    652         for (i = 0; i < argc; i++)
    653             printf(" %s", argv[i]);
    654         puts("");
     525        for (i = 0; args[i]; i++)
     526            printf(" %s", args[i]);
     527        bb_putchar('\n');
    655528    }
    656529
     
    658531    pid = -1;
    659532    if (!noexecute) {
    660         pid = spawn(argv);
     533        pid = spawn(args);
    661534        if (pid < 0)
    662             bb_perror_msg("%s", argv[0]);
    663     }
    664 
    665     for (i = num_args+1; i < argc; i++)
    666         free(argv[i]);
    667 
     535            bb_simple_perror_msg(args[0]);
     536    }
     537
     538#if DO_PROGRESS_INDICATOR
     539    free(args[XXX]);
     540#endif
     541
     542    /* No child, so don't record an instance */
     543    if (pid <= 0) {
     544        free(args[0]);
     545        return;
     546    }
     547
     548    inst = xzalloc(sizeof(*inst));
    668549    inst->pid = pid;
    669     inst->prog = argv[0];
    670     inst->type = xstrdup(type);
     550    inst->prog = args[0];
    671551    inst->device = xstrdup(device);
    672552    inst->base_device = base_device(device);
     553#if DO_PROGRESS_INDICATOR
    673554    inst->start_time = time(NULL);
     555#endif
    674556
    675557    /* Add to the list of running fsck's.
     
    689571 * specified in /etc/fstab, or "auto".
    690572 */
    691 static void fsck_device(struct fs_info *fs, int interactive)
     573static void fsck_device(struct fs_info *fs /*, int interactive */)
    692574{
    693575    const char *type;
     
    716598
    717599    num_running++;
    718     execute(type, fs->device, fs->mountpt, interactive);
     600    execute(type, fs->device, fs->mountpt /*, interactive */);
    719601}
    720602
     
    868750     * filesystem types (done as a side-effect of calling ignore()).
    869751     */
    870     for (fs = filesys_info; fs; fs = fs->next) {
     752    for (fs = filesys_info; fs; fs = fs->next)
    871753        if (ignore(fs))
    872754            fs->flags |= FLAG_DONE;
    873     }
    874755
    875756    /*
     
    878759    if (!parallel_root) {
    879760        for (fs = filesys_info; fs; fs = fs->next) {
    880             if (LONE_CHAR(fs->mountpt, '/'))
    881                 break;
    882         }
    883         if (fs) {
    884             if (!skip_root && !ignore(fs)) {
    885                 fsck_device(fs, 1);
    886                 status |= wait_many(FLAG_WAIT_ALL);
    887                 if (status > EXIT_NONDESTRUCT)
    888                     return status;
     761            if (LONE_CHAR(fs->mountpt, '/')) {
     762                if (!skip_root && !ignore(fs)) {
     763                    fsck_device(fs /*, 1*/);
     764                    status |= wait_many(FLAG_WAIT_ALL);
     765                    if (status > EXIT_NONDESTRUCT)
     766                        return status;
     767                }
     768                fs->flags |= FLAG_DONE;
     769                break;
    889770            }
    890             fs->flags |= FLAG_DONE;
    891771        }
    892772    }
    893773    /*
    894      * This is for the bone-headed user who enters the root
    895      * filesystem twice.  Skip root will skip all root entries.
     774     * This is for the bone-headed user who has root
     775     * filesystem listed twice.
     776     * "Skip root" will skip _all_ root entries.
    896777     */
    897778    if (skip_root)
     
    907788
    908789        for (fs = filesys_info; fs; fs = fs->next) {
    909             if (cancel_requested)
     790            if (bb_got_signal)
    910791                break;
    911792            if (fs->flags & FLAG_DONE)
     
    913794            /*
    914795             * If the filesystem's pass number is higher
    915              * than the current pass number, then we don't
     796             * than the current pass number, then we didn't
    916797             * do it yet.
    917798             */
     
    932813             * Spawn off the fsck process
    933814             */
    934             fsck_device(fs, serialize);
     815            fsck_device(fs /*, serialize*/);
    935816            fs->flags |= FLAG_DONE;
    936817
     
    947828            }
    948829        }
    949         if (cancel_requested)
     830        if (bb_got_signal)
    950831            break;
    951832        if (verbose > 1)
     
    960841            not_done_yet = 1;
    961842    }
    962     kill_all_if_cancel_requested();
     843    kill_all_if_got_signal();
    963844    status |= wait_many(FLAG_WAIT_ATLEAST_ONE);
    964845    return status;
     
    976857    smallint negate;
    977858
    978     if (fs_type) {
    979         s = fs_type;
    980         while ((s = strchr(s, ','))) {
    981             num++;
    982             s++;
    983         }
     859    s = fs_type;
     860    while ((s = strchr(s, ','))) {
     861        num++;
     862        s++;
    984863    }
    985864
     
    987866    fs_type_flag = xzalloc(num * sizeof(fs_type_flag[0]));
    988867    fs_type_negated = -1; /* not yet known is it negated or not */
    989 
    990     if (!fs_type)
    991         return;
    992868
    993869    num = 0;
     
    1028904}
    1029905
    1030 static void parse_args(int argc, char **argv)
    1031 {
    1032     int i, j;
    1033     char *arg, *tmp;
    1034     char *options = NULL;
    1035     int optpos = 0;
    1036     int opts_for_fsck = 0;
    1037 
    1038     /* in bss, so already zeroed
     906static char **new_args(void)
     907{
     908    args = xrealloc_vector(args, 2, num_args);
     909    return &args[num_args++];
     910}
     911
     912int fsck_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
     913int fsck_main(int argc UNUSED_PARAM, char **argv)
     914{
     915    int i, status;
     916    /*int interactive;*/
     917    struct fs_info *fs;
     918    const char *fstab;
     919    char *tmp;
     920    char **devices;
     921    int num_devices;
     922    smallint opts_for_fsck;
     923    smallint doall;
     924    smallint notitle;
     925
     926    /* we want wait() to be interruptible */
     927    signal_no_SA_RESTART_empty_mask(SIGINT, record_signo);
     928    signal_no_SA_RESTART_empty_mask(SIGTERM, record_signo);
     929
     930    setbuf(stdout, NULL);
     931
     932    opts_for_fsck = doall = notitle = 0;
     933    devices = NULL;
    1039934    num_devices = 0;
    1040     num_args = 0;
    1041     instance_list = NULL;
    1042     */
    1043 
    1044 /* TODO: getopt32 */
    1045     for (i = 1; i < argc; i++) {
    1046         arg = argv[i];
     935    new_args(); /* args[0] = NULL, will be replaced by fsck.<type> */
     936    /* instance_list = NULL; - in bss, so already zeroed */
     937
     938    while (*++argv) {
     939        int j;
     940        int optpos;
     941        char *options;
     942        char *arg = *argv;
    1047943
    1048944        /* "/dev/blk" or "/path" or "UUID=xxx" or "LABEL=xxx" */
     
    1051947// "/path", "UUID=xxx" or "LABEL=xxx" into block device name
    1052948// ("UUID=xxx"/"LABEL=xxx" can probably shifted to fsck.auto duties)
    1053             devices = xrealloc(devices, (num_devices+1) * sizeof(devices[0]));
    1054             devices[num_devices++] = xstrdup(arg);
     949            devices = xrealloc_vector(devices, 2, num_devices);
     950            devices[num_devices++] = arg;
    1055951            continue;
    1056952        }
    1057953
    1058954        if (arg[0] != '-' || opts_for_fsck) {
    1059             args = xrealloc(args, (num_args+1) * sizeof(args[0]));
    1060             args[num_args++] = xstrdup(arg);
     955            *new_args() = arg;
    1061956            continue;
    1062957        }
    1063958
     959        if (LONE_CHAR(arg + 1, '-')) { /* "--" ? */
     960            opts_for_fsck = 1;
     961            continue;
     962        }
     963
     964        optpos = 0;
     965        options = NULL;
    1064966        for (j = 1; arg[j]; j++) {
    1065             if (opts_for_fsck) {
    1066                 optpos++;
    1067                 /* one extra for '\0' */
    1068                 options = xrealloc(options, optpos + 2);
    1069                 options[optpos] = arg[j];
    1070                 continue;
    1071             }
    1072967            switch (arg[j]) {
    1073968            case 'A':
     
    1078973                progress = 1;
    1079974                if (arg[++j]) { /* -Cn */
    1080                     progress_fd = xatoi_u(&arg[j]);
     975                    progress_fd = xatoi_positive(&arg[j]);
    1081976                    goto next_arg;
    1082977                }
    1083978                /* -C n */
    1084                 progress_fd = xatoi_u(argv[++i]);
     979                if (!*++argv)
     980                    bb_show_usage();
     981                progress_fd = xatoi_positive(*argv);
    1085982                goto next_arg;
    1086983#endif
     
    11111008                if (arg[++j])
    11121009                    tmp = &arg[j];
    1113                 else if (++i < argc)
    1114                     tmp = argv[i];
     1010                else if (*++argv)
     1011                    tmp = *argv;
    11151012                else
    11161013                    bb_show_usage();
     
    11181015                compile_fs_type(fstype);
    11191016                goto next_arg;
    1120             case '-':
    1121                 opts_for_fsck++;
    1122                 break;
    11231017            case '?':
    11241018                bb_show_usage();
     
    11361030            options[0] = '-';
    11371031            options[optpos + 1] = '\0';
    1138             args = xrealloc(args, (num_args+1) * sizeof(args[0]));
    1139             args[num_args++] = options;
    1140             optpos = 0;
    1141             options = NULL;
     1032            *new_args() = options;
    11421033        }
    11431034    }
     
    11471038    if (tmp)
    11481039        max_running = xatoi(tmp);
    1149 }
    1150 
    1151 static void signal_cancel(int sig ATTRIBUTE_UNUSED)
    1152 {
    1153     cancel_requested = 1;
    1154 }
    1155 
    1156 int fsck_main(int argc, char **argv);
    1157 int fsck_main(int argc, char **argv)
    1158 {
    1159     int i, status = 0;
    1160     int interactive;
    1161     const char *fstab;
    1162     struct fs_info *fs;
    1163     struct sigaction sa;
    1164 
    1165     memset(&sa, 0, sizeof(sa));
    1166     sa.sa_handler = signal_cancel;
    1167     sigaction(SIGINT, &sa, 0);
    1168     sigaction(SIGTERM, &sa, 0);
    1169 
    1170     setbuf(stdout, NULL);
    1171 
    1172     parse_args(argc, argv);
     1040    new_args(); /* args[num_args - 2] will be replaced by <device> */
     1041    new_args(); /* args[num_args - 1] is the last, NULL element */
    11731042
    11741043    if (!notitle)
     
    11821051    load_fs_info(fstab);
    11831052
    1184     interactive = (num_devices == 1) | serialize;
    1185 
    1186     /* If -A was specified ("check all"), do that! */
     1053    /*interactive = (num_devices == 1) | serialize;*/
     1054
     1055    if (num_devices == 0)
     1056        /*interactive =*/ serialize = doall = 1;
    11871057    if (doall)
    11881058        return check_all();
    11891059
    1190     if (num_devices == 0) {
    1191         serialize = 1;
    1192         interactive = 1;
    1193         return check_all();
    1194     }
    1195 
     1060    status = 0;
    11961061    for (i = 0; i < num_devices; i++) {
    1197         if (cancel_requested) {
    1198             kill_all_if_cancel_requested();
     1062        if (bb_got_signal) {
     1063            kill_all_if_got_signal();
    11991064            break;
    12001065        }
     
    12021067        fs = lookup(devices[i]);
    12031068        if (!fs)
    1204             fs = create_fs_device(devices[i], 0, "auto", 0, -1, -1);
    1205         fsck_device(fs, interactive);
     1069            fs = create_fs_device(devices[i], "", "auto", NULL, -1);
     1070        fsck_device(fs /*, interactive */);
    12061071
    12071072        if (serialize
    12081073         || (max_running && (num_running >= max_running))
    12091074        ) {
    1210             struct fsck_instance *inst;
    1211 
    1212             inst = wait_one(0);
    1213             if (inst) {
    1214                 status |= inst->exit_status;
    1215                 free_instance(inst);
    1216             }
     1075            int exit_status = wait_one(0);
     1076            if (exit_status >= 0)
     1077                status |= exit_status;
    12171078            if (verbose > 1)
    12181079                puts("----------------------------------");
  • branches/2.2.9/mindi-busybox/e2fsprogs/lsattr.c

    r1765 r2725  
    4646    if (option_mask32 & OPT_PF_LONG) {
    4747        printf("%-28s ", name);
    48         print_flags(stdout, fsflags, PFOPT_LONG);
    49         puts("");
     48        print_e2flags(stdout, fsflags, PFOPT_LONG);
     49        bb_putchar('\n');
    5050    } else {
    51         print_flags(stdout, fsflags, 0);
     51        print_e2flags(stdout, fsflags, 0);
    5252        printf(" %s\n", name);
    5353    }
     
    5858}
    5959
    60 static int lsattr_dir_proc(const char *dir_name, struct dirent *de,
    61                void *private)
     60static int FAST_FUNC lsattr_dir_proc(const char *dir_name,
     61        struct dirent *de,
     62        void *private UNUSED_PARAM)
    6263{
    6364    struct stat st;
     
    7576            printf("\n%s:\n", path);
    7677            iterate_on_dir(path, lsattr_dir_proc, NULL);
    77             puts("");
     78            bb_putchar('\n');
    7879        }
    7980    }
     
    9697}
    9798
    98 int lsattr_main(int argc, char **argv);
    99 int lsattr_main(int argc, char **argv)
     99int lsattr_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
     100int lsattr_main(int argc UNUSED_PARAM, char **argv)
    100101{
    101102    getopt32(argv, "Radlv");
     
    103104
    104105    if (!*argv)
    105         lsattr_args(".");
    106     else {
    107         while (*argv)
    108             lsattr_args(*argv++);
    109     }
     106        *--argv = (char*)".";
     107    do lsattr_args(*argv++); while (*argv);
    110108
    111109    return EXIT_SUCCESS;
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/Config.in

    r1765 r2725  
     1# DO NOT EDIT. This file is generated from Config.src
    12#
    23# For a description of the syntax of this configuration file,
     
    56
    67menu "Linux Ext2 FS Progs"
     8
     9
    710
    811config CHATTR
     
    3942    default n
    4043    help
    41       mke2fs is used to create an ext2/ext3 filesystem.  The normal compat
     44      mke2fs is used to create an ext2/ext3 filesystem. The normal compat
    4245      symlinks 'mkfs.ext2' and 'mkfs.ext3' are also provided.
    4346
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/Kbuild

    r1765 r2725  
     1# DO NOT EDIT. This file is generated from Kbuild.src
    12# Makefile for busybox
    23#
    34# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
    45#
    5 # Licensed under the GPL v2, see the file LICENSE in this tarball.
     6# Licensed under GPLv2, see file LICENSE in this source tree.
    67
    78lib-y:=
     9
     10
    811
    912lib-$(CONFIG_CHATTR)     += chattr.o
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/blkid/Kbuild

    r1765 r2725  
     1# DO NOT EDIT. This file is generated from Kbuild.src
    12# Makefile for busybox
    23#
    34# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
    45#
    5 # Licensed under the GPL v2, see the file LICENSE in this tarball.
     6# Licensed under GPLv2, see file LICENSE in this source tree.
    67
    78NEEDED-$(CONFIG_E2FSCK) = y
     
    1112
    1213lib-y:=
     14
     15
     16
    1317lib-$(NEEDED-y) += cache.o dev.o devname.o devno.o blkid_getsize.o \
    1418                   probe.o read.o resolve.o save.o tag.o list.o
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/blkid/blkid.h

    r1765 r2725  
    1111 * %End-Header%
    1212 */
    13 
    14 #ifndef _BLKID_BLKID_H
    15 #define _BLKID_BLKID_H
     13#ifndef BLKID_BLKID_H
     14#define BLKID_BLKID_H 1
    1615
    1716#include <sys/types.h>
     
    103102#endif
    104103
    105 #endif /* _BLKID_BLKID_H */
     104#endif
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/blkid/blkidP.h

    r1765 r2725  
    1111 * %End-Header%
    1212 */
    13 
    14 #ifndef _BLKID_BLKIDP_H
    15 #define _BLKID_BLKIDP_H
     13#ifndef BLKID_BLKIDP_H
     14#define BLKID_BLKIDP_H 1
    1615
    1716#include <sys/types.h>
     
    185184#endif
    186185
    187 #endif /* _BLKID_BLKIDP_H */
     186#endif
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/blkid/cache.c

    r1765 r2725  
    3636                filename ? filename : "default cache"));
    3737
    38     if (!(cache = (blkid_cache) calloc(1, sizeof(struct blkid_struct_cache))))
    39         return -BLKID_ERR_MEM;
     38    cache = xzalloc(sizeof(struct blkid_struct_cache));
    4039
    4140    INIT_LIST_HEAD(&cache->bic_devs);
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/blkid/dev.c

    r1765 r2725  
    2121    blkid_dev dev;
    2222
    23     if (!(dev = (blkid_dev) calloc(1, sizeof(struct blkid_struct_dev))))
    24         return NULL;
     23    dev = xzalloc(sizeof(struct blkid_struct_dev));
    2524
    2625    INIT_LIST_HEAD(&dev->bid_devs);
     
    8382            printf("    tag: NULL\n");
    8483    }
    85     puts("");
     84    bb_putchar('\n');
    8685}
    8786#endif
     
    162161{
    163162    blkid_dev_iterate   iter;
    164     blkid_cache         cache = NULL;
     163    blkid_cache     cache = NULL;
    165164    blkid_dev       dev;
    166165    int         c, ret;
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/blkid/devname.c

    r1765 r2725  
    153153
    154154    DBG(DEBUG_DEVNAME, printf("opening %s\n", lvm_device));
    155     if ((lvf = fopen(lvm_device, "r")) == NULL) {
     155    if ((lvf = fopen_for_read(lvm_device)) == NULL) {
    156156        DBG(DEBUG_DEVNAME, printf("%s: (%d) %s\n", lvm_device, errno,
    157157                      strerror(errno)));
     
    234234    char device[110];
    235235
    236     procpt = fopen(PROC_EVMS_VOLUMES, "r");
     236    procpt = fopen_for_read(PROC_EVMS_VOLUMES);
    237237    if (!procpt)
    238238        return 0;
    239239    while (fgets(line, sizeof(line), procpt)) {
    240         if (sscanf (line, " %d %d %d %*s %*s %[^\n ]",
     240        if (sscanf(line, " %d %d %d %*s %*s %[^\n ]",
    241241                &ma, &mi, &sz, device) != 4)
    242242            continue;
     
    259259    FILE *proc;
    260260    char line[1024];
    261     char ptname0[128], ptname1[128], *ptname = 0;
     261    char ptname0[128], ptname1[128], *ptname = NULL;
    262262    char *ptnames[2];
    263263    dev_t devs[2];
     
    274274
    275275    if (cache->bic_flags & BLKID_BIC_FL_PROBED &&
    276         time(0) - cache->bic_time < BLKID_PROBE_INTERVAL)
     276        time(NULL) - cache->bic_time < BLKID_PROBE_INTERVAL)
    277277        return 0;
    278278
     
    283283#endif
    284284
    285     proc = fopen(PROC_PARTITIONS, "r");
     285    proc = fopen_for_read(PROC_PARTITIONS);
    286286    if (!proc)
    287287        return -BLKID_ERR_PROC;
     
    336336    fclose(proc);
    337337
    338     cache->bic_time = time(0);
     338    cache->bic_time = time(NULL);
    339339    cache->bic_flags |= BLKID_BIC_FL_PROBED;
    340340    blkid_flush_cache(cache);
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/blkid/list.h

    r1765 r2725  
    11/* vi: set sw=4 ts=4: */
    22#if !defined(_BLKID_LIST_H) && !defined(LIST_HEAD)
    3 #define _BLKID_LIST_H
     3#define BLKID_LIST_H 1
    44
    55#ifdef __cplusplus
     
    7171#endif
    7272
    73 #endif /* _BLKID_LIST_H */
     73#endif
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/blkid/probe.c

    r1765 r2725  
    8383{
    8484    struct ext2_super_block *es = (struct ext2_super_block *) buf;
    85     const char *label = 0;
     85    const char *label = NULL;
    8686
    8787    DBG(DEBUG_PROBE, printf("ext2_sb.compat = %08X:%08X:%08X\n",
     
    169169    struct vfat_super_block *vs;
    170170    char serno[10];
    171     const char *label = 0;
     171    const char *label = NULL;
    172172    int label_len = 0;
    173173
     
    202202    struct msdos_super_block *ms = (struct msdos_super_block *) buf;
    203203    char serno[10];
    204     const char *label = 0;
     204    const char *label = NULL;
    205205    int label_len = 0;
    206206
     
    233233{
    234234    struct xfs_super_block *xs;
    235     const char *label = 0;
     235    const char *label = NULL;
    236236
    237237    xs = (struct xfs_super_block *)buf;
     
    251251    struct reiserfs_super_block *rs = (struct reiserfs_super_block *) buf;
    252252    unsigned int blocksize;
    253     const char *label = 0;
     253    const char *label = NULL;
    254254
    255255    blocksize = blkid_le16(rs->rs_blocksize);
     
    278278{
    279279    struct jfs_super_block *js;
    280     const char *label = 0;
     280    const char *label = NULL;
    281281
    282282    js = (struct jfs_super_block *)buf;
     
    296296{
    297297    struct romfs_super_block *ros;
    298     const char *label = 0;
     298    const char *label = NULL;
    299299
    300300    ros = (struct romfs_super_block *)buf;
     
    313313{
    314314    struct cramfs_super_block *csb;
    315     const char *label = 0;
     315    const char *label = NULL;
    316316
    317317    csb = (struct cramfs_super_block *)buf;
     
    430430    major = ocfsmajor(ovh);
    431431    if (major == 1)
    432         blkid_set_tag(dev,"SEC_TYPE","ocfs1",sizeof("ocfs1"));
     432        blkid_set_tag(dev, "SEC_TYPE", "ocfs1", sizeof("ocfs1"));
    433433    else if (major >= 9)
    434         blkid_set_tag(dev,"SEC_TYPE","ntocfs",sizeof("ntocfs"));
     434        blkid_set_tag(dev, "SEC_TYPE", "ntocfs", sizeof("ntocfs"));
    435435
    436436    blkid_set_tag(dev, "LABEL", (const char*)ovl.label, ocfslabellen(ovl));
     
    563563        return NULL;
    564564
    565     now = time(0);
     565    now = time(NULL);
    566566    diff = now - dev->bid_time;
    567567
     
    660660    if (dev && type) {
    661661        dev->bid_devno = st.st_rdev;
    662         dev->bid_time = time(0);
     662        dev->bid_time = time(NULL);
    663663        dev->bid_flags |= BLKID_BID_FL_VERIFIED;
    664664        cache->bic_flags |= BLKID_BIC_FL_CHANGED;
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/blkid/probe.h

    r1765 r2725  
    1212 * %End-Header%
    1313 */
    14 
    15 #ifndef _BLKID_PROBE_H
    16 #define _BLKID_PROBE_H
     14#ifndef BLKID_PROBE_H
     15#define BLKID_PROBE_H 1
    1716
    1817#include <linux/types.h>
     
    309308    __asm__("bswap %0" : "=r" (val) : "0" (val));
    310309#else
    311     __asm__("xchgb %b0,%h0\n\t" /* swap lower bytes */
    312         "rorl $16,%0\n\t"   /* swap words       */
    313         "xchgb %b0,%h0"     /* swap higher bytes    */
     310    __asm__("xchgb %b0,%h0\n\t" /* swap lower bytes  */
     311        "rorl $16,%0\n\t"   /* swap words        */
     312        "xchgb %b0,%h0"     /* swap higher bytes */
    314313        :"=q" (val)
    315314        : "0" (val));
     
    320319_INLINE_ __u16 blkid_swab16(__u16 val)
    321320{
    322     __asm__("xchgb %b0,%h0"     /* swap bytes       */ \
    323         : "=q" (val) \
    324         :  "0" (val)); \
     321    __asm__("xchgb %b0,%h0"     /* swap bytes */
     322        : "=q" (val)
     323        :  "0" (val));
    325324        return val;
    326325}
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/blkid/read.c

    r1765 r2725  
    375375                cache->bic_filename));
    376376
    377     file = fdopen(fd, "r");
    378     if (!file)
    379         goto errout;
     377    file = xfdopen_for_read(fd);
    380378
    381379    while (fgets(buf, sizeof(buf), file)) {
     
    437435            printf("    tag: NULL\n");
    438436    }
    439     puts("");
     437    bb_putchar('\n');
    440438}
    441439
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/blkid/resolve.c

    r1765 r2725  
    6666    blkid_dev dev;
    6767    blkid_cache c = cache;
    68     char *t = 0, *v = 0;
     68    char *t = NULL, *v = NULL;
    6969    char *ret = NULL;
    7070
     
    122122    }
    123123    if (blkid_get_cache(&cache, bb_dev_null) < 0) {
    124         fprintf(stderr, "cannot get blkid cache\n");
     124        fprintf(stderr, "Can't get blkid cache\n");
    125125        exit(1);
    126126    }
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/blkid/save.c

    r1765 r2725  
    9696        fd = mkstemp(tmp);
    9797        if (fd >= 0) {
    98             file = fdopen(fd, "w");
     98            file = xfdopen_for_write(fd);
    9999            opened = tmp;
    100100        }
     
    103103
    104104    if (!file) {
    105         file = fopen(filename, "w");
     105        file = fopen_for_write(filename);
    106106        opened = filename;
    107107    }
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/blkid/tag.c

    r1765 r2725  
    2222    blkid_tag tag;
    2323
    24     if (!(tag = (blkid_tag) calloc(1, sizeof(struct blkid_struct_tag))))
    25         return NULL;
     24    tag = xzalloc(sizeof(struct blkid_struct_tag));
    2625
    2726    INIT_LIST_HEAD(&tag->bit_tags);
     
    114113{
    115114    blkid_tag   t = 0, head = 0;
    116     char        *val = 0;
     115    char        *val = NULL;
    117116
    118117    if (!dev || !name)
     
    365364{
    366365    blkid_tag_iterate   iter;
    367     blkid_cache         cache = NULL;
     366    blkid_cache     cache = NULL;
    368367    blkid_dev       dev;
    369368    int         c, ret, found;
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/chattr.c

    r1765 r2725  
    171171}
    172172
    173 int chattr_main(int argc, char **argv);
     173int chattr_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
    174174int chattr_main(int argc, char **argv)
    175175{
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/e2fsbb.h

    r1765 r2725  
    77 */
    88
    9 #ifndef __E2FSBB_H__
    10 #define __E2FSBB_H__ 1
     9#ifndef E2FSBB_H
     10#define E2FSBB_H 1
    1111
    1212#include "libbb.h"
     
    4141#endif
    4242
    43 #endif /* __E2FSBB_H__ */
     43#endif
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/e2fsck.c

    r1765 r2725  
    2727 * part of the ext2fs journaling system.
    2828 *
    29  * Licensed under GPLv2 or later, see file License in this tarball for details.
    30  */
    31 
    32 #ifndef _GNU_SOURCE
    33 #define _GNU_SOURCE 1 /* get strnlen() */
    34 #endif
     29 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
     30 */
    3531
    3632#include "e2fsck.h" /*Put all of our defines here to clean things up*/
     
    9086struct problem_context {
    9187    errcode_t       errcode;
    92     ext2_ino_t ino, ino2, dir;
     88    ext2_ino_t      ino, ino2, dir;
    9389    struct ext2_inode *inode;
    9490    struct ext2_dir_entry *dirent;
    95     blk_t   blk, blk2;
     91    blk_t           blk, blk2;
    9692    e2_blkcnt_t     blkcount;
    9793    int             group;
    98     __u64   num;
    99     const char *str;
     94    __u64           num;
     95    const char      *str;
    10096};
    10197
     
    134130
    135131typedef struct dnode_t {
    136     struct dnode_t *dict_left;
    137     struct dnode_t *dict_right;
    138     struct dnode_t *dict_parent;
    139     dnode_color_t dict_color;
    140     const void *dict_key;
    141     void *dict_data;
     132    struct dnode_t *dict_left;
     133    struct dnode_t *dict_right;
     134    struct dnode_t *dict_parent;
     135    dnode_color_t dict_color;
     136    const void *dict_key;
     137    void *dict_data;
    142138} dnode_t;
    143139
     
    146142
    147143typedef struct dict_t {
    148     dnode_t dict_nilnode;
    149     dictcount_t dict_nodecount;
    150     dictcount_t dict_maxcount;
    151     dict_comp_t dict_compare;
    152     dnode_free_t dict_freenode;
    153     int dict_dupes;
     144    dnode_t dict_nilnode;
     145    dictcount_t dict_nodecount;
     146    dictcount_t dict_maxcount;
     147    dict_comp_t dict_compare;
     148    dnode_free_t dict_freenode;
     149    int dict_dupes;
    154150} dict_t;
    155151
     
    157153
    158154typedef struct dict_load_t {
    159     dict_t *dict_dictptr;
    160     dnode_t dict_nilnode;
     155    dict_t *dict_dictptr;
     156    dnode_t dict_nilnode;
    161157} dict_load_t;
    162158
     
    193189#define K_DEV_JOURNAL   2
    194190
    195 #define lock_buffer(bh) do {} while(0)
    196 #define unlock_buffer(bh) do {} while(0)
     191#define lock_buffer(bh) do {} while (0)
     192#define unlock_buffer(bh) do {} while (0)
    197193#define buffer_req(bh) 1
    198 #define do_readahead(journal, start) do {} while(0)
     194#define do_readahead(journal, start) do {} while (0)
    199195
    200196static e2fsck_t e2fsck_global_ctx;  /* Try your very best not to use this! */
     
    215211    kmem_cache_t *new_cache;
    216212
    217     new_cache = malloc(sizeof(*new_cache));
    218     if (new_cache)
    219         new_cache->object_length = len;
     213    new_cache = xmalloc(sizeof(*new_cache));
     214    new_cache->object_length = len;
    220215    return new_cache;
    221216}
     
    270265static void rotate_left(dnode_t *upper)
    271266{
    272     dnode_t *lower, *lowleft, *upparent;
    273 
    274     lower = upper->right;
    275     upper->right = lowleft = lower->left;
    276     lowleft->parent = upper;
    277 
    278     lower->parent = upparent = upper->parent;
    279 
    280     /* don't need to check for root node here because root->parent is
    281        the sentinel nil node, and root->parent->left points back to root */
    282 
    283     if (upper == upparent->left) {
    284     upparent->left = lower;
    285     } else {
    286     assert (upper == upparent->right);
    287     upparent->right = lower;
    288     }
    289 
    290     lower->left = upper;
    291     upper->parent = lower;
     267    dnode_t *lower, *lowleft, *upparent;
     268
     269    lower = upper->right;
     270    upper->right = lowleft = lower->left;
     271    lowleft->parent = upper;
     272
     273    lower->parent = upparent = upper->parent;
     274
     275    /* don't need to check for root node here because root->parent is
     276       the sentinel nil node, and root->parent->left points back to root */
     277
     278    if (upper == upparent->left) {
     279        upparent->left = lower;
     280    } else {
     281        assert (upper == upparent->right);
     282        upparent->right = lower;
     283    }
     284
     285    lower->left = upper;
     286    upper->parent = lower;
    292287}
    293288
     
    299294static void rotate_right(dnode_t *upper)
    300295{
    301     dnode_t *lower, *lowright, *upparent;
    302 
    303     lower = upper->left;
    304     upper->left = lowright = lower->right;
    305     lowright->parent = upper;
    306 
    307     lower->parent = upparent = upper->parent;
    308 
    309     if (upper == upparent->right) {
    310     upparent->right = lower;
    311     } else {
    312     assert (upper == upparent->left);
    313     upparent->left = lower;
    314     }
    315 
    316     lower->right = upper;
    317     upper->parent = lower;
     296    dnode_t *lower, *lowright, *upparent;
     297
     298    lower = upper->left;
     299    upper->left = lowright = lower->right;
     300    lowright->parent = upper;
     301
     302    lower->parent = upparent = upper->parent;
     303
     304    if (upper == upparent->right) {
     305        upparent->right = lower;
     306    } else {
     307        assert (upper == upparent->left);
     308        upparent->left = lower;
     309    }
     310
     311    lower->right = upper;
     312    upper->parent = lower;
    318313}
    319314
     
    325320static void free_nodes(dict_t *dict, dnode_t *node, dnode_t *nil)
    326321{
    327     if (node == nil)
    328     return;
    329     free_nodes(dict, node->left, nil);
    330     free_nodes(dict, node->right, nil);
    331     dict->dict_freenode(node);
     322    if (node == nil)
     323        return;
     324    free_nodes(dict, node->left, nil);
     325    free_nodes(dict, node->right, nil);
     326    dict->dict_freenode(node);
    332327}
    333328
     
    341336static int verify_dict_has_node(dnode_t *nil, dnode_t *root, dnode_t *node)
    342337{
    343     if (root != nil) {
    344     return root == node
    345         || verify_dict_has_node(nil, root->left, node)
    346         || verify_dict_has_node(nil, root->right, node);
    347     }
    348     return 0;
     338    if (root != nil) {
     339        return root == node
     340            || verify_dict_has_node(nil, root->left, node)
     341            || verify_dict_has_node(nil, root->right, node);
     342    }
     343    return 0;
    349344}
    350345
     
    356351static void dict_set_allocator(dict_t *dict, dnode_free_t fr)
    357352{
    358     assert (dict_count(dict) == 0);
    359     dict->dict_freenode = fr;
     353    assert(dict_count(dict) == 0);
     354    dict->dict_freenode = fr;
    360355}
    361356
     
    367362static void dict_free_nodes(dict_t *dict)
    368363{
    369     dnode_t *nil = dict_nil(dict), *root = dict_root(dict);
    370     free_nodes(dict, root, nil);
    371     dict->dict_nodecount = 0;
    372     dict->nilnode.left = &dict->nilnode;
    373     dict->nilnode.right = &dict->nilnode;
     364    dnode_t *nil = dict_nil(dict), *root = dict_root(dict);
     365    free_nodes(dict, root, nil);
     366    dict->dict_nodecount = 0;
     367    dict->nilnode.left = &dict->nilnode;
     368    dict->nilnode.right = &dict->nilnode;
    374369}
    375370
     
    380375static dict_t *dict_init(dict_t *dict, dictcount_t maxcount, dict_comp_t comp)
    381376{
    382     dict->compare = comp;
    383     dict->dict_freenode = dnode_free;
    384     dict->dict_nodecount = 0;
    385     dict->maxcount = maxcount;
    386     dict->nilnode.left = &dict->nilnode;
    387     dict->nilnode.right = &dict->nilnode;
    388     dict->nilnode.parent = &dict->nilnode;
    389     dict->nilnode.color = dnode_black;
    390     dict->dupes = 0;
    391     return dict;
     377    dict->compare = comp;
     378    dict->dict_freenode = dnode_free;
     379    dict->dict_nodecount = 0;
     380    dict->maxcount = maxcount;
     381    dict->nilnode.left = &dict->nilnode;
     382    dict->nilnode.right = &dict->nilnode;
     383    dict->nilnode.parent = &dict->nilnode;
     384    dict->nilnode.color = dnode_black;
     385    dict->dupes = 0;
     386    return dict;
    392387}
    393388
     
    401396static dnode_t *dict_lookup(dict_t *dict, const void *key)
    402397{
    403     dnode_t *root = dict_root(dict);
    404     dnode_t *nil = dict_nil(dict);
    405     dnode_t *saved;
    406     int result;
    407 
    408     /* simple binary search adapted for trees that contain duplicate keys */
    409 
    410     while (root != nil) {
    411     result = dict->compare(key, root->key);
    412     if (result < 0)
    413         root = root->left;
    414     else if (result > 0)
    415         root = root->right;
    416     else {
    417         if (!dict->dupes) { /* no duplicates, return match          */
    418         return root;
    419         } else {            /* could be dupes, find leftmost one    */
    420         do {
    421             saved = root;
    422             root = root->left;
    423             while (root != nil && dict->compare(key, root->key))
     398    dnode_t *root = dict_root(dict);
     399    dnode_t *nil = dict_nil(dict);
     400    dnode_t *saved;
     401    int result;
     402
     403    /* simple binary search adapted for trees that contain duplicate keys */
     404
     405    while (root != nil) {
     406        result = dict->compare(key, root->key);
     407        if (result < 0)
     408            root = root->left;
     409        else if (result > 0)
    424410            root = root->right;
    425         } while (root != nil);
    426         return saved;
    427         }
    428     }
    429     }
    430 
    431     return NULL;
     411        else {
     412            if (!dict->dupes) { /* no duplicates, return match          */
     413                return root;
     414            } else {            /* could be dupes, find leftmost one    */
     415                do {
     416                    saved = root;
     417                    root = root->left;
     418                    while (root != nil && dict->compare(key, root->key))
     419                        root = root->right;
     420                } while (root != nil);
     421                return saved;
     422            }
     423        }
     424    }
     425
     426    return NULL;
    432427}
    433428
     
    442437static void dict_insert(dict_t *dict, dnode_t *node, const void *key)
    443438{
    444     dnode_t *where = dict_root(dict), *nil = dict_nil(dict);
    445     dnode_t *parent = nil, *uncle, *grandpa;
    446     int result = -1;
    447 
    448     node->key = key;
    449 
    450     /* basic binary tree insert */
    451 
    452     while (where != nil) {
    453     parent = where;
    454     result = dict->compare(key, where->key);
    455     /* trap attempts at duplicate key insertion unless it's explicitly allowed */
    456     assert (dict->dupes || result != 0);
     439    dnode_t *where = dict_root(dict), *nil = dict_nil(dict);
     440    dnode_t *parent = nil, *uncle, *grandpa;
     441    int result = -1;
     442
     443    node->key = key;
     444
     445    /* basic binary tree insert */
     446
     447    while (where != nil) {
     448        parent = where;
     449        result = dict->compare(key, where->key);
     450        /* trap attempts at duplicate key insertion unless it's explicitly allowed */
     451        assert(dict->dupes || result != 0);
     452        if (result < 0)
     453            where = where->left;
     454        else
     455            where = where->right;
     456    }
     457
     458    assert(where == nil);
     459
    457460    if (result < 0)
    458         where = where->left;
     461        parent->left = node;
    459462    else
    460         where = where->right;
    461     }
    462 
    463     assert (where == nil);
    464 
    465     if (result < 0)
    466     parent->left = node;
    467     else
    468     parent->right = node;
    469 
    470     node->parent = parent;
    471     node->left = nil;
    472     node->right = nil;
    473 
    474     dict->dict_nodecount++;
    475 
    476     /* red black adjustments */
    477 
    478     node->color = dnode_red;
    479 
    480     while (parent->color == dnode_red) {
    481     grandpa = parent->parent;
    482     if (parent == grandpa->left) {
    483         uncle = grandpa->right;
    484         if (uncle->color == dnode_red) {    /* red parent, red uncle */
    485         parent->color = dnode_black;
    486         uncle->color = dnode_black;
    487         grandpa->color = dnode_red;
    488         node = grandpa;
    489         parent = grandpa->parent;
    490         } else {                            /* red parent, black uncle */
    491         if (node == parent->right) {
    492             rotate_left(parent);
    493             parent = node;
    494             assert (grandpa == parent->parent);
    495             /* rotation between parent and child preserves grandpa */
    496         }
    497         parent->color = dnode_black;
    498         grandpa->color = dnode_red;
    499         rotate_right(grandpa);
    500         break;
    501         }
    502     } else {        /* symmetric cases: parent == parent->parent->right */
    503         uncle = grandpa->left;
    504         if (uncle->color == dnode_red) {
    505         parent->color = dnode_black;
    506         uncle->color = dnode_black;
    507         grandpa->color = dnode_red;
    508         node = grandpa;
    509         parent = grandpa->parent;
    510         } else {
    511         if (node == parent->left) {
    512             rotate_right(parent);
    513             parent = node;
    514             assert (grandpa == parent->parent);
    515         }
    516         parent->color = dnode_black;
    517         grandpa->color = dnode_red;
    518         rotate_left(grandpa);
    519         break;
    520         }
    521     }
    522     }
    523 
    524     dict_root(dict)->color = dnode_black;
    525 
     463        parent->right = node;
     464
     465    node->parent = parent;
     466    node->left = nil;
     467    node->right = nil;
     468
     469    dict->dict_nodecount++;
     470
     471    /* red black adjustments */
     472
     473    node->color = dnode_red;
     474
     475    while (parent->color == dnode_red) {
     476        grandpa = parent->parent;
     477        if (parent == grandpa->left) {
     478            uncle = grandpa->right;
     479            if (uncle->color == dnode_red) {    /* red parent, red uncle */
     480                parent->color = dnode_black;
     481                uncle->color = dnode_black;
     482                grandpa->color = dnode_red;
     483                node = grandpa;
     484                parent = grandpa->parent;
     485            } else {                            /* red parent, black uncle */
     486                if (node == parent->right) {
     487                    rotate_left(parent);
     488                    parent = node;
     489                    assert (grandpa == parent->parent);
     490                    /* rotation between parent and child preserves grandpa */
     491                }
     492                parent->color = dnode_black;
     493                grandpa->color = dnode_red;
     494                rotate_right(grandpa);
     495                break;
     496            }
     497        } else {        /* symmetric cases: parent == parent->parent->right */
     498            uncle = grandpa->left;
     499            if (uncle->color == dnode_red) {
     500                parent->color = dnode_black;
     501                uncle->color = dnode_black;
     502                grandpa->color = dnode_red;
     503                node = grandpa;
     504                parent = grandpa->parent;
     505            } else {
     506                if (node == parent->left) {
     507                    rotate_right(parent);
     508                    parent = node;
     509                    assert (grandpa == parent->parent);
     510                }
     511                parent->color = dnode_black;
     512                grandpa->color = dnode_red;
     513                rotate_left(grandpa);
     514                break;
     515            }
     516        }
     517    }
     518
     519    dict_root(dict)->color = dnode_black;
    526520}
    527521
     
    533527static dnode_t *dnode_init(dnode_t *dnode, void *data)
    534528{
    535     dnode->data = data;
    536     dnode->parent = NULL;
    537     dnode->left = NULL;
    538     dnode->right = NULL;
    539     return dnode;
     529    dnode->data = data;
     530    dnode->parent = NULL;
     531    dnode->left = NULL;
     532    dnode->right = NULL;
     533    return dnode;
    540534}
    541535
    542536static int dict_alloc_insert(dict_t *dict, const void *key, void *data)
    543537{
    544     dnode_t *node = malloc(sizeof(dnode_t));
    545 
    546     if (node) {
     538    dnode_t *node = xmalloc(sizeof(dnode_t));
     539
    547540    dnode_init(node, data);
    548541    dict_insert(dict, node, key);
    549542    return 1;
    550     }
    551     return 0;
    552543}
    553544
     
    559550static dnode_t *dict_first(dict_t *dict)
    560551{
    561     dnode_t *nil = dict_nil(dict), *root = dict_root(dict), *left;
    562 
    563     if (root != nil)
    564     while ((left = root->left) != nil)
    565         root = left;
    566 
    567     return (root == nil) ? NULL : root;
     552    dnode_t *nil = dict_nil(dict), *root = dict_root(dict), *left;
     553
     554    if (root != nil)
     555        while ((left = root->left) != nil)
     556            root = left;
     557
     558    return (root == nil) ? NULL : root;
    568559}
    569560
     
    577568static dnode_t *dict_next(dict_t *dict, dnode_t *curr)
    578569{
    579     dnode_t *nil = dict_nil(dict), *parent, *left;
    580 
    581     if (curr->right != nil) {
    582     curr = curr->right;
    583     while ((left = curr->left) != nil)
    584         curr = left;
    585     return curr;
    586     }
    587 
    588     parent = curr->parent;
    589 
    590     while (parent != nil && curr == parent->right) {
    591     curr = parent;
     570    dnode_t *nil = dict_nil(dict), *parent, *left;
     571
     572    if (curr->right != nil) {
     573        curr = curr->right;
     574        while ((left = curr->left) != nil)
     575            curr = left;
     576        return curr;
     577    }
     578
    592579    parent = curr->parent;
    593     }
    594 
    595     return (parent == nil) ? NULL : parent;
     580
     581    while (parent != nil && curr == parent->right) {
     582        curr = parent;
     583        parent = curr->parent;
     584    }
     585
     586    return (parent == nil) ? NULL : parent;
    596587}
    597588
     
    599590static void dnode_free(dnode_t *node)
    600591{
    601     free(node);
     592    free(node);
    602593}
    603594
     
    810801                       * sizeof (struct dx_dirblock_info),
    811802                       "dx_block info array");
    812 
    813803}
    814804
     
    15441534    struct inode            *j_inode = NULL;
    15451535    struct kdev_s           *dev_fs = NULL, *dev_journal;
    1546     const char              *journal_name = 0;
     1536    const char              *journal_name = NULL;
    15471537    journal_t               *journal = NULL;
    15481538    errcode_t               retval = 0;
     
    17331723    ext2fs_free_mem(&journal);
    17341724    return retval;
    1735 
    17361725}
    17371726
     
    18871876
    18881877    /* Leave a valid existing V1 superblock signature alone.
    1889      * Anything unrecognisable we overwrite with a new V2
     1878     * Anything unrecognizable we overwrite with a new V2
    18901879     * signature. */
    18911880
     
    22712260    fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY;
    22722261    inode.i_links_count = 0;
    2273     inode.i_dtime = time(0);
     2262    inode.i_dtime = time(NULL);
    22742263    if ((retval = ext2fs_write_inode(fs, ino, &inode)) != 0)
    22752264        goto err_out;
     
    23932382    N_("llost+found"),
    23942383    N_("Lis a link"),
    2395     N_("mmultiply-claimed"),
    2396     N_("ninvalid"),
     2384    N_("mmultiply-claimed"),
     2385    N_("ninvalid"),
    23972386    N_("oorphaned"),
    23982387    N_("pproblem in"),
     
    24442433        }
    24452434        if ((ch < 32) || (ch == 0x7f)) {
    2446             fputc('^', stdout);
     2435            bb_putchar('^');
    24472436            ch ^= 0x40; /* ^@, ^A, ^B; ^? for DEL */
    24482437        }
    2449         fputc(ch, stdout);
     2438        bb_putchar(ch);
    24502439    }
    24512440}
     
    24982487        if (*first && islower(*str)) {
    24992488            *first = 0;
    2500             fputc(toupper(*str++), stdout);
     2489            bb_putchar(toupper(*str++));
    25012490        }
    25022491        print_e2fsck_message(ctx, str, pctx, *first);
     
    26312620    switch (ch) {
    26322621    case '%':
    2633         fputc('%', stdout);
     2622        bb_putchar('%');
    26342623        break;
    26352624    case 'b':
     
    26552644        break;
    26562645    case 'm':
    2657         printf("%s", error_message(ctx->errcode));
     2646        fputs(error_message(ctx->errcode), stdout);
    26582647        break;
    26592648    case 'N':
     
    26772666        break;
    26782667    case 's':
    2679         printf("%s", ctx->str ? ctx->str : "NULL");
     2668        fputs((ctx->str ? ctx->str : "NULL"), stdout);
    26802669        break;
    26812670    case 'X':
     
    27432732    region_t        region;
    27442733
    2745     region = malloc(sizeof(struct region_struct));
    2746     if (!region)
    2747         return NULL;
    2748     memset(region, 0, sizeof(struct region_struct));
     2734    region = xzalloc(sizeof(struct region_struct));
    27492735    region->min = min;
    27502736    region->max = max;
     
    28112797     * Insert a new region element structure into the linked list
    28122798     */
    2813     new_region = malloc(sizeof(struct region_el));
    2814     if (!new_region)
    2815         return -1;
     2799    new_region = xmalloc(sizeof(struct region_el));
    28162800    new_region->start = start;
    28172801    new_region->end = start + n;
     
    33823366            if (!LINUX_S_ISDIR(inode->i_mode)) {
    33833367                if (fix_problem(ctx, PR_1_ROOT_NO_DIR, &pctx)) {
    3384                     inode->i_dtime = time(0);
     3368                    inode->i_dtime = time(NULL);
    33853369                    inode->i_links_count = 0;
    33863370                    ext2fs_icount_store(ctx->inode_link_info,
     
    33893373                               "pass1");
    33903374                }
    3391 
    33923375            }
    33933376            /*
     
    34763459            if (fix_problem(ctx, PR_1_LOW_DTIME, &pctx)) {
    34773460                inode->i_dtime = inode->i_links_count ?
    3478                     0 : time(0);
     3461                    0 : time(NULL);
    34793462                e2fsck_write_inode(ctx, ino, inode,
    34803463                           "pass1");
     
    34903473                if (fix_problem(ctx,
    34913474                        PR_1_ZERO_DTIME, &pctx)) {
    3492                     inode->i_dtime = time(0);
     3475                    inode->i_dtime = time(NULL);
    34933476                    e2fsck_write_inode(ctx, ino, inode,
    34943477                               "pass1");
     
    36603643        e2fsck_read_inode(ctx, EXT2_RESIZE_INO, inode,
    36613644                  "recreate inode");
    3662         inode->i_mtime = time(0);
     3645        inode->i_mtime = time(NULL);
    36633646        e2fsck_write_inode(ctx, EXT2_RESIZE_INO, inode,
    36643647                  "recreate inode");
     
    36923675    ext2fs_free_mem(&block_buf);
    36933676    ext2fs_free_mem(&inode);
    3694 
    36953677}
    36963678
     
    41704152        inode->i_links_count = 0;
    41714153        ext2fs_icount_store(ctx->inode_link_info, ino, 0);
    4172         inode->i_dtime = time(0);
     4154        inode->i_dtime = time(NULL);
    41734155        dirty_inode++;
    41744156        ext2fs_unmark_inode_bitmap(ctx->inode_dir_map, ino);
     
    42034185            inode->i_links_count = 0;
    42044186            ext2fs_icount_store(ctx->inode_link_info, ino, 0);
    4205             inode->i_dtime = time(0);
     4187            inode->i_dtime = time(NULL);
    42064188            dirty_inode++;
    42074189            ext2fs_unmark_inode_bitmap(ctx->inode_dir_map, ino);
     
    44654447                    }
    44664448                } else {
    4467                     ext2fs_mark_block_bitmap(ctx->block_found_map,
    4468                                  b);
     4449                    ext2fs_mark_block_bitmap(ctx->block_found_map, b);
    44694450                }
    44704451            }
     
    44834464                }
    44844465            } else {
    4485                 ext2fs_mark_block_bitmap(ctx->block_found_map,
    4486                      fs->group_desc[i].bg_block_bitmap);
    4487             }
    4488 
     4466                ext2fs_mark_block_bitmap(ctx->block_found_map,
     4467                    fs->group_desc[i].bg_block_bitmap);
     4468            }
    44894469        }
    44904470        /*
     
    45004480                }
    45014481            } else {
    4502                 ext2fs_mark_block_bitmap(ctx->block_found_map,
    4503                      fs->group_desc[i].bg_inode_bitmap);
     4482                ext2fs_mark_block_bitmap(ctx->block_found_map,
     4483                    fs->group_desc[i].bg_inode_bitmap);
    45044484            }
    45054485        }
     
    51485128    e2fsck_read_inode(ctx, ino, &inode, "delete_file");
    51495129    inode.i_links_count = 0;
    5150     inode.i_dtime = time(0);
     5130    inode.i_dtime = time(NULL);
    51515131    if (inode.i_file_acl &&
    51525132        (fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_EXT_ATTR)) {
     
    56025582        }
    56035583    }
    5604 
    56055584}
    56065585
     
    60195998    struct dx_dir_info      *dx_dir;
    60205999#ifdef ENABLE_HTREE
    6021     struct dx_dirblock_info *dx_db = 0;
     6000    struct dx_dirblock_info *dx_db = NULL;
    60226001#endif /* ENABLE_HTREE */
    60236002    struct ext2_dir_entry   *dirent, *prev;
     
    63946373    e2fsck_read_inode(ctx, ino, &inode, "deallocate_inode");
    63956374    inode.i_links_count = 0;
    6396     inode.i_dtime = time(0);
     6375    inode.i_dtime = time(NULL);
    63976376    e2fsck_write_inode(ctx, ino, &inode, "deallocate_inode");
    63986377    clear_problem_context(&pctx);
     
    68916870    inode.i_mode = 040755;
    68926871    inode.i_size = fs->blocksize;
    6893     inode.i_atime = inode.i_ctime = inode.i_mtime = time(0);
     6872    inode.i_atime = inode.i_ctime = inode.i_mtime = time(NULL);
    68946873    inode.i_links_count = 2;
    68956874    inode.i_blocks = fs->blocksize / 512;
     
    71397118    inode.i_mode = 040700;
    71407119    inode.i_size = fs->blocksize;
    7141     inode.i_atime = inode.i_ctime = inode.i_mtime = time(0);
     7120    inode.i_atime = inode.i_ctime = inode.i_mtime = time(NULL);
    71427121    inode.i_links_count = 2;
    71437122    inode.i_blocks = fs->blocksize / 512;
     
    74937472            ext2fs_icount_store(ctx->inode_link_info, i, 0);
    74947473            inode.i_links_count = 0;
    7495             inode.i_dtime = time(0);
     7474            inode.i_dtime = time(NULL);
    74967475            e2fsck_write_inode(ctx, i, &inode,
    74977476                       "disconnect_inode");
     
    75347513    struct problem_context  pctx;
    75357514    __u16   link_count, link_counted;
    7536     char    *buf = 0;
     7515    char    *buf = NULL;
    75377516    int     group, maxgroup;
    75387517
     
    94019380    /* Cannot proceed without a root inode. */
    94029381    { PR_3_NO_ROOT_INODE_ABORT,
    9403       N_("Cannot proceed without a @r.\n"),
     9382      N_("can't proceed without a @r.\n"),
    94049383      PROMPT_NONE, PR_FATAL },
    94059384
     
    96809659    ext2_filsys fs = ctx->fs;
    96819660    const struct e2fsck_problem *ptr;
    9682     struct latch_descr *ldesc = 0;
     9661    struct latch_descr *ldesc = NULL;
    96839662    const char *message;
    96849663    int             def_yn, answer, ans;
     
    97629741            printf("%s.\n", answer ?
    97639742                   _(preen_msg[(int) ptr->prompt]) : _("IGNORED"));
    9764 
    97659743    }
    97669744
     
    100159993         * to do with it?  That depends on the pass... */
    100169994
    10017         switch(blocktype) {
     9995        switch (blocktype) {
    100189996        case JFS_DESCRIPTOR_BLOCK:
    100199997            /* If it is a valid descriptor block, replay it
     
    1031210290        }
    1031310291        if (fd->num_array >= fd->max_array) {
    10314             new_array = realloc(fd->harray,
     10292            new_array = xrealloc(fd->harray,
    1031510293                sizeof(struct hash_entry) * (fd->max_array+500));
    10316             if (!new_array) {
    10317                 fd->err = ENOMEM;
    10318                 return BLOCK_ABORT;
    10319             }
    1032010294            fd->harray = new_array;
    1032110295            fd->max_array += 500;
     
    1039210366
    1039310367    if (outdir->max) {
    10394         new_mem = realloc(outdir->buf, blocks * fs->blocksize);
    10395         if (!new_mem)
    10396             return ENOMEM;
     10368        new_mem = xrealloc(outdir->buf, blocks * fs->blocksize);
    1039710369        outdir->buf = new_mem;
    10398         new_mem = realloc(outdir->hashes,
     10370        new_mem = xrealloc(outdir->hashes,
    1039910371                  blocks * sizeof(ext2_dirhash_t));
    10400         if (!new_mem)
    10401             return ENOMEM;
    1040210372        outdir->hashes = new_mem;
    1040310373    } else {
    10404         outdir->buf = malloc(blocks * fs->blocksize);
    10405         outdir->hashes = malloc(blocks * sizeof(ext2_dirhash_t));
     10374        outdir->buf = xmalloc(blocks * fs->blocksize);
     10375        outdir->hashes = xmalloc(blocks * sizeof(ext2_dirhash_t));
    1040610376        outdir->num = 0;
    1040710377    }
     
    1068710657{
    1068810658    struct ext2_dx_root_info        *root_info;
    10689     struct ext2_dx_entry            *root, *dx_ent = 0;
     10659    struct ext2_dx_entry            *root, *dx_ent = NULL;
    1069010660    struct ext2_dx_countlimit       *root_limit, *limit;
    1069110661    errcode_t                       retval;
     
    1083910809    errcode_t               retval;
    1084010810    struct ext2_inode       inode;
    10841     char                    *dir_buf = 0;
     10811    char                    *dir_buf = NULL;
    1084210812    struct fill_dir_struct  fd;
    1084310813    struct out_dir          outdir;
     
    1085010820    retval = ENOMEM;
    1085110821    fd.harray = 0;
    10852     dir_buf = malloc(inode.i_size);
    10853     if (!dir_buf)
    10854         goto errout;
     10822    dir_buf = xmalloc(inode.i_size);
    1085510823
    1085610824    fd.max_array = inode.i_size / 32;
    1085710825    fd.num_array = 0;
    10858     fd.harray = malloc(fd.max_array * sizeof(struct hash_entry));
    10859     if (!fd.harray)
    10860         goto errout;
     10826    fd.harray = xmalloc(fd.max_array * sizeof(struct hash_entry));
    1086110827
    1086210828    fd.ctx = ctx;
     
    1115911125    shift = 0;
    1116011126    tmp = hash_size;
    11161     while((tmp >>= 1UL) != 0UL)
     11127    while ((tmp >>= 1UL) != 0UL)
    1116211128        shift++;
    1116311129    journal->j_revoke->hash_shift = shift;
    1116411130
    11165     journal->j_revoke->hash_table = malloc(hash_size * sizeof(struct list_head));
    11166     if (!journal->j_revoke->hash_table) {
    11167         free(journal->j_revoke);
    11168         journal->j_revoke = NULL;
    11169         return -ENOMEM;
    11170     }
     11131    journal->j_revoke->hash_table = xmalloc(hash_size * sizeof(struct list_head));
    1117111132
    1117211133    for (tmp = 0; tmp < hash_size; tmp++)
     
    1135511316        (blk >= fs->super->s_blocks_count)) {
    1135611317        fix_problem(ctx, PR_0_ORPHAN_ILLEGAL_BLOCK_NUM, pctx);
    11357     return_abort:
     11318 return_abort:
    1135811319        pb->abort = 1;
    1135911320        return BLOCK_ABORT;
     
    1155911520            ext2fs_inode_alloc_stats2(fs, ino, -1,
    1156011521                          LINUX_S_ISDIR(inode.i_mode));
    11561             inode.i_dtime = time(0);
     11522            inode.i_dtime = time(NULL);
    1156211523        } else {
    1156311524            inode.i_dtime = 0;
     
    1156811529    ext2fs_free_mem(&block_buf);
    1156911530    return 0;
    11570 return_abort:
     11531 return_abort:
    1157111532    ext2fs_free_mem(&block_buf);
    1157211533    return 1;
     
    1158611547    int             i, j, gdt_off, ind_off;
    1158711548    blk_t           blk, pblk, expect;
    11588     __u32           *dind_buf = 0, *ind_buf;
     11549    __u32           *dind_buf = NULL, *ind_buf;
    1158911550    errcode_t       retval;
    1159011551
     
    1164911610        (blk < fs->super->s_first_data_block ||
    1165011611         blk >= fs->super->s_blocks_count)) {
    11651     resize_inode_invalid:
     11612 resize_inode_invalid:
    1165211613        if (fix_problem(ctx, PR_0_RESIZE_INODE_INVALID, &pctx)) {
    1165311614            memset(&inode, 0, sizeof(inode));
     
    1169111652    }
    1169211653
    11693 cleanup:
     11654 cleanup:
    1169411655    ext2fs_free_mem(&dind_buf);
    11695 
    11696  }
     11656}
    1169711657
    1169811658static void check_super_block(e2fsck_t ctx)
     
    1187311833            (gd->bg_used_dirs_count > sb->s_inodes_per_group))
    1187411834            ext2fs_unmark_valid(fs);
    11875 
    1187611835    }
    1187711836
     
    1193311892                ~EXT2_FEATURE_INCOMPAT_FILETYPE;
    1193411893            ext2fs_mark_super_dirty(fs);
    11935 
    1193611894        }
    1193711895    }
     
    1222012178    char buf[256];
    1222112179
    12222     ret = malloc(size);
    12223     if (!ret) {
    12224         sprintf(buf, "Can't allocate %s\n", description);
    12225         bb_error_msg_and_die(buf);
    12226     }
    12227     memset(ret, 0, size);
     12180    ret = xzalloc(size);
    1222812181    return ret;
    1222912182}
     
    1223712190    if (!len)
    1223812191        len = strlen(str);
    12239     ret = malloc(len+1);
    12240     if (ret) {
    12241         strncpy(ret, str, len);
    12242         ret[len] = 0;
    12243     }
     12192    ret = xmalloc(len+1);
     12193    strncpy(ret, str, len);
     12194    ret[len] = 0;
    1224412195    return ret;
    1224512196}
     
    1225212203    int     fail = 0;
    1225312204
    12254     while(1) {
     12205    while (1) {
    1225512206        if (e2fsck_global_ctx &&
    1225612207            (e2fsck_global_ctx->flags & E2F_FLAG_CANCEL)) {
     
    1228212233    tmp.c_cc[VMIN] = 1;
    1228312234    tmp.c_cc[VTIME] = 0;
    12284     tcsetattr (0, TCSANOW, &tmp);
     12235    tcsetattr_stdin_TCSANOW(&tmp);
    1228512236#endif
    1228612237
     
    1229812249        if (c == 3) {
    1229912250#ifdef HAVE_TERMIOS_H
    12300             tcsetattr (0, TCSANOW, &termios);
     12251            tcsetattr_stdin_TCSANOW(&termios);
    1230112252#endif
    1230212253            if (e2fsck_global_ctx &&
     
    1232412275        puts ("no\n");
    1232512276#ifdef HAVE_TERMIOS_H
    12326     tcsetattr (0, TCSANOW, &termios);
     12277    tcsetattr_stdin_TCSANOW(&termios);
    1232712278#endif
    1232812279    return def;
     
    1263312584                     &ctx->mount_flags);
    1263412585    if (retval) {
    12635         bb_error_msg(_("while determining whether %s is mounted."),
     12586        bb_error_msg(_("while determining whether %s is mounted"),
    1263612587            ctx->filesystem_name);
    1263712588        return;
     
    1265412605    printf(_("%s is mounted.  "), ctx->filesystem_name);
    1265512606    if (!ctx->interactive)
    12656         bb_error_msg_and_die(_("Cannot continue, aborting."));
     12607        bb_error_msg_and_die(_("can't continue, aborting"));
    1265712608    printf(_("\n\n\007\007\007\007WARNING!!!  "
    1265812609           "Running e2fsck on a mounted filesystem may cause\n"
     
    1267312624    struct dirent*  de;
    1267412625
    12675     f = fopen("/proc/apm", "r");
     12626    f = fopen_for_read("/proc/apm");
    1267612627    if (f) {
    1267712628        if (fscanf(f, "%s %s %s %x", tmp, tmp, tmp, &acflag) != 4)
     
    1268712638            snprintf(fname, 80, "/proc/acpi/ac_adapter/%s/state",
    1268812639                 de->d_name);
    12689             f = fopen(fname, "r");
     12640            f = fopen_for_read(fname);
    1269012641            if (!f)
    1269112642                continue;
     
    1271512666    long next_check;
    1271612667    int batt = is_on_batt();
    12717     time_t now = time(0);
     12668    time_t now = time(NULL);
    1271812669
    1271912670    if ((ctx->options & E2F_OPT_FORCE) || cflag || swapfs)
     
    1276812719            printf(_(" (check in %ld mounts)"), next_check);
    1276912720    }
    12770     fputc('\n', stdout);
     12721    bb_putchar('\n');
    1277112722    ext2fs_close(fs);
    1277212723    ctx->fs = NULL;
     
    1286512816           spaces + (sizeof(spaces) - (dpywidth - i + 1)));
    1286612817    if (fixed_percent == 1000)
    12867         fputc('|', stdout);
     12818        bb_putchar('|');
    1286812819    else
    12869         fputc(spinner[ctx->progress_pos & 3], stdout);
     12820        bb_putchar(spinner[ctx->progress_pos & 3]);
    1287012821    printf(" %4.1f%%  ", percent);
    1287112822    if (dpynum)
     
    1289312844    if (ctx->progress_fd) {
    1289412845        sprintf(buf, "%d %lu %lu\n", pass, cur, max);
    12895         write(ctx->progress_fd, buf, strlen(buf));
     12846        xwrite_str(ctx->progress_fd, buf);
    1289612847    } else {
    1289712848        percent = calc_percent(&e2fsck_tbl, pass, cur, max);
     
    1300912960    errcode_t       retval;
    1301012961    struct sigaction        sa;
    13011     char            *extended_opts = 0;
     12962    char            *extended_opts = NULL;
    1301212963
    1301312964    retval = e2fsck_allocate_context(&ctx);
     
    1306113012            if (ctx->options & (E2F_OPT_YES|E2F_OPT_NO)) {
    1306213013            conflict_opt:
    13063                 bb_error_msg_and_die(_("Only one the options -p/-a, -n or -y may be specified."));
     13014                bb_error_msg_and_die(_("only one the options -p/-a, -n or -y may be specified"));
    1306413015            }
    1306513016            ctx->options |= E2F_OPT_PREEN;
     
    1337413325                 * device driver is being bogus.
    1337513326                 */
    13376                 bb_error_msg(_("cannot set superblock flags on %s"), ctx->device_name);
     13327                bb_error_msg(_("can't set superblock flags on %s"), ctx->device_name);
    1337713328                bb_error_msg_and_die(0);
    1337813329            }
     
    1340613357    /* FIXME - do we support this at all? */
    1340713358    if (sb->s_feature_incompat & EXT2_FEATURE_INCOMPAT_COMPRESSION)
    13408         bb_error_msg(_("Warning: compression support is experimental."));
     13359        bb_error_msg(_("warning: compression support is experimental"));
    1340913360#endif
    1341013361#ifndef ENABLE_HTREE
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/e2fsck.h

    r1765 r2725  
    630630
    631631
    632 #define tid_gt(x, y)        ((x - y) > 0)
     632#define tid_gt(x, y)  ((x - y) > 0)
    633633
    634634static inline int tid_geq(tid_t x, tid_t y)
     
    637637    return (difference >= 0);
    638638}
    639 
    640 
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/e2p/Kbuild

    r1765 r2725  
     1# DO NOT EDIT. This file is generated from Kbuild.src
    12# Makefile for busybox
    23#
    34# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
    45#
    5 # Licensed under the GPL v2, see the file LICENSE in this tarball.
     6# Licensed under GPLv2, see file LICENSE in this source tree.
    67
    78NEEDED-$(CONFIG_CHATTR) = y
     
    1112
    1213lib-y:=
     14
     15
     16
    1317lib-$(NEEDED-y) += fgetsetflags.o fgetsetversion.o pf.o iod.o mntopts.o \
    1418           feature.o ls.o uuid.o pe.o ostype.o ps.o hashstr.o \
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/e2p/e2p.h

    r1765 r2725  
    1414#endif
    1515
    16 /* `options' for print_flags() */
     16/* `options' for print_e2flags() */
    1717
    1818#define PFOPT_LONG  1 /* Must be 1 for compatibility with `int long_format'. */
     
    3838void list_super2(struct ext2_super_block * s, FILE *f);
    3939#define list_super(s) list_super2(s, stdout)
    40 void print_fs_errors (FILE * f, unsigned short errors);
    41 void print_flags (FILE * f, unsigned long flags, unsigned options);
    42 void print_fs_state (FILE * f, unsigned short state);
     40void print_fs_errors (FILE *f, unsigned short errors);
     41void print_flags (FILE *f, unsigned long flags, unsigned options);
     42void print_fs_state (FILE *f, unsigned short state);
    4343int setflags (int fd, unsigned long flags);
    4444int setversion (int fd, unsigned long version);
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/e2p/ostype.c

    r1765 r2725  
    7171}
    7272#endif
    73 
    74 
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/e2p/pf.c

    r1765 r2725  
    4949};
    5050
    51 void print_flags (FILE * f, unsigned long flags, unsigned options)
     51void print_flags (FILE *f, unsigned long flags, unsigned options)
    5252{
    5353    int long_opt = (options & PFOPT_LONG);
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/Kbuild

    r1765 r2725  
     1# DO NOT EDIT. This file is generated from Kbuild.src
    12# Makefile for busybox
    23#
    34# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
    45#
    5 # Licensed under the GPL v2, see the file LICENSE in this tarball.
     6# Licensed under GPLv2, see file LICENSE in this source tree.
    67
    78NEEDED-$(CONFIG_E2FSCK) = y
     
    1112
    1213lib-y:=
     14
     15
     16
    1317lib-$(NEEDED-y) += gen_bitmap.o bitops.o ismounted.o mkjournal.o unix_io.o \
    1418                   rw_bitmaps.o initialize.o bitmaps.o block.o \
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/alloc.c

    r1765 r2725  
    110110    errcode_t   retval;
    111111    blk_t       block;
    112     char        *buf = 0;
     112    char        *buf = NULL;
    113113
    114114    if (!block_buf) {
     
    172172    return EXT2_ET_BLOCK_ALLOC_FAIL;
    173173}
    174 
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/alloc_tables.c

    r1765 r2725  
    9898    }
    9999
    100 
    101100    return 0;
    102101}
    103 
    104 
    105102
    106103errcode_t ext2fs_allocate_tables(ext2_filsys fs)
     
    116113    return 0;
    117114}
    118 
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/bb_inode.c

    r1765 r2725  
    126126        goto cleanup;
    127127
    128     inode.i_atime = inode.i_mtime = time(0);
     128    inode.i_atime = inode.i_mtime = time(NULL);
    129129    if (!inode.i_ctime)
    130         inode.i_ctime = time(0);
     130        inode.i_ctime = time(NULL);
    131131    inode.i_blocks = rec.bad_block_count * (fs->blocksize / 512);
    132132    inode.i_size = rec.bad_block_count * fs->blocksize;
     
    261261    return BLOCK_CHANGED;
    262262}
    263 
    264 
    265 
    266 
    267 
    268 
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/bitops.c

    r1765 r2725  
    6666}
    6767
    68 #endif  /* !_EXT2_HAVE_ASM_BITOPS_ */
     68#endif  /* !_EXT2_HAVE_ASM_BITOPS_ */
    6969
    7070void ext2fs_warn_bitmap(errcode_t errcode, unsigned long arg,
     
    8989#endif
    9090}
    91 
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/bitops.h

    r1765 r2725  
    1414 * Linus Torvalds.
    1515 */
    16 
    1716#include <string.h>
    18 //#include <strings.h>
    1917
    2018extern int ext2fs_set_bit(unsigned int nr,void * addr);
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/block.c

    r1765 r2725  
    436436                     block_buf, xlate_func, &xl);
    437437}
    438 
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/bmap.c

    r1765 r2725  
    137137    blk_t addr_per_block;
    138138    blk_t   b;
    139     char    *buf = 0;
     139    char    *buf = NULL;
    140140    errcode_t   retval = 0;
    141141    int     blocks_alloc = 0, inode_dirty = 0;
     
    260260    return retval;
    261261}
    262 
    263 
    264 
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/bmove.c

    r1765 r2725  
    154154    return 0;
    155155}
    156 
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/brel.h

    r1765 r2725  
    8585#define ext2fs_brel_delete(brel, old) ((brel)->delete((brel), old))
    8686#define ext2fs_brel_free(brel) ((brel)->free((brel)))
    87 
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/closefs.c

    r1765 r2725  
    207207    errcode_t   retval;
    208208    unsigned long   fs_state;
    209     struct ext2_super_block *super_shadow = 0;
    210     struct ext2_group_desc *group_shadow = 0;
     209    struct ext2_super_block *super_shadow = NULL;
     210    struct ext2_group_desc *group_shadow = NULL;
    211211    char    *group_ptr;
    212212    int old_desc_blocks;
     
    379379    return 0;
    380380}
    381 
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/cmp_bitmaps.c

    r1765 r2725  
    7171    return 0;
    7272}
    73 
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/dir_iterate.c

    r1765 r2725  
    218218    return 0;
    219219}
    220 
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/dirblock.c

    r1765 r2725  
    8181    errcode_t   retval;
    8282    char        *p, *end;
    83     char        *buf = 0;
     83    char        *buf = NULL;
    8484    struct ext2_dir_entry *dirent;
    8585
     
    131131    return ext2fs_write_dir_block2(fs, block, inbuf, 0);
    132132}
    133 
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/dirhash.c

    r1765 r2725  
    4343        b0 += ((b1 << 4)+a) ^ (b1+sum) ^ ((b1 >> 5)+b);
    4444        b1 += ((b0 << 4)+c) ^ (b0+sum) ^ ((b0 >> 5)+d);
    45     } while(--n);
     45    } while (--n);
    4646
    4747    buf[0] += b0;
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/dupfs.c

    r1765 r2725  
    9393    ext2fs_free(fs);
    9494    return retval;
    95 
    9695}
    97 
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/e2image.h

    r1765 r2725  
    3838    __u32   offset_reserved[8];
    3939};
    40 
    41 
    42 
    43 
    44 
    45 
    46 
    47 
    48 
    49 
    50 
    51 
    52 
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/ext2_ext_attr.h

    r1765 r2725  
    5151#define EXT2_XATTR_SIZE(size) \
    5252    (((size) + EXT2_EXT_ATTR_ROUND) & ~EXT2_EXT_ATTR_ROUND)
    53 
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/ext2_fs.h

    r1765 r2725  
    1414 *  Copyright (C) 1991, 1992  Linus Torvalds
    1515 */
    16 
    17 #ifndef _LINUX_EXT2_FS_H
    18 #define _LINUX_EXT2_FS_H
     16#ifndef LINUX_EXT2_FS_H
     17#define LINUX_EXT2_FS_H 1
    1918
    2019#include "ext2_types.h"     /* Changed from linux/types.h */
     
    568567                     ~EXT2_DIR_ROUND)
    569568
    570 #endif  /* _LINUX_EXT2_FS_H */
     569#endif
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/ext2_io.h

    r1765 r2725  
    1010 * %End-Header%
    1111 */
    12 
    13 #ifndef _EXT2FS_EXT2_IO_H
    14 #define _EXT2FS_EXT2_IO_H
     12#ifndef EXT2FS_EXT2_IO_H
     13#define EXT2FS_EXT2_IO_H 1
    1514
    1615/*
     
    111110    (int blksize, errcode_t err);
    112111
    113 #endif /* _EXT2FS_EXT2_IO_H */
    114 
     112#endif
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/ext2fs.h

    r1765 r2725  
    1010 * %End-Header%
    1111 */
    12 
    13 #ifndef _EXT2FS_EXT2FS_H
    14 #define _EXT2FS_EXT2FS_H
     12#ifndef EXT2FS_EXT2FS_H
     13#define EXT2FS_EXT2FS_H 1
    1514
    1615
     
    921920#endif
    922921
    923 #endif /* _EXT2FS_EXT2FS_H */
     922#endif
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/ext2fsP.h

    r1765 r2725  
    8686                    int         ref_offset,
    8787                    void        *priv_data);
    88 
    89 
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/ext2fs_inline.c

    r1765 r2725  
    5151     * with C99 strict type aliasing rules. */
    5252    memcpy(&p, ptr, sizeof (p));
    53     p = realloc(p, size);
    54     if (!p)
    55         return EXT2_ET_NO_MEMORY;
     53    p = xrealloc(p, size);
    5654    memcpy(ptr, &p, sizeof (p));
    5755    return 0;
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/ext_attr.c

    r1765 r2725  
    6969    errcode_t   retval;
    7070    struct ext2_ext_attr_header *header;
    71     char    *buf = 0;
     71    char    *buf = NULL;
    7272
    7373    if ((blk >= fs->super->s_blocks_count) ||
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/finddev.c

    r1765 r2725  
    116116char *ext2fs_find_block_device(dev_t device)
    117117{
    118     struct dir_list *list = 0, *new_list = 0;
     118    struct dir_list *list = NULL, *new_list = NULL;
    119119    struct dir_list *current;
    120     char    *ret_path = 0;
     120    char    *ret_path = NULL;
    121121
    122122    /*
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/flushb.c

    r1765 r2725  
    2424#if HAVE_SYS_MOUNT_H
    2525#include <sys/param.h>
    26 #include <sys/mount.h>      /* This may define BLKFLSBUF */
     26#include <sys/mount.h>  /* This may define BLKFLSBUF */
    2727#endif
    2828
     
    3939#ifdef __linux__
    4040#ifndef BLKFLSBUF
    41 #define BLKFLSBUF   _IO(0x12,97)    /* flush buffer cache */
     41#define BLKFLSBUF  _IO(0x12,97)  /* flush buffer cache */
    4242#endif
    4343#ifndef FDFLUSH
    44 #define FDFLUSH     _IO(2,0x4b) /* flush floppy disk */
     44#define FDFLUSH    _IO(2,0x4b)  /* flush floppy disk */
    4545#endif
    4646#endif
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/freefs.c

    r1765 r2725  
    126126    ext2fs_free_mem(&dblist);
    127127}
    128 
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/get_pathname.c

    r1765 r2725  
    154154    ext2fs_free_mem(&buf);
    155155    return retval;
    156 
    157156}
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/getsize.c

    r1765 r2725  
    7979    dev = CreateFile(file, GENERIC_READ,
    8080             FILE_SHARE_READ | FILE_SHARE_WRITE ,
    81              NULL,  OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
     81             NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
    8282
    8383    if (dev == INVALID_HANDLE_VALUE)
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/imager.c

    r1765 r2725  
    334334errcode_t ext2fs_image_bitmap_read(ext2_filsys fs, int fd, int flags)
    335335{
    336     char        *ptr, *buf = 0;
     336    char        *ptr, *buf = NULL;
    337337    int     size;
    338338    ssize_t     actual;
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/ind_block.c

    r1765 r2725  
    6868    return io_channel_write_blk(fs->io, blk, 1, buf);
    6969}
    70 
    71 
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/inline.c

    r1765 r2725  
    22/*
    33 * inline.c --- Includes the inlined functions defined in the header
    4  *  files as standalone functions, in case the application program
    5  *  is compiled with inlining turned off.
     4 * files as standalone functions, in case the application program
     5 * is compiled with inlining turned off.
    66 *
    77 * Copyright (C) 1993, 1994 Theodore Ts'o.
     
    3131#define INCLUDE_INLINE_FUNCS
    3232#include "ext2fs.h"
    33 
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/inode.c

    r1765 r2725  
    765765    return 0;
    766766}
    767 
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/inode_io.c

    r1765 r2725  
    269269    return ext2fs_file_flush(data->file);
    270270}
    271 
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/ismounted.c

    r1765 r2725  
    6060#ifndef __GNU__ /* The GNU hurd is broken with respect to stat devices */
    6161            file_rdev = st_buf.st_rdev;
    62 #endif  /* __GNU__ */
     62#endif  /* __GNU__ */
    6363        } else {
    6464            file_dev = st_buf.st_dev;
     
    7474                if (file_rdev && (file_rdev == st_buf.st_rdev))
    7575                    break;
    76 #endif  /* __GNU__ */
     76#endif  /* __GNU__ */
    7777            } else {
    7878                if (file_dev && ((file_dev == st_buf.st_dev) &&
     
    100100            }
    101101        }
    102 #endif  /* __GNU__ */
     102#endif  /* __GNU__ */
    103103        goto errout;
    104104    }
     
    248248        S_ISBLK(st_buf.st_mode))
    249249        file_dev = st_buf.st_rdev;
    250 #endif  /* __GNU__ */
    251 
    252     if (!(f = fopen("/proc/swaps", "r")))
     250#endif  /* __GNU__ */
     251
     252    if (!(f = fopen_for_read("/proc/swaps")))
    253253        return 0;
    254254    /* Skip the first line */
     
    272272            break;
    273273        }
    274 #endif  /* __GNU__ */
     274#endif  /* __GNU__ */
    275275    }
    276276    fclose(f);
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/jfs_dat.h

    r1765 r2725  
    6161    __u32       s_sequence; /* first commit ID expected in log */
    6262    __u32       s_start;    /* blocknr of start of log */
    63 
    6463} journal_superblock_t;
    65 
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/kernel-jbd.h

    r1765 r2725  
    1414 * filesystem journaling support.
    1515 */
    16 
    17 #ifndef _LINUX_JBD_H
    18 #define _LINUX_JBD_H
     16#ifndef LINUX_JBD_H
     17#define LINUX_JBD_H 1
    1918
    2019#include <sys/types.h>
     
    234233
    235234
    236 #endif  /* _LINUX_JBD_H */
     235#endif
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/kernel-list.h

    r1765 r2725  
    11/* vi: set sw=4 ts=4: */
    2 #ifndef _LINUX_LIST_H
    3 #define _LINUX_LIST_H
     2#ifndef LINUX_LIST_H
     3#define LINUX_LIST_H 1
    44
    55/*
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/lookup.c

    r1765 r2725  
    6767    return (ls.found) ? 0 : EXT2_ET_FILE_NOT_FOUND;
    6868}
    69 
    70 
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/mkdir.c

    r1765 r2725  
    4040    ext2_ino_t      scratch_ino;
    4141    blk_t           blk;
    42     char            *block = 0;
     42    char            *block = NULL;
    4343
    4444    EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
     
    137137    ext2fs_free_mem(&block);
    138138    return retval;
    139 
    140139}
    141 
    142 
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/mkjournal.c

    r1765 r2725  
    9696{
    9797    errcode_t   retval;
    98     char        *buf = 0;
     98    char        *buf = NULL;
    9999    int     fd, ret_size;
    100100    blk_t       i;
     
    189189    else
    190190        return BLOCK_CHANGED;
    191 
    192191}
    193192
     
    232231    inode.i_size += fs->blocksize * size;
    233232    inode.i_blocks += (fs->blocksize / 512) * es.newblocks;
    234     inode.i_mtime = inode.i_ctime = time(0);
     233    inode.i_mtime = inode.i_ctime = time(NULL);
    235234    inode.i_links_count = 1;
    236235    inode.i_mode = LINUX_S_IFREG | 0600;
     
    424423    ext2fs_close(fs);
    425424    exit(0);
    426 
    427 }
    428 #endif
     425}
     426#endif
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/namei.c

    r1765 r2725  
    3131{
    3232    char *pathname;
    33     char *buffer = 0;
     33    char *buffer = NULL;
    3434    errcode_t retval;
    3535    struct ext2_inode ei;
     
    4949        return EXT2_ET_SYMLINK_LOOP;
    5050    }
    51     if (ext2fs_inode_data_blocks(fs,&ei)) {
     51    if (ext2fs_inode_data_blocks(fs, &ei)) {
    5252        retval = ext2fs_get_mem(fs->blocksize, &buffer);
    5353        if (retval)
     
    203203    return retval;
    204204}
    205 
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/newdir.c

    r1765 r2725  
    6767        dir->name[0] = '.';
    6868        dir->name[1] = '.';
    69 
    7069    }
    7170    *block = buf;
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/read_bb.c

    r1765 r2725  
    9595    return rb.err;
    9696}
    97 
    98 
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/read_bb_file.c

    r1765 r2725  
    9595                    call_compat_invalid);
    9696}
    97 
    98 
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/res_gdt.c

    r1765 r2725  
    114114        inode.i_size = inode_size & 0xFFFFFFFF;
    115115        inode.i_size_high = (inode_size >> 32) & 0xFFFFFFFF;
    116         if(inode.i_size_high) {
     116        if (inode.i_size_high) {
    117117            sb->s_feature_ro_compat |=
    118118                EXT2_FEATURE_RO_COMPAT_LARGE_FILE;
    119119        }
    120         inode.i_ctime = time(0);
     120        inode.i_ctime = time(NULL);
    121121    }
    122122
     
    210210#endif
    211211    if (inode_dirty) {
    212         inode.i_atime = inode.i_mtime = time(0);
     212        inode.i_atime = inode.i_mtime = time(NULL);
    213213        retval2 = ext2fs_write_inode(fs, EXT2_RESIZE_INO, &inode);
    214214        if (!retval)
     
    219219    return retval;
    220220}
    221 
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/rs_bitmap.c

    r1765 r2725  
    105105    return retval;
    106106}
    107 
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/rw_bitmaps.c

    r1765 r2725  
    150150{
    151151    dgrp_t i;
    152     char *block_bitmap = 0, *inode_bitmap = 0;
     152    char *block_bitmap = NULL, *inode_bitmap = NULL;
    153153    char *buf;
    154154    errcode_t retval;
     
    267267errcode_t ext2fs_read_bitmaps(ext2_filsys fs)
    268268{
    269 
    270269    EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
    271270
     
    294293    return 0;
    295294}
    296 
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/swapfs.c

    r1765 r2725  
    6767    for (i=0; i < 17; i++)
    6868        sb->s_jnl_blocks[i] = ext2fs_swab32(sb->s_jnl_blocks[i]);
    69 
    7069}
    7170
     
    223222                 bufsize - sizeof(struct ext2_inode) -
    224223                 t->i_extra_isize - sizeof(__u32), 0);
    225 
    226224}
    227225
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/test_io.c

    r1765 r2725  
    181181    data->outfile = NULL;
    182182    if ((value = getenv("TEST_IO_LOGFILE")) != NULL)
    183         data->outfile = fopen(value, "w");
     183        data->outfile = fopen_for_write(value);
    184184    if (!data->outfile)
    185185        data->outfile = stderr;
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/ext2fs/unlink.c

    r1765 r2725  
    9898    return (ls.done) ? 0 : EXT2_ET_DIR_NO_SPACE;
    9999}
    100 
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/fsck.c

    r1765 r2725  
    2121 *      2001, 2002, 2003, 2004, 2005 by  Theodore Ts'o.
    2222 *
    23  * %Begin-Header%
    24  * This file may be redistributed under the terms of the GNU Public
    25  * License.
    26  * %End-Header%
     23 * Licensed under GPLv2, see file LICENSE in this source tree.
    2724 */
    2825
     
    286283    if (!s)
    287284        return 0;
    288     ret = strdup(s);
     285    ret = xstrdup(s);
    289286    return ret;
    290287}
     
    353350        return;
    354351
    355     for (p = q = word; *p; q++) {
    356         c = *p++;
    357         if (c != '\\') {
    358             *q = c;
    359         } else {
    360             *q = bb_process_escape_sequence(&p);
    361         }
    362     }
    363     *q = 0;
     352    strcpy_and_process_escape_sequences(word, word);
    364353}
    365354
     
    381370    struct fs_info *fs;
    382371
    383     if (!(fs = malloc(sizeof(struct fs_info))))
    384         return NULL;
     372    fs = xmalloc(sizeof(struct fs_info));
    385373
    386374    fs->device = string_copy(device);
     
    478466    struct fs_info *fs;
    479467
    480     if ((f = fopen(filename, "r")) == NULL) {
    481         bb_perror_msg("WARNING: cannot open %s", filename);
     468    if ((f = fopen_or_warn(filename, "r")) == NULL) {
    482469        return;
    483470    }
     
    535522static char *find_fsck(char *type)
    536523{
    537   char *s;
    538   const char *tpl;
    539   char *p = string_copy(fsck_path);
    540   struct stat st;
    541 
    542   /* Are we looking for a program or just a type? */
    543   tpl = (strncmp(type, "fsck.", 5) ? "%s/fsck.%s" : "%s/%s");
    544 
    545   for(s = strtok(p, ":"); s; s = strtok(NULL, ":")) {
    546     s = xasprintf(tpl, s, type);
    547     if (stat(s, &st) == 0) break;
    548     free(s);
    549   }
    550   free(p);
    551   return s;
     524    char *s;
     525    const char *tpl;
     526    char *p = string_copy(fsck_path);
     527    struct stat st;
     528
     529    /* Are we looking for a program or just a type? */
     530    tpl = (strncmp(type, "fsck.", 5) ? "%s/fsck.%s" : "%s/%s");
     531
     532    for (s = strtok(p, ":"); s; s = strtok(NULL, ":")) {
     533        s = xasprintf(tpl, s, type);
     534        if (stat(s, &st) == 0) break;
     535        free(s);
     536    }
     537    free(p);
     538    return s;
    552539}
    553540
     
    578565    pid_t   pid;
    579566
    580     inst = malloc(sizeof(struct fsck_instance));
    581     if (!inst)
    582         return ENOMEM;
    583     memset(inst, 0, sizeof(struct fsck_instance));
     567    inst = xzalloc(sizeof(struct fsck_instance));
    584568
    585569    prog = xasprintf("fsck.%s", type);
     
    614598        for (i=0; i < argc; i++)
    615599            printf("%s ", argv[i]);
    616         puts("");
     600        bb_putchar('\n');
    617601    }
    618602
     
    621605        pid = -1;
    622606    else if ((pid = fork()) < 0) {
    623         perror("fork");
     607        perror("vfork"+1);
    624608        return errno;
    625609    } else if (pid == 0) {
     
    627611            close(0);
    628612        (void) execv(s, argv);
    629         bb_perror_msg_and_die("%s", argv[0]);
     613        bb_simple_perror_msg_and_die(argv[0]);
    630614    }
    631615
     
    887871    num = 0;
    888872    s = strtok(list, ",");
    889     while(s) {
     873    while (s) {
    890874        negate = 0;
    891875        if (strncmp(s, "no", 2) == 0) {
     
    932916
    933917    s = strtok(list, ",");
    934     while(s) {
     918    while (s) {
    935919        if (strcmp(s, opt) == 0) {
    936920            free(list);
     
    1006990    if (s == NULL) {
    1007991        if (wanted)
    1008             bb_error_msg("cannot check %s: fsck.%s not found",
     992            bb_error_msg("can't check %s: fsck.%s not found",
    1009993                fs->device, fs->type);
    1010994        return 1;
     
    11751159{
    11761160    int     i, j;
    1177     char    *arg, *dev, *tmp = 0;
     1161    char    *arg, *dev, *tmp = NULL;
    11781162    char    options[128];
    11791163    int     opt = 0;
     
    12081192                 */
    12091193                if (access("/proc/partitions", R_OK) < 0) {
    1210                     bb_perror_msg_and_die("cannot open /proc/partitions "
     1194                    bb_perror_msg_and_die("can't open /proc/partitions "
    12111195                            "(is /proc mounted?)");
    12121196                }
     
    12201204                else
    12211205                    bb_error_msg_and_die(
    1222         "cannot find matching filesystem: %s", arg);
     1206        "can't find matching filesystem: %s", arg);
    12231207            }
    12241208            devices[num_devices++] = dev ? dev : string_copy(arg);
     
    13221306}
    13231307
    1324 int fsck_main(int argc, char **argv);
     1308int fsck_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
    13251309int fsck_main(int argc, char **argv)
    13261310{
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/lsattr.c

    r1765 r2725  
    1313/*
    1414 * History:
    15  * 93/10/30 - Creation
    16  * 93/11/13 - Replace stat() calls by lstat() to avoid loops
    17  * 94/02/27 - Integrated in Ted's distribution
    18  * 98/12/29 - Display version info only when -V specified (G M Sipe)
     15 * 93/10/30 - Creation
     16 * 93/11/13 - Replace stat() calls by lstat() to avoid loops
     17 * 94/02/27 - Integrated in Ted's distribution
     18 * 98/12/29 - Display version info only when -V specified (G M Sipe)
    1919 */
    2020
     
    5757    if (flags & OPT_PF_LONG) {
    5858        printf("%-28s ", name);
    59         print_flags(stdout, fsflags, PFOPT_LONG);
    60         puts("");
     59        print_e2flags(stdout, fsflags, PFOPT_LONG);
     60        bb_putchar('\n');
    6161    } else {
    62         print_flags(stdout, fsflags, 0);
     62        print_e2flags(stdout, fsflags, 0);
    6363        printf(" %s\n", name);
    6464    }
     
    103103                printf("\n%s:\n", path);
    104104                iterate_on_dir(path, lsattr_dir_proc, NULL);
    105                 puts("");
     105                bb_putchar('\n');
    106106            }
    107107        }
     
    113113}
    114114
    115 int lsattr_main(int argc, char **argv);
     115int lsattr_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
    116116int lsattr_main(int argc, char **argv)
    117117{
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/mke2fs.c

    r1765 r2725  
    66 *  2003, 2004, 2005 by Theodore Ts'o.
    77 *
    8  * This file may be redistributed under the terms of the GNU Public
    9  * License.
     8 * Licensed under GPLv2, see file LICENSE in this source tree.
    109 */
    1110
     
    177176    if (retval) {
    178177        va_start(ap, fmt);
    179         fprintf(stderr,"\nCould not ");
     178        fprintf(stderr, "\nCould not ");
    180179        vfprintf(stderr, fmt, ap);
    181180        fprintf(stderr, "\n");
     
    210209    if (retval) {
    211210        va_start(ap, fmt);
    212         fprintf(stderr,"\nWarning: ");
     211        fprintf(stderr, "\nWarning: ");
    213212        vfprintf(stderr, fmt, ap);
    214213        fprintf(stderr, "\n");
     
    226225    errcode_t   retval;
    227226
    228     f = xfopen(bad_blocks_file, "r");
     227    f = xfopen_for_read(bad_blocks_file);
    229228    retval = ext2fs_read_bb_FILE(fs, f, bb_list, invalid_block);
    230229    fclose (f);
     
    247246    f = popen(buf, "r");
    248247    if (!f) {
    249         bb_perror_msg_and_die("cannot run '%s'", buf);
     248        bb_perror_msg_and_die("can't run '%s'", buf);
    250249    }
    251250    retval = ext2fs_read_bb_FILE(fs, f, bb_list, invalid_block);
     
    642641            s->s_inodes_per_group);
    643642    if (fs->group_desc_count == 1) {
    644         puts("");
     643        bb_putchar('\n');
    645644        return;
    646645    }
     
    677676    }
    678677
    679     if((sb->s_creator_os = e2p_string2os(os)) >= 0) {
     678    if ((sb->s_creator_os = e2p_string2os(os)) >= 0) {
    680679        return 1;
    681680    } else if (!strcasecmp("GNU", os)) {
     
    801800    ext2_ino_t  num_inodes = 0;
    802801    errcode_t   retval;
    803     char *      extended_opts = 0;
    804     const char *    fs_type = 0;
     802    char *      extended_opts = NULL;
     803    const char *    fs_type = NULL;
    805804    blk_t       dev_size;
    806805    long        sysval;
     
    897896            break;
    898897        case 'r':
    899             param.s_rev_level = xatoi_u(optarg);
     898            param.s_rev_level = xatoi_positive(optarg);
    900899            if (param.s_rev_level == EXT2_GOOD_OLD_REV) {
    901900                param.s_feature_incompat = 0;
     
    914913#ifdef EXT2_DYNAMIC_REV
    915914        case 'I':
    916             inode_size = xatoi_u(optarg);
     915            inode_size = xatoi_positive(optarg);
    917916            break;
    918917#endif
    919918        case 'N':
    920             num_inodes = xatoi_u(optarg);
     919            num_inodes = xatoi_positive(optarg);
    921920            break;
    922921        case 'v':
     
    11881187    if (ENABLE_FEATURE_CLEAN_UP)
    11891188        atexit(mke2fs_clean_up);
    1190     if(!PRS(argc, argv))
     1189    if (!PRS(argc, argv))
    11911190        return 0;
    11921191
     
    13071306                         NULL, &ret_blk, NULL);
    13081307
    1309         mke2fs_warning_msg(retval, "cannot zero block %u at end of filesystem", ret_blk);
     1308        mke2fs_warning_msg(retval, "can't zero block %u at end of filesystem", ret_blk);
    13101309        write_inode_tables(fs);
    13111310        create_root_dir(fs);
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/tune2fs.c

    r1765 r2725  
    99 * Copyright 1995, 1996, 1997, 1998, 1999, 2000 by Theodore Ts'o.
    1010 *
    11  * %Begin-Header%
    12  * This file may be redistributed under the terms of the GNU Public
    13  * License.
    14  * %End-Header%
     11 * Licensed under GPLv2, see file LICENSE in this source tree.
    1512 */
    1613
     
    396393#endif
    397394    if (ts.tm_mday == 0) {
    398         bb_error_msg_and_die("Cannot parse date/time specifier: %s", str);
     395        bb_error_msg_and_die("can't parse date/time specifier: %s", str);
    399396    }
    400397    return mktime(&ts);
     
    558555}
    559556
    560 #ifdef CONFIG_FINDFS
    561 static ATTRIBUTE_NORETURN void do_findfs(int argc, char **argv)
    562 {
    563     if ((argc != 2) ||
    564         (strncmp(argv[1], "LABEL=", 6) && strncmp(argv[1], "UUID=", 5)))
    565         bb_show_usage();
    566     device_name = x_blkid_get_devname(argv[1]);
    567     puts(device_name);
    568     exit(0);
    569 }
    570 #else
    571 #define do_findfs(x, y)
    572 #endif
    573 
    574557static void tune2fs_clean_up(void)
    575558{
     
    578561}
    579562
    580 int tune2fs_main(int argc, char **argv);
     563int tune2fs_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
    581564int tune2fs_main(int argc, char **argv)
    582565{
     
    589572        atexit(tune2fs_clean_up);
    590573
    591     if (ENABLE_FINDFS && (applet_name[0] == 'f')) /* findfs */
    592         do_findfs(argc, argv);  /* no return */
    593     else if (ENABLE_E2LABEL && (applet_name[0] == 'e')) /* e2label */
     574    if (ENABLE_E2LABEL && (applet_name[0] == 'e')) /* e2label */
    594575        parse_e2label_options(argc, argv);
    595576    else
     
    610591    retval = ext2fs_check_if_mounted(device_name, &mount_flags);
    611592    if (retval)
    612         bb_error_msg_and_die("cannot determine if %s is mounted", device_name);
     593        bb_error_msg_and_die("can't determine if %s is mounted", device_name);
    613594    /* Normally we only need to write out the superblock */
    614595    fs->flags |= EXT2_FLAG_SUPER_ONLY;
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/util.c

    r1765 r2725  
    55 * Copyright 1995, 1996, 1997, 1998, 1999, 2000 by Theodore Ts'o.
    66 *
    7  * %Begin-Header%
    8  * This file may be redistributed under the terms of the GNU Public
    9  * License.
    10  * %End-Header%
     7 * Licensed under GPLv2, see file LICENSE in this source tree.
    118 */
    129
     
    3835    if (force)
    3936        return;
    40     if(val == -1)
    41         bb_perror_msg_and_die("cannot stat %s", device);
     37    if (val == -1)
     38        bb_perror_msg_and_die("can't stat '%s'", device);
    4239    if (!S_ISBLK(s.st_mode)) {
    4340        printf("%s is not a block special device.\n", device);
     
    8380    retval = ext2fs_check_if_mounted(device, &mount_flags);
    8481    if (retval) {
    85         bb_error_msg("cannot determine if %s is mounted", device);
     82        bb_error_msg("can't determine if %s is mounted", device);
    8683        return;
    8784    }
     
    9996        goto force_check;
    10097    }
    101 
    10298}
    10399
     
    220216                    fs->blocksize, io_ptr, &jfs);
    221217    if (retval)
    222         bb_error_msg_and_die("cannot journal device %s", journal_device);
    223     if(!quiet)
     218        bb_error_msg_and_die("can't journal device %s", journal_device);
     219    if (!quiet)
    224220        printf("Adding journal to device %s: ", journal_device);
    225221    fflush(stdout);
    226222    retval = ext2fs_add_journal_device(fs, jfs);
    227     if(retval)
     223    if (retval)
    228224        bb_error_msg_and_die("\nFailed to add journal to device %s", journal_device);
    229     if(!quiet)
     225    if (!quiet)
    230226        puts("done");
    231227    ext2fs_close(jfs);
     
    243239        return;
    244240    }
    245     if(!quiet)
     241    if (!quiet)
    246242        printf("Creating journal (%ld blocks): ", journal_blocks);
    247243    fflush(stdout);
    248244    retval = ext2fs_add_journal_inode(fs, journal_blocks,
    249245                          journal_flags);
    250     if(retval)
    251         bb_error_msg_and_die("cannot create journal");
    252     if(!quiet)
     246    if (retval)
     247        bb_error_msg_and_die("can't create journal");
     248    if (!quiet)
    253249        puts("done");
    254250}
     
    263259     else
    264260        oldpath = PATH_SET;
    265     putenv (oldpath);
     261    putenv(oldpath);
    266262    return oldpath;
    267263}
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/uuid/Kbuild

    r1765 r2725  
     1# DO NOT EDIT. This file is generated from Kbuild.src
    12# Makefile for busybox
    23#
    34# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
    45#
    5 # Licensed under the GPL v2, see the file LICENSE in this tarball.
     6# Licensed under GPLv2, see file LICENSE in this source tree.
    67
    78NEEDED-$(CONFIG_E2FSCK) = y
     
    1112
    1213lib-y:=
     14
     15
    1316lib-$(NEEDED-y) += compare.o gen_uuid.o pack.o parse.o unpack.o unparse.o \
    1417                   uuid_time.o
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/uuid/gen_uuid.c

    r1765 r2725  
    166166    for (i = 0; i < n; i+= ifreq_size(*ifrp) ) {
    167167        ifrp = (struct ifreq *)((char *) ifc.ifc_buf+i);
    168         strncpy(ifr.ifr_name, ifrp->ifr_name, IFNAMSIZ);
     168        strncpy_IFNAMSIZ(ifr.ifr_name, ifrp->ifr_name);
    169169#ifdef SIOCGIFHWADDR
    170170        if (ioctl(sd, SIOCGIFHWADDR, &ifr) < 0)
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/uuid/uuid.h

    r1765 r2725  
    3333 * %End-Header%
    3434 */
    35 
    36 #ifndef _UUID_UUID_H
    37 #define _UUID_UUID_H
     35#ifndef UUID_UUID_H
     36#define UUID_UUID_H 1
    3837
    3938#include <sys/types.h>
     
    5554#ifdef __GNUC__
    5655#define UUID_DEFINE(name,u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15) \
    57     static const uuid_t name ATTRIBUTE_UNUSED = {u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15}
     56    static const uuid_t name UNUSED_PARAM = {u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15}
    5857#else
    5958#define UUID_DEFINE(name,u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,u10,u11,u12,u13,u14,u15) \
  • branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/uuid/uuid_time.c

    r1765 r2725  
    148148        break;
    149149    default:
    150         puts("");
     150        bb_putchar('\n');
    151151    }
    152152    if (type != 1) {
Note: See TracChangeset for help on using the changeset viewer.