Changeset 3621 in MondoRescue for branches/3.3/mindi-busybox/util-linux


Ignore:
Timestamp:
Dec 20, 2016, 4:07:32 PM (9 years ago)
Author:
Bruno Cornec
Message:

New 3?3 banch for incorporation of latest busybox 1.25. Changing minor version to handle potential incompatibilities.

Location:
branches/3.3
Files:
10 added
73 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/3.3/mindi-busybox/util-linux/Config.src

    r3232 r3621  
    435435      any need to reading text files, you can leave this disabled.
    436436
    437 config MOUNT
    438     bool "mount"
    439     default y
    440     select PLATFORM_LINUX
    441     help
    442       All files and filesystems in Unix are arranged into one big directory
    443       tree. The 'mount' utility is used to graft a filesystem onto a
    444       particular part of the tree. A filesystem can either live on a block
    445       device, or it can be accessible over the network, as is the case with
    446       NFS filesystems. Most people using BusyBox will also want to enable
    447       the 'mount' utility.
    448 
    449 config FEATURE_MOUNT_FAKE
    450     bool "Support option -f"
    451     default y
    452     depends on MOUNT
    453     help
    454       Enable support for faking a file system mount.
    455 
    456 config FEATURE_MOUNT_VERBOSE
    457     bool "Support option -v"
    458     default y
    459     depends on MOUNT
    460     help
    461       Enable multi-level -v[vv...] verbose messages. Useful if you
    462       debug mount problems and want to see what is exactly passed
    463       to the kernel.
    464 
    465 config FEATURE_MOUNT_HELPERS
    466     bool "Support mount helpers"
    467     default n
    468     depends on MOUNT
    469     help
    470       Enable mounting of virtual file systems via external helpers.
    471       E.g. "mount obexfs#-b00.11.22.33.44.55 /mnt" will in effect call
    472       "obexfs -b00.11.22.33.44.55 /mnt"
    473       Also "mount -t sometype [-o opts] fs /mnt" will try
    474       "sometype [-o opts] fs /mnt" if simple mount syscall fails.
    475       The idea is to use such virtual filesystems in /etc/fstab.
    476 
    477 config FEATURE_MOUNT_LABEL
    478     bool "Support specifying devices by label or UUID"
    479     default y
    480     depends on MOUNT
    481     select VOLUMEID
    482     help
    483       This allows for specifying a device by label or uuid, rather than by
    484       name. This feature utilizes the same functionality as blkid/findfs.
    485       This also enables label or uuid support for swapon.
    486 
    487 config FEATURE_MOUNT_NFS
    488     bool "Support mounting NFS file systems on Linux < 2.6.23"
    489     default n
    490     depends on MOUNT
    491     select FEATURE_HAVE_RPC
    492     select FEATURE_SYSLOG
    493     help
    494       Enable mounting of NFS file systems on Linux kernels prior
    495       to version 2.6.23. Note that in this case mounting of NFS
    496       over IPv6 will not be possible.
    497 
    498       Note that this option links in RPC support from libc,
    499       which is rather large (~10 kbytes on uclibc).
    500 
    501 config FEATURE_MOUNT_CIFS
    502     bool "Support mounting CIFS/SMB file systems"
    503     default y
    504     depends on MOUNT
    505     help
    506       Enable support for samba mounts.
    507 
    508 config FEATURE_MOUNT_FLAGS
    509     depends on MOUNT
    510     bool "Support lots of -o flags in mount"
    511     default y
    512     help
    513       Without this, mount only supports ro/rw/remount. With this, it
    514       supports nosuid, suid, dev, nodev, exec, noexec, sync, async, atime,
    515       noatime, diratime, nodiratime, loud, bind, move, shared, slave,
    516       private, unbindable, rshared, rslave, rprivate, and runbindable.
    517 
    518 config FEATURE_MOUNT_FSTAB
    519     depends on MOUNT
    520     bool "Support /etc/fstab and -a"
    521     default y
    522     help
    523       Support mount all and looking for files in /etc/fstab.
    524 
    525437config PIVOT_ROOT
    526438    bool "pivot_root"
     
    577489      This program replays a typescript, using timing information
    578490      given by script -t.
    579 
    580 config SETARCH
    581     bool "setarch"
    582     default y
    583     select PLATFORM_LINUX
    584     help
    585       The linux32 utility is used to create a 32bit environment for the
    586       specified program (usually a shell). It only makes sense to have
    587       this util on a system that supports both 64bit and 32bit userland
    588       (like amd64/x86, ppc64/ppc, sparc64/sparc, etc...).
    589491
    590492config SWAPONOFF
     
    599501      space. If you are not using any swap space, you can leave this
    600502      option disabled.
     503
     504config FEATURE_SWAPON_DISCARD
     505    bool "Support discard option -d"
     506    default y
     507    depends on SWAPONOFF
     508    help
     509      Enable support for discarding swap area blocks at swapon and/or as
     510      the kernel frees them. This option enables both the -d option on
     511      'swapon' and the 'discard' option for swap entries in /etc/fstab.
    601512
    602513config FEATURE_SWAPON_PRI
     
    700611      your kernel.
    701612
    702 config VOLUMEID
    703     bool #No description makes it a hidden option
    704     default n
    705 
    706 menu "Filesystem/Volume identification"
    707     depends on VOLUMEID
    708 
    709 config FEATURE_VOLUMEID_EXT
    710     bool "Ext filesystem"
    711     default y
    712     depends on VOLUMEID
    713     help
    714       TODO
    715 
    716 config FEATURE_VOLUMEID_BTRFS
    717     bool "btrfs filesystem"
    718     default y
    719     depends on VOLUMEID
    720     help
    721       TODO
    722 
    723 config FEATURE_VOLUMEID_REISERFS
    724     bool "Reiser filesystem"
    725     default y
    726     depends on VOLUMEID
    727     help
    728       TODO
    729 
    730 config FEATURE_VOLUMEID_FAT
    731     bool "fat filesystem"
    732     default y
    733     depends on VOLUMEID
    734     help
    735       TODO
    736 
    737 config FEATURE_VOLUMEID_EXFAT
    738     bool "exFAT filesystem"
    739     default y
    740     depends on VOLUMEID
    741     help
    742       exFAT (extended FAT) is a proprietary file system designed especially
    743       for flash drives. It has many features from NTFS, but with less
    744       overhead. exFAT is used on most SDXC cards for consumer electronics.
    745 
    746 config FEATURE_VOLUMEID_HFS
    747     bool "hfs filesystem"
    748     default y
    749     depends on VOLUMEID
    750     help
    751       TODO
    752 
    753 config FEATURE_VOLUMEID_JFS
    754     bool "jfs filesystem"
    755     default y
    756     depends on VOLUMEID
    757     help
    758       TODO
    759 
    760 ### config FEATURE_VOLUMEID_UFS
    761 ### bool "ufs filesystem"
    762 ### default y
    763 ### depends on VOLUMEID
    764 ### help
    765 ###   TODO
    766 
    767 config FEATURE_VOLUMEID_XFS
    768     bool "xfs filesystem"
    769     default y
    770     depends on VOLUMEID
    771     help
    772       TODO
    773 
    774 config FEATURE_VOLUMEID_NILFS
    775     bool "nilfs filesystem"
    776     default y
    777     depends on VOLUMEID
    778     help
    779       TODO
    780 
    781 config FEATURE_VOLUMEID_NTFS
    782     bool "ntfs filesystem"
    783     default y
    784     depends on VOLUMEID
    785     help
    786       TODO
    787 
    788 config FEATURE_VOLUMEID_ISO9660
    789     bool "iso9660 filesystem"
    790     default y
    791     depends on VOLUMEID
    792     help
    793       TODO
    794 
    795 config FEATURE_VOLUMEID_UDF
    796     bool "udf filesystem"
    797     default y
    798     depends on VOLUMEID
    799     help
    800       TODO
    801 
    802 config FEATURE_VOLUMEID_LUKS
    803     bool "luks filesystem"
    804     default y
    805     depends on VOLUMEID
    806     help
    807       TODO
    808 
    809 config FEATURE_VOLUMEID_LINUXSWAP
    810     bool "linux swap filesystem"
    811     default y
    812     depends on VOLUMEID
    813     help
    814       TODO
    815 
    816 ### config FEATURE_VOLUMEID_LVM
    817 ### bool "lvm"
    818 ### default y
    819 ### depends on VOLUMEID
    820 ### help
    821 ###   TODO
    822 
    823 config FEATURE_VOLUMEID_CRAMFS
    824     bool "cramfs filesystem"
    825     default y
    826     depends on VOLUMEID
    827     help
    828       TODO
    829 
    830 ### config FEATURE_VOLUMEID_HPFS
    831 ### bool "hpfs filesystem"
    832 ### default y
    833 ### depends on VOLUMEID
    834 ### help
    835 ###   TODO
    836 
    837 config FEATURE_VOLUMEID_ROMFS
    838     bool "romfs filesystem"
    839     default y
    840     depends on VOLUMEID
    841     help
    842       TODO
    843 
    844 config FEATURE_VOLUMEID_SQUASHFS
    845     bool "SquashFS filesystem"
    846     default y
    847     depends on VOLUMEID && FEATURE_BLKID_TYPE
    848     help
    849       Squashfs is a compressed read-only filesystem for Linux. Squashfs is
    850       intended for general read-only filesystem use and in constrained block
    851       device/memory systems (e.g. embedded systems) where low overhead is
    852       needed.
    853 
    854 config FEATURE_VOLUMEID_SYSV
    855     bool "sysv filesystem"
    856     default y
    857     depends on VOLUMEID
    858     help
    859       TODO
    860 
    861 ### config FEATURE_VOLUMEID_MINIX
    862 ### bool "minix filesystem"
    863 ### default y
    864 ### depends on VOLUMEID
    865 ### help
    866 ###   TODO
    867 
    868 ### These only detect partition tables - not used (yet?)
    869 ### config FEATURE_VOLUMEID_MAC
    870 ### bool "mac filesystem"
    871 ### default y
    872 ### depends on VOLUMEID
    873 ### help
    874 ###   TODO
    875 ###
    876 ### config FEATURE_VOLUMEID_MSDOS
    877 ### bool "msdos filesystem"
    878 ### default y
    879 ### depends on VOLUMEID
    880 ### help
    881 ###   TODO
    882 
    883 config FEATURE_VOLUMEID_OCFS2
    884     bool "ocfs2 filesystem"
    885     default y
    886     depends on VOLUMEID
    887     help
    888       TODO
    889 
    890 ### config FEATURE_VOLUMEID_HIGHPOINTRAID
    891 ### bool "highpoint raid"
    892 ### default y
    893 ### depends on VOLUMEID
    894 ### help
    895 ###   TODO
    896 
    897 ### config FEATURE_VOLUMEID_ISWRAID
    898 ### bool "intel raid"
    899 ### default y
    900 ### depends on VOLUMEID
    901 ### help
    902 ###   TODO
    903 
    904 ### config FEATURE_VOLUMEID_LSIRAID
    905 ### bool "lsi raid"
    906 ### default y
    907 ### depends on VOLUMEID
    908 ### help
    909 ###   TODO
    910 
    911 ### config FEATURE_VOLUMEID_VIARAID
    912 ### bool "via raid"
    913 ### default y
    914 ### depends on VOLUMEID
    915 ### help
    916 ###   TODO
    917 
    918 ### config FEATURE_VOLUMEID_SILICONRAID
    919 ### bool "silicon raid"
    920 ### default y
    921 ### depends on VOLUMEID
    922 ### help
    923 ###   TODO
    924 
    925 ### config FEATURE_VOLUMEID_NVIDIARAID
    926 ### bool "nvidia raid"
    927 ### default y
    928 ### depends on VOLUMEID
    929 ### help
    930 ###   TODO
    931 
    932 ### config FEATURE_VOLUMEID_PROMISERAID
    933 ### bool "promise raid"
    934 ### default y
    935 ### depends on VOLUMEID
    936 ### help
    937 ###   TODO
    938 
    939 config FEATURE_VOLUMEID_LINUXRAID
    940     bool "linuxraid"
    941     default y
    942     depends on VOLUMEID
    943     help
    944       TODO
     613source util-linux/volume_id/Config.in
    945614
    946615endmenu
    947 
    948 endmenu
  • branches/3.3/mindi-busybox/util-linux/Kbuild.src

    r3232 r3621  
    4141lib-$(CONFIG_SCRIPT)            += script.o
    4242lib-$(CONFIG_SCRIPTREPLAY)      += scriptreplay.o
    43 lib-$(CONFIG_SETARCH)           += setarch.o
    4443lib-$(CONFIG_SWAPONOFF)         += swaponoff.o
    4544lib-$(CONFIG_SWITCH_ROOT)       += switch_root.o
  • branches/3.3/mindi-busybox/util-linux/acpid.c

    r3232 r3621  
    122122    const char *args[] = { "run-parts", handler, NULL };
    123123
    124     // debug info
    125     if (option_mask32 & OPT_d) {
    126         bb_error_msg("%s", event);
    127     }
     124    // log the event
     125    bb_error_msg("%s", event);
    128126
    129127    // spawn handler
     
    154152
    155153        if (buf) {
    156             if (strncmp(buf, evt_tab[i].desc, strlen(buf)) == 0) {
     154            if (is_prefixed_with(evt_tab[i].desc, buf)) {
    157155                action = evt_tab[i].desc;
    158156                break;
     
    257255         * This includes any output from children.
    258256         */
    259         xmove_fd(xopen(opt_logfile, O_WRONLY | O_CREAT | O_TRUNC), STDOUT_FILENO);
     257        xmove_fd(xopen(opt_logfile, O_WRONLY | O_CREAT | O_APPEND), STDOUT_FILENO);
    260258        xdup2(STDOUT_FILENO, STDERR_FILENO);
    261259        /* Also, acpid's messages (but not children) will go to syslog too */
  • branches/3.3/mindi-busybox/util-linux/dmesg.c

    r3232 r3621  
    1717//usage:     "\n    -n LEVEL    Set console logging level"
    1818//usage:     "\n    -s SIZE     Buffer size"
     19//usage:     "\n    -r      Print raw message buffer"
    1920
    2021#include <sys/klog.h>
     
    3031        OPT_c = 1 << 0,
    3132        OPT_s = 1 << 1,
    32         OPT_n = 1 << 2
     33        OPT_n = 1 << 2,
     34        OPT_r = 1 << 3
    3335    };
    3436
    3537    opt_complementary = "s+:n+"; /* numeric */
    36     opts = getopt32(argv, "cs:n:", &len, &level);
     38    opts = getopt32(argv, "cs:n:r", &len, &level);
    3739    if (opts & OPT_n) {
    3840        if (klogctl(8, NULL, (long) level))
     
    5658
    5759
    58     if (ENABLE_FEATURE_DMESG_PRETTY) {
     60    if (ENABLE_FEATURE_DMESG_PRETTY && !(opts & OPT_r)) {
    5961        int last = '\n';
    6062        int in = 0;
  • branches/3.3/mindi-busybox/util-linux/fbset.c

    r3232 r3621  
    165165} g_cmdoptions[] = {
    166166    /*"12345678" + NUL */
     167//TODO: convert to index_in_strings()
    167168    { "fb"      , 1, CMD_FB       },
    168169    { "db"      , 1, CMD_DB       },
     
    249250            continue;
    250251        s = p + strlen(mode);
    251         //bb_info_msg("CHECK[%s][%s][%d]", mode, p-1, *s);
     252        //bb_error_msg("CHECK[%s][%s][%d]", mode, p-1, *s);
    252253        /* exact match? */
    253254        if (((!*s || isspace(*s)) && '"' != s[-1]) /* end-of-token */
    254255         || ('"' == *s && '"' == p[-1]) /* ends with " but starts with " too! */
    255256        ) {
    256             //bb_info_msg("FOUND[%s][%s][%s][%d]", token[1], p, mode, isspace(*s));
     257            //bb_error_msg("FOUND[%s][%s][%s][%d]", token[1], p, mode, isspace(*s));
    257258            break;
    258259        }
     
    265266        int i;
    266267
    267 //bb_info_msg("???[%s][%s]", token[0], token[1]);
     268//bb_error_msg("???[%s][%s]", token[0], token[1]);
    268269        if (strcmp(token[0], "endmode") == 0) {
    269 //bb_info_msg("OK[%s]", mode);
     270//bb_error_msg("OK[%s]", mode);
    270271            return 1;
    271272        }
     
    295296                base->bits_per_pixel = base_bits_per_pixel;
    296297            }
    297 //bb_info_msg("GEO[%s]", p);
     298//bb_error_msg("GEO[%s]", p);
    298299            break;
    299300        case 1:
     
    322323                base->vsync_len = base_vsync_len;
    323324            }
    324 //bb_info_msg("TIM[%s]", p);
     325//bb_error_msg("TIM[%s]", p);
    325326            break;
    326327        case 2:
     
    328329            static const uint32_t syncs[] = {FB_VMODE_INTERLACED, FB_VMODE_DOUBLE};
    329330            ss(&base->vmode, syncs[i-2], p, "false");
    330 //bb_info_msg("VMODE[%s]", p);
     331//bb_error_msg("VMODE[%s]", p);
    331332            break;
    332333        }
     
    336337            static const uint32_t syncs[] = {FB_SYNC_VERT_HIGH_ACT, FB_SYNC_HOR_HIGH_ACT, FB_SYNC_COMP_HIGH_ACT};
    337338            ss(&base->sync, syncs[i-4], p, "low");
    338 //bb_info_msg("SYNC[%s]", p);
     339//bb_error_msg("SYNC[%s]", p);
    339340            break;
    340341        }
    341342        case 7:
    342343            ss(&base->sync, FB_SYNC_EXT, p, "false");
    343 //bb_info_msg("EXTSYNC[%s]", p);
     344//bb_error_msg("EXTSYNC[%s]", p);
    344345            break;
    345346        case 8: {
     
    350351
    351352            sscanf(p, "%d/%d,%d/%d,%d/%d,%d/%d",
    352                 &red_offset, &red_length,
    353                 &green_offset, &green_length,
    354                 &blue_offset, &blue_length,
    355                 &transp_offset, &transp_length);
     353                &red_length, &red_offset,
     354                &green_length, &green_offset,
     355                &blue_length, &blue_offset,
     356                &transp_length, &transp_offset);
    356357            base->red.offset = red_offset;
    357358            base->red.length = red_length;
     
    417418
    418419    const char *fbdev = DEFAULTFBDEV;
    419     const char *modefile = DEFAULTFBMODE;
     420    IF_FEATURE_FBSET_READMODE(const char *modefile = DEFAULTFBMODE;)
    420421    char *thisarg;
    421422    char *mode = mode; /* for compiler */
     
    445446                break;
    446447            case CMD_DB:
    447                 modefile = argv[1];
     448                IF_FEATURE_FBSET_READMODE(modefile = argv[1];)
    448449                break;
    449450            case CMD_ALL:
  • branches/3.3/mindi-busybox/util-linux/fdformat.c

    r3232 r3621  
    7373    xioctl(fd, FDGETPRM, &param);
    7474
    75     printf("%s-sided, %d tracks, %d sec/track. Total capacity %d kB\n",
     75    printf("%s-sided, %u tracks, %u sec/track. Total capacity %d kB\n",
    7676        (param.head == 2) ? "Double" : "Single",
    7777        param.track, param.sect, param.size >> 1);
     
    9494
    9595    xioctl(fd, FDFMTEND, NULL);
    96     printf("done\n");
     96    puts("Done");
    9797
    9898    /* VERIFY */
     
    127127        if (ENABLE_FEATURE_CLEAN_UP) free(data);
    128128
    129         printf("done\n");
     129        puts("Done");
    130130    }
    131131
  • branches/3.3/mindi-busybox/util-linux/fdisk.c

    r3232 r3621  
    11031103    if (!g_cylinders)
    11041104        printf(" cylinders");
    1105     printf(
    11061105#if ENABLE_FEATURE_FDISK_WRITABLE
    1107         " (settable in the extra functions menu)"
    1108 #endif
    1109         "\n");
     1106    puts(" (settable in the extra functions menu)");
     1107#else
     1108    bb_putchar('\n');
     1109#endif
    11101110    return 1;
    11111111}
     
    11511151    p = pex->part_table;
    11521152    if (!get_start_sect(p)) {
    1153         printf("Bad offset in primary extended partition\n");
     1153        puts("Bad offset in primary extended partition");
    11541154        return;
    11551155    }
     
    14511451            return 0;
    14521452        }
    1453         printf("This disk has both DOS and BSD magic.\n"
    1454              "Give the 'b' command to go to BSD mode.\n");
     1453        puts("This disk has both DOS and BSD magic.\n"
     1454             "Give the 'b' command to go to BSD mode.");
    14551455    }
    14561456#endif
     
    14621462    if (!valid_part_table_flag(MBRbuffer)) {
    14631463        if (what == OPEN_MAIN) {
    1464             printf("Device contains neither a valid DOS "
    1465                   "partition table, nor Sun, SGI, OSF or GPT "
    1466                   "disklabel\n");
     1464            puts("Device contains neither a valid DOS "
     1465                 "partition table, nor Sun, SGI, OSF or GPT "
     1466                 "disklabel");
    14671467#ifdef __sparc__
    14681468            IF_FEATURE_SUN_LABEL(create_sunlabel();)
     
    15971597        if (value >= low && value <= high)
    15981598            break;
    1599         printf("Value is out of range\n");
     1599        puts("Value is out of range");
    16001600    }
    16011601    return value;
     
    16421642        return pno;
    16431643    }
    1644     printf("No partition is defined yet!\n");
     1644    puts("No partition is defined yet!");
    16451645    return -1;
    16461646
     
    16691669        return pno;
    16701670    }
    1671     printf("All primary partitions have been defined already!\n");
     1671    puts("All primary partitions have been defined already!");
    16721672    return -1;
    16731673
     
    17041704    if (dos_compatible_flag) {
    17051705        sector_offset = g_sectors;
    1706         printf("DOS Compatibility flag is set\n");
     1706        printf("DOS Compatibility flag is %sset\n", "");
    17071707    } else {
    17081708        sector_offset = 1;
    1709         printf("DOS Compatibility flag is not set\n");
     1709        printf("DOS Compatibility flag is %sset\n", "not ");
    17101710    }
    17111711}
     
    18141814
    18151815        if (!sys && !LABEL_IS_SGI && !LABEL_IS_SUN) {
    1816             printf("Type 0 means free space to many systems\n"
    1817                    "(but not to Linux). Having partitions of\n"
    1818                    "type 0 is probably unwise.\n");
     1816            puts("Type 0 means free space to many systems\n"
     1817                "(but not to Linux). Having partitions of\n"
     1818                "type 0 is probably unwise.");
    18191819            /* break; */
    18201820        }
     
    18221822        if (!LABEL_IS_SUN && !LABEL_IS_SGI) {
    18231823            if (IS_EXTENDED(sys) != IS_EXTENDED(p->sys_ind)) {
    1824                 printf("You cannot change a partition into"
    1825                        " an extended one or vice versa\n");
     1824                puts("You cannot change a partition into"
     1825                    " an extended one or vice versa");
    18261826                break;
    18271827            }
     
    18311831#if ENABLE_FEATURE_SUN_LABEL
    18321832            if (LABEL_IS_SUN && i == 2 && sys != SUN_WHOLE_DISK)
    1833                 printf("Consider leaving partition 3 "
    1834                        "as Whole disk (5),\n"
    1835                        "as SunOS/Solaris expects it and "
    1836                        "even Linux likes it\n\n");
     1833                puts("Consider leaving partition 3 "
     1834                    "as Whole disk (5),\n"
     1835                    "as SunOS/Solaris expects it and "
     1836                    "even Linux likes it\n");
    18371837#endif
    18381838#if ENABLE_FEATURE_SGI_LABEL
     
    18431843                )
    18441844            ) {
    1845                 printf("Consider leaving partition 9 "
    1846                        "as volume header (0),\nand "
    1847                        "partition 11 as entire volume (6)"
    1848                        "as IRIX expects it\n\n");
     1845                puts("Consider leaving partition 9 "
     1846                    "as volume header (0),\nand "
     1847                    "partition 11 as entire volume (6)"
     1848                    "as IRIX expects it\n");
    18491849            }
    18501850#endif
     
    20682068
    20692069    if (!wrong_p_order(NULL)) {
    2070         printf("Ordering is already correct\n\n");
     2070        puts("Ordering is already correct\n");
    20712071        return;
    20722072    }
     
    20962096        fix_chain_of_logicals();
    20972097
    2098     printf("Done.\n");
     2098    puts("Done");
    20992099}
    21002100#endif
     
    21792179    if (LABEL_IS_DOS && wrong_p_order(NULL)) {
    21802180        /* FIXME */
    2181         printf("\nPartition table entries are not in disk order\n");
     2181        puts("\nPartition table entries are not in disk order");
    21822182    }
    21832183}
     
    21932193    printf("\nDisk %s: %u heads, %u sectors, %u cylinders\n\n",
    21942194        disk_device, g_heads, g_sectors, g_cylinders);
    2195     printf("Nr AF  Hd Sec  Cyl  Hd Sec  Cyl      Start       Size ID\n");
     2195    puts("Nr AF  Hd Sec  Cyl  Hd Sec  Cyl      Start       Size ID");
    21962196    for (i = 0; i < g_partitions; i++) {
    21972197        pe = &ptes[i];
     
    24202420    }
    24212421    if (start > limit) {
    2422         printf("No free sectors available\n");
     2422        puts("No free sectors available");
    24232423        if (n > 4)
    24242424            g_partitions--;
     
    24912491    }
    24922492    if (LABEL_IS_AIX) {
    2493         printf("Sorry - this fdisk cannot handle AIX disk labels.\n"
     2493        puts("Sorry - this fdisk cannot handle AIX disk labels.\n"
    24942494"If you want to add DOS-type partitions, create a new empty DOS partition\n"
    2495 "table first (use 'o'). This will destroy the present disk contents.\n");
     2495"table first (use 'o'). This will destroy the present disk contents.");
    24962496        return;
    24972497    }
     
    25012501
    25022502    if (!free_primary && g_partitions >= MAXIMUM_PARTS) {
    2503         printf("The maximum number of partitions has been created\n");
     2503        puts("The maximum number of partitions has been created");
    25042504        return;
    25052505    }
     
    25092509            add_logical();
    25102510        else
    2511             printf("You must delete some partition and add "
    2512                  "an extended partition first\n");
     2511            puts("You must delete some partition and add "
     2512                 "an extended partition first");
    25132513    } else {
    25142514        char c, line[80];
     
    25482548    int i;
    25492549
    2550     printf("Calling ioctl() to re-read partition table\n");
     2550    puts("Calling ioctl() to re-read partition table");
    25512551    sync();
    25522552    /* Users with slow external USB disks on a 320MHz ARM system (year 2011)
     
    25592559#if 0
    25602560    if (dos_changed)
    2561         printf(
     2561        puts(
    25622562        "\nWARNING: If you have created or modified any DOS 6.x\n"
    25632563        "partitions, please see the fdisk manual page for additional\n"
    2564         "information\n");
     2564        "information");
    25652565#endif
    25662566
     
    25902590    }
    25912591    else if (LABEL_IS_SGI) {
    2592         /* no test on change? the printf below might be mistaken */
     2592        /* no test on change? the "altered" msg below might be mistaken */
    25932593        sgi_write_table();
    25942594    }
     
    26022602    }
    26032603
    2604     printf("The partition table has been altered.\n");
     2604    puts("The partition table has been altered.");
    26052605    reread_partition_table(1);
    26062606}
     
    27452745            if (dos_compatible_flag) {
    27462746                sector_offset = g_sectors;
    2747                 printf("Warning: setting sector offset for DOS "
    2748                     "compatiblity\n");
     2747                puts("Warning: setting sector offset for DOS "
     2748                    "compatiblity");
    27492749            }
    27502750            update_units();
     
    27822782       So try to be careful. This only works since 2.1.73. */
    27832783
    2784     if (strncmp("/dev/hd", device, 7))
     2784    if (!is_prefixed_with(device, "/dev/hd"))
    27852785        return 0;
    27862786
     
    27882788    procf = fopen_for_read(buf);
    27892789    if (procf != NULL && fgets(buf, sizeof(buf), procf))
    2790         is_ide = (!strncmp(buf, "cdrom", 5) ||
    2791               !strncmp(buf, "tape", 4));
     2790        is_ide = (is_prefixed_with(buf, "cdrom") ||
     2791              is_prefixed_with(buf, "tape"));
    27922792    else
    27932793        /* Now when this proc file does not exist, skip the
     
    30253025                if (read_maybe_empty("Please enter the name of the "
    30263026                        "new boot file: ") == '\n')
    3027                     printf("Boot file unchanged\n");
     3027                    puts("Boot file unchanged");
    30283028                else
    30293029                    sgi_set_bootfile(line_ptr);
     
    31073107        case 'x':
    31083108            if (LABEL_IS_SGI) {
    3109                 printf("\n\tSorry, no experts menu for SGI "
    3110                     "partition tables available\n\n");
     3109                puts("\n\tSorry, no experts menu for SGI "
     3110                    "partition tables available\n");
    31113111            } else
    31123112                xselect();
  • branches/3.3/mindi-busybox/util-linux/fdisk_gpt.c

    r2725 r3621  
    9494    char numstr6[6];
    9595
    96     numstr6[5] = '\0';
    97 
    98     smart_ulltoa5(total_number_of_sectors, numstr6, " KMGTPEZY");
     96    smart_ulltoa5(total_number_of_sectors * sector_size, numstr6, " KMGTPEZY")[0] = '\0';
    9997    printf("Disk %s: %llu sectors, %s\n", disk_device,
    10098        (unsigned long long)total_number_of_sectors,
     
    109107        (unsigned long long)SWAP_LE64(gpt_hdr->last_usable_lba));
    110108
    111     printf("Number  Start (sector)    End (sector)  Size       Code  Name\n");
     109    puts("Number  Start (sector)    End (sector)  Size       Code  Name");
    112110    for (i = 0; i < n_parts; i++) {
    113111        gpt_partition *p = gpt_part(i);
    114112        if (p->lba_start) {
    115             smart_ulltoa5(1 + SWAP_LE64(p->lba_end) - SWAP_LE64(p->lba_start),
    116                 numstr6, " KMGTPEZY");
     113            smart_ulltoa5((1 + SWAP_LE64(p->lba_end) - SWAP_LE64(p->lba_start)) * sector_size,
     114                numstr6, " KMGTPEZY")[0] = '\0';
    117115            printf("%4u %15llu %15llu %11s   %04x  ",
    118116                i + 1,
     
    122120                0x0700 /* FIXME */);
    123121            gpt_print_wide(p->name, 18);
    124             printf("\n");
     122            bb_putchar('\n');
    125123        }
    126124    }
  • branches/3.3/mindi-busybox/util-linux/fdisk_osf.c

    r3232 r3621  
    367367                printf("Reading disklabel of %s at sector %u\n",
    368368                    partname(disk_device, t+1, 0), ss + BSD_LABELSECTOR);
    369             if (xbsd_readlabel(xbsd_part) == 0)
     369            if (xbsd_readlabel(xbsd_part) == 0) {
    370370                if (xbsd_create_disklabel() == 0)
    371371                    return;
    372372                break;
     373            }
    373374        }
    374375    }
     
    855856    d->d_magic = BSD_DISKMAGIC;
    856857
    857     if (strncmp(disk_device, "/dev/sd", 7) == 0)
     858    if (is_prefixed_with(disk_device, "/dev/sd"))
    858859        d->d_type = BSD_DTYPE_SCSI;
    859860    else
  • branches/3.3/mindi-busybox/util-linux/fdisk_sgi.c

    r2725 r3621  
    441441
    442442    write_sector(0, sgilabel);
    443     if (!strncmp((char*)sgilabel->directory[0].vol_file_name, "sgilabel", 8)) {
     443    if (is_prefixed_with((char*)sgilabel->directory[0].vol_file_name, "sgilabel")) {
    444444        /*
    445445         * keep this habit of first writing the "sgilabel".
     
    505505        if ((Index[0] != 10) && verbose)
    506506            printf("IRIX likes when Partition 11 covers the entire disk\n");
    507         if ((sgi_get_start_sector(Index[0]) != 0) && verbose)
     507        if ((sgi_get_start_sector(Index[0]) != 0) && verbose) {
    508508            printf("The entire disk partition should start "
    509509                "at block 0,\n"
    510510                "not at diskblock %u\n",
    511511                sgi_get_start_sector(Index[0]));
    512         if (SGI_DEBUG)      /* I do not understand how some disks fulfil it */
     512        }
     513        if (SGI_DEBUG) {     /* I do not understand how some disks fulfil it */
    513514            if ((sgi_get_num_sectors(Index[0]) != lastblock) && verbose)
    514515                printf("The entire disk partition is only %u diskblock large,\n"
     
    516517                    sgi_get_num_sectors(Index[0]), lastblock);
    517518            lastblock = sgi_get_num_sectors(Index[0]);
     519        }
    518520    } else {
    519521        if (verbose)
     
    670672
    671673    for (n = 8; n < g_partitions; n++) {
    672     if (!sgi_get_num_sectors(n)) {
    673         /*
    674          * 5 cylinders is an arbitrary value I like
    675          * IRIX 5.3 stored files in the volume header
    676          * (like sash, symmon, fx, ide) with ca. 3200
    677          * sectors.
    678          */
    679         if (g_heads * g_sectors * 5 < sgi_get_lastblock())
    680             sgi_set_partition(n, 0, g_heads * g_sectors * 5, SGI_VOLHDR);
    681             break;
     674        if (!sgi_get_num_sectors(n)) {
     675            /*
     676             * 5 cylinders is an arbitrary value I like
     677             * IRIX 5.3 stored files in the volume header
     678             * (like sash, symmon, fx, ide) with ca. 3200
     679             * sectors.
     680             */
     681            if (g_heads * g_sectors * 5 < sgi_get_lastblock()) {
     682                sgi_set_partition(n, 0, g_heads * g_sectors * 5, SGI_VOLHDR);
     683                break;
     684            }
    682685        }
    683686    }
  • branches/3.3/mindi-busybox/util-linux/fdisk_sun.c

    r2725 r3621  
    349349    set_all_unchanged();
    350350    set_changed(0);
     351    check_sun_label();
    351352    get_boot(CREATE_EMPTY_SUN);
    352353}
     
    498499            first = read_int(scround(start), scround(stop)+1,
    499500                     scround(stop), 0, mesg);
    500         if (display_in_cyl_units)
     501        if (display_in_cyl_units) {
    501502            first *= units_per_sector;
    502         else
     503        } else {
    503504            /* Starting sector has to be properly aligned */
    504             first = (first + g_heads * g_sectors - 1) / (g_heads * g_sectors);
     505            first = (first + g_heads * g_sectors - 1) /
     506                (g_heads * g_sectors);
     507            first *= g_heads * g_sectors;
     508        }
    505509        if (n == 2 && first != 0)
    506510            printf("\
  • branches/3.3/mindi-busybox/util-linux/findfs.c

    r3232 r3621  
    2828        bb_show_usage();
    2929
    30     if (strncmp(dev, "/dev/", 5) == 0) {
     30    if (is_prefixed_with(dev, "/dev/")) {
    3131        /* Just pass any /dev/xxx name right through.
    3232         * This might aid in some scripts being able
  • branches/3.3/mindi-busybox/util-linux/flock.c

    r3232 r3621  
    5858     * we use "+" in order to support "flock -opt FILE PROG -with-opts",
    5959     * we need to remove -c by hand.
    60      * TODO: in upstream, -c 'PROG ARGS' means "run sh -c 'PROG ARGS'"
    6160     */
    6261    if (argv[0]
     
    6766    ) {
    6867        argv++;
     68        if (argv[1])
     69            bb_error_msg_and_die("-c takes only one argument");
     70        opt |= OPT_c;
    6971    }
    7072
     
    9193    }
    9294
    93     if (argv[0])
    94         return spawn_and_wait(argv);
     95    if (argv[0]) {
     96        int rc;
     97        if (opt & OPT_c) {
     98            /* -c 'PROG ARGS' means "run sh -c 'PROG ARGS'" */
     99            argv -= 2;
     100            argv[0] = (char*)get_shell_name();
     101            argv[1] = (char*)"-c";
     102            /* argv[2] = "PROG ARGS"; */
     103            /* argv[3] = NULL; */
     104        }
     105        rc = spawn_and_wait(argv);
     106        if (rc < 0)
     107            bb_simple_perror_msg(argv[0]);
     108        return rc;
     109    }
    95110
    96111    return EXIT_SUCCESS;
  • branches/3.3/mindi-busybox/util-linux/fsck_minix.c

    r3232 r3621  
    372372    }
    373373    if (def)
    374         printf("y\n");
     374        puts("y");
    375375    else {
    376         printf("n\n");
     376        puts("n");
    377377        errors_uncorrected = 1;
    378378    }
     
    406406            cont = ask("Do you really want to continue", 0);
    407407        if (!cont) {
    408             printf("Check aborted\n");
     408            puts("Check aborted");
    409409            exit(EXIT_SUCCESS);
    410410        }
     
    471471        return;
    472472    if (nr < FIRSTZONE || nr >= ZONES) {
    473         printf("Internal error: trying to write bad block\n"
    474                "Write request ignored\n");
     473        puts("Internal error: trying to write bad block\n"
     474            "Write request ignored");
    475475        errors_uncorrected = 1;
    476476        return;
     
    660660        die("can't read inodes");
    661661    if (NORM_FIRSTZONE != FIRSTZONE) {
    662         printf("warning: firstzone!=norm_firstzone\n");
     662        puts("warning: firstzone!=norm_firstzone");
    663663        errors_uncorrected = 1;
    664664    }
     
    687687    if (!inode_count[nr]) {
    688688        if (!inode_in_use(nr)) {
    689             printf("Inode %d is marked as 'unused', but it is used "
     689            printf("Inode %u is marked as 'unused', but it is used "
    690690                    "for file '%s'\n", nr, current_name);
    691691            if (OPT_repair) {
     
    714714        links++;
    715715    if (!++inode_count[nr]) {
    716         printf("Warning: inode count too big\n");
     716        puts("Warning: inode count too big");
    717717        inode_count[nr]--;
    718718        errors_uncorrected = 1;
     
    13001300    if (changed) {
    13011301        write_tables();
    1302         printf("FILE SYSTEM HAS BEEN CHANGED\n");
     1302        puts("FILE SYSTEM HAS BEEN CHANGED");
    13031303        sync();
    13041304    } else if (OPT_repair)
  • branches/3.3/mindi-busybox/util-linux/getopt.c

    r3232 r3621  
    3636//usage:#define getopt_full_usage "\n\n"
    3737//usage:    IF_LONG_OPTS(
    38 //usage:       "    -a,--alternative        Allow long options starting with single -"
    39 //usage:     "\n    -l,--longoptions=LOPT[,...] Long options to be recognized"
    40 //usage:     "\n    -n,--name=PROGNAME      The name under which errors are reported"
    41 //usage:     "\n    -o,--options=OPTSTRING      Short options to be recognized"
    42 //usage:     "\n    -q,--quiet          Disable error reporting by getopt(3)"
     38//usage:    IF_FEATURE_GETOPT_LONG(
     39//usage:       "    -a,--alternative        Allow long options starting with single -\n"
     40//usage:       "    -l,--longoptions=LOPT[,...] Long options to recognize\n"
     41//usage:    )
     42//usage:       "    -n,--name=PROGNAME      The name under which errors are reported"
     43//usage:     "\n    -o,--options=OPTSTRING      Short options to recognize"
     44//usage:     "\n    -q,--quiet          No error messages on unrecognized options"
    4345//usage:     "\n    -Q,--quiet-output       No normal output"
    4446//usage:     "\n    -s,--shell=SHELL        Set shell quoting conventions"
    45 //usage:     "\n    -T,--test           Test for getopt(1) version"
    46 //usage:     "\n    -u,--unquoted           Don't quote the output"
     47//usage:     "\n    -T,--test           Version test (exits with 4)"
     48//usage:     "\n    -u,--unquoted           Don't quote output"
    4749//usage:    )
    4850//usage:    IF_NOT_LONG_OPTS(
    49 //usage:       "    -a      Allow long options starting with single -"
    50 //usage:     "\n    -l LOPT[,...]   Long options to be recognized"
    51 //usage:     "\n    -n PROGNAME The name under which errors are reported"
    52 //usage:     "\n    -o OPTSTRING    Short options to be recognized"
    53 //usage:     "\n    -q      Disable error reporting by getopt(3)"
     51//usage:    IF_FEATURE_GETOPT_LONG(
     52//usage:       "    -a      Allow long options starting with single -\n"
     53//usage:       "    -l LOPT[,...]   Long options to recognize\n"
     54//usage:    )
     55//usage:       "    -n PROGNAME The name under which errors are reported"
     56//usage:     "\n    -o OPTSTRING    Short options to recognize"
     57//usage:     "\n    -q      No error messages on unrecognized options"
    5458//usage:     "\n    -Q      No normal output"
    5559//usage:     "\n    -s SHELL    Set shell quoting conventions"
    56 //usage:     "\n    -T      Test for getopt(1) version"
    57 //usage:     "\n    -u      Don't quote the output"
     60//usage:     "\n    -T      Version test (exits with 4)"
     61//usage:     "\n    -u      Don't quote output"
    5862//usage:    )
     63//usage:    IF_FEATURE_GETOPT_LONG( /* example uses -l, needs FEATURE_GETOPT_LONG */
    5964//usage:     "\n"
    6065//usage:     "\nExample:"
     
    7479//usage:     "\n    esac"
    7580//usage:     "\ndone"
     81//usage:    )
    7682//usage:
    7783//usage:#define getopt_example_usage
     
    215221{
    216222    int exit_code = 0; /* We assume everything will be OK */
    217     int opt;
    218 #if ENABLE_FEATURE_GETOPT_LONG
    219     int longindex;
    220 #endif
    221     const char *charptr;
    222223
    223224    if (quiet_errors) /* No error reporting from getopt(3) */
     
    234235
    235236    while (1) {
    236         opt =
    237 #if ENABLE_FEATURE_GETOPT_LONG
    238             alternative ?
    239             getopt_long_only(argc, argv, optstr, longopts, &longindex) :
    240             getopt_long(argc, argv, optstr, longopts, &longindex);
     237#if ENABLE_FEATURE_GETOPT_LONG
     238        int longindex;
     239        int opt = alternative
     240            ? getopt_long_only(argc, argv, optstr, longopts, &longindex)
     241            : getopt_long(argc, argv, optstr, longopts, &longindex)
     242        ;
    241243#else
    242             getopt(argc, argv, optstr);
     244        int opt = getopt(argc, argv, optstr);
    243245#endif
    244246        if (opt == -1)
     
    258260                printf(" %s", normalize(optarg));
    259261            else {
     262                const char *charptr;
    260263                printf(" -%c", opt);
    261264                charptr = strchr(optstr, opt);
    262                 if (charptr != NULL && *++charptr == ':')
     265                if (charptr && *++charptr == ':')
    263266                    printf(" %s",
    264267                        normalize(optarg ? optarg : ""));
     
    268271
    269272    if (!quiet_output) {
     273        unsigned idx;
    270274        printf(" --");
    271         while (optind < argc)
    272             printf(" %s", normalize(argv[optind++]));
     275        idx = optind;
     276        while (argv[idx])
     277            printf(" %s", normalize(argv[idx++]));
    273278        bb_putchar('\n');
    274279    }
     
    374379            /* For some reason, the original getopt gave no error
    375380             * when there were no arguments. */
    376             printf(" --\n");
     381            puts(" --");
    377382            return 0;
    378383        }
  • branches/3.3/mindi-busybox/util-linux/hexdump.c

    r3232 r3621  
    6767static const char hexdump_opts[] ALIGN1 = "bcdoxCe:f:n:s:v" IF_FEATURE_HEXDUMP_REVERSE("R");
    6868
    69 static const struct suffix_mult suffixes[] = {
    70     { "b", 512 },
    71     { "k", 1024 },
    72     { "m", 1024*1024 },
    73     { "", 0 }
    74 };
    75 
    7669int hexdump_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
    7770int hexdump_main(int argc, char **argv)
     
    117110        } /* else */
    118111        if (ch == 's') { /* compat: -s accepts hex numbers too */
    119             dumper->dump_skip = xstrtoul_range_sfx(optarg, /*base:*/ 0, /*lo:*/ 0, /*hi:*/ LONG_MAX, suffixes);
     112            dumper->dump_skip = xstrtoull_range_sfx(
     113                optarg,
     114                /*base:*/ 0,
     115                /*lo:*/ 0, /*hi:*/ OFF_T_MAX,
     116                bkm_suffixes
     117            );
    120118        } /* else */
    121119        if (ch == 'v') {
  • branches/3.3/mindi-busybox/util-linux/hwclock.c

    r3232 r3621  
    7070#else
    7171    char *cp = ctime(&t);
    72     strchrnul(cp, '\n')[0] = '\0';
     72    chomp(cp);
    7373#endif
    7474
     
    9898    struct timezone tz;
    9999
    100     tz.tz_minuteswest = timezone/60 - 60*daylight;
     100    tz.tz_minuteswest = timezone/60;
     101    /* ^^^ used to also subtract 60*daylight, but it's wrong:
     102     * daylight!=0 means "this timezone has some DST
     103     * during the year", not "DST is in effect now".
     104     */
    101105    tz.tz_dsttime = 0;
    102106
     
    249253    broken = localtime(&tv.tv_sec);
    250254    tz.tz_minuteswest = timezone / 60;
    251     if (broken->tm_isdst)
     255    if (broken->tm_isdst > 0)
    252256        tz.tz_minuteswest -= 60;
    253257    tz.tz_dsttime = 0;
     
    306310    applet_long_options = hwclock_longopts;
    307311#endif
     312
     313    /* Initialize "timezone" (libc global variable) */
     314    tzset();
     315
    308316    opt_complementary = "r--wst:w--rst:s--wrt:t--rsw:l--u:u--l";
    309317    opt = getopt32(argv, "lurswtf:", &rtcname);
  • branches/3.3/mindi-busybox/util-linux/ipcrm.c

    r3232 r3621  
    120120            if (remove_ids(what, &argv[2]))
    121121                fflush_stdout_and_exit(EXIT_FAILURE);
    122             printf("resource(s) deleted\n");
     122            puts("resource(s) deleted");
    123123            return 0;
    124124        }
  • branches/3.3/mindi-busybox/util-linux/ipcs.c

    r3232 r3621  
    167167        printf("------ Shared Memory %s --------\n", "Status");
    168168        printf("segments allocated %d\n"
    169                 "pages allocated %ld\n"
    170                 "pages resident  %ld\n"
    171                 "pages swapped   %ld\n"
    172                 "Swap performance: %ld attempts\t%ld successes\n",
     169                "pages allocated %lu\n"
     170                "pages resident  %lu\n"
     171                "pages swapped   %lu\n"
     172                "Swap performance: %lu attempts\t%lu successes\n",
    173173                shm_info.used_ids,
    174174                shm_info.shm_tot,
     
    570570            bb_perror_msg_and_die("semctl");
    571571        }
    572         printf("%-10d %-10d %-10d %-10d %-10d\n", i, val, ncnt, zcnt, pid);
     572        printf("%-10u %-10d %-10d %-10d %-10d\n", i, val, ncnt, zcnt, pid);
    573573    }
    574574    bb_putchar('\n');
  • branches/3.3/mindi-busybox/util-linux/losetup.c

    r3232 r3621  
    99
    1010//usage:#define losetup_trivial_usage
    11 //usage:       "[-r] [-o OFS] LOOPDEV FILE - associate loop devices\n"
     11//usage:       "[-r] [-o OFS] {-f|LOOPDEV} FILE - associate loop devices\n"
    1212//usage:       "    losetup -d LOOPDEV - disassociate\n"
    13 //usage:       "    losetup [-f] - show"
     13//usage:       "    losetup -a - show status\n"
     14//usage:       "    losetup -f - show next free loop device"
    1415//usage:#define losetup_full_usage "\n\n"
    1516//usage:       "    -o OFS  Start OFS bytes into FILE"
    1617//usage:     "\n    -r  Read-only"
    17 //usage:     "\n    -f  Show first free loop device"
     18//usage:     "\n    -f  Show/use next free loop device"
    1819//usage:
    1920//usage:#define losetup_notes_usage
    20 //usage:       "No arguments will display all current associations.\n"
    2121//usage:       "One argument (losetup /dev/loop1) will display the current association\n"
    2222//usage:       "(if any), or disassociate it (with -d). The display shows the offset\n"
     
    2828#include "libbb.h"
    2929
     30/* 1048575 is a max possible minor number in Linux circa 2010 */
     31/* for now use something less extreme */
     32#define MAX_LOOP_NUM 1023
     33
    3034int losetup_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
    3135int losetup_main(int argc UNUSED_PARAM, char **argv)
    3236{
    3337    unsigned opt;
    34     int n;
    3538    char *opt_o;
    36     unsigned long long offset = 0;
     39    char dev[LOOP_NAMESIZE];
    3740    enum {
    3841        OPT_d = (1 << 0),
    3942        OPT_o = (1 << 1),
    4043        OPT_f = (1 << 2),
    41         OPT_r = (1 << 3), /* must be last */
     44        OPT_a = (1 << 3),
     45        OPT_r = (1 << 4), /* must be last */
    4246    };
    4347
    44     /* max 2 args, -d,-o,-f opts are mutually exclusive */
    45     opt_complementary = "?2:d--of:o--df:f--do";
    46     opt = getopt32(argv, "do:fr", &opt_o);
     48    opt_complementary = "?2:d--ofar:a--ofr";
     49    opt = getopt32(argv, "do:far", &opt_o);
    4750    argv += optind;
    4851
    49     if (opt == OPT_o)
    50         offset = xatoull(opt_o);
    51 
    52     if (opt == OPT_d) {
    53         /* -d BLOCKDEV */
    54         if (!argv[0] || argv[1])
    55             bb_show_usage();
    56         if (del_loop(argv[0]))
    57             bb_simple_perror_msg_and_die(argv[0]);
    58         return EXIT_SUCCESS;
    59     }
    60 
    61     if (argv[0]) {
     52    /* LOOPDEV */
     53    if (!opt && argv[0] && !argv[1]) {
    6254        char *s;
    6355
    64         if (opt == OPT_f) /* -f should not have arguments */
    65             bb_show_usage();
    66 
    67         if (argv[1]) {
    68             /* [-r] [-o OFS] BLOCKDEV FILE */
    69             if (set_loop(&argv[0], argv[1], offset, (opt / OPT_r)) < 0)
    70                 bb_simple_perror_msg_and_die(argv[0]);
    71             return EXIT_SUCCESS;
    72         }
    73         /* [-r] [-o OFS] BLOCKDEV */
    7456        s = query_loop(argv[0]);
    7557        if (!s)
     
    8163    }
    8264
    83     /* [-r] [-o OFS|-f] with no params */
    84     n = 0;
    85     while (1) {
     65    /* -d LOOPDEV */
     66    if (opt == OPT_d && argv[0]) {
     67        if (del_loop(argv[0]))
     68            bb_simple_perror_msg_and_die(argv[0]);
     69        return EXIT_SUCCESS;
     70    }
     71
     72    /* -a */
     73    if (opt == OPT_a) {
     74        int n;
     75        for (n = 0; n < MAX_LOOP_NUM; n++) {
     76            char *s;
     77
     78            sprintf(dev, LOOP_FORMAT, n);
     79            s = query_loop(dev);
     80            if (s) {
     81                printf("%s: %s\n", dev, s);
     82                free(s);
     83            }
     84        }
     85        return EXIT_SUCCESS;
     86    }
     87
     88    /* contains -f */
     89    if (opt & OPT_f) {
    8690        char *s;
    87         char dev[LOOP_NAMESIZE];
     91        int n = 0;
    8892
    89         sprintf(dev, LOOP_FORMAT, n);
    90         s = query_loop(dev);
    91         n++;
    92         if (!s) {
    93             if (n > 9 && errno && errno != ENXIO)
    94                 return EXIT_SUCCESS;
    95             if (opt == OPT_f) {
    96                 puts(dev);
    97                 return EXIT_SUCCESS;
    98             }
    99         } else {
    100             if (opt != OPT_f)
    101                 printf("%s: %s\n", dev, s);
    102             if (ENABLE_FEATURE_CLEAN_UP)
    103                 free(s);
     93        do {
     94            if (n > MAX_LOOP_NUM)
     95                bb_error_msg_and_die("no free loop devices");
     96            sprintf(dev, LOOP_FORMAT, n++);
     97            s = query_loop(dev);
     98            free(s);
     99        } while (s);
     100        /* now: dev is next free "/dev/loopN" */
     101        if ((opt == OPT_f) && !argv[0]) {
     102            puts(dev);
     103            return EXIT_SUCCESS;
    104104        }
    105105    }
    106     return EXIT_SUCCESS;
     106
     107    /* [-r] [-o OFS] {-f|LOOPDEV} FILE */
     108    if (argv[0] && ((opt & OPT_f) || argv[1])) {
     109        unsigned long long offset = 0;
     110        char *d = dev;
     111
     112        if (opt & OPT_o)
     113            offset = xatoull(opt_o);
     114        if (!(opt & OPT_f))
     115            d = *argv++;
     116
     117        if (argv[0]) {
     118            if (set_loop(&d, argv[0], offset, (opt & OPT_r)) < 0)
     119                bb_simple_perror_msg_and_die(argv[0]);
     120            return EXIT_SUCCESS;
     121        }
     122    }
     123
     124    bb_show_usage(); /* does not return */
     125    /*return EXIT_FAILURE;*/
    107126}
  • branches/3.3/mindi-busybox/util-linux/mdev.c

    r3232 r3621  
    9898
    9999#include "libbb.h"
     100#include "common_bufsiz.h"
    100101#include "xregex.h"
    101102
     
    284285#endif
    285286    struct rule cur_rule;
    286     char timestr[sizeof("60.123456")];
     287    char timestr[sizeof("HH:MM:SS.123456")];
    287288} FIX_ALIASING;
    288 #define G (*(struct globals*)&bb_common_bufsiz1)
     289#define G (*(struct globals*)bb_common_bufsiz1)
    289290#define INIT_G() do { \
     291    setup_common_bufsiz(); \
    290292    IF_NOT_FEATURE_MDEV_CONF(G.cur_rule.maj = -1;) \
    291293    IF_NOT_FEATURE_MDEV_CONF(G.cur_rule.mode = 0660;) \
     
    324326    }
    325327    make_default_cur_rule();
    326 }
    327 
    328 /* In later versions, endofname is in libbb */
    329 #define endofname mdev_endofname
    330 static
    331 const char* FAST_FUNC
    332 endofname(const char *name)
    333 {
    334 #define is_name(c)      ((c) == '_' || isalpha((unsigned char)(c)))
    335 #define is_in_name(c)   ((c) == '_' || isalnum((unsigned char)(c)))
    336     if (!is_name(*name))
    337         return name;
    338     while (*++name) {
    339         if (!is_in_name(*name))
    340             break;
    341     }
    342     return name;
    343328}
    344329
     
    418403
    419404        /* 2nd field: uid:gid - device ownership */
    420         if (get_uidgid(&G.cur_rule.ugid, tokens[1], /*allow_numeric:*/ 1) == 0) {
     405        if (get_uidgid(&G.cur_rule.ugid, tokens[1]) == 0) {
    421406            bb_error_msg("unknown user/group '%s' on line %d", tokens[1], G.parser->lineno);
    422407            goto next_rule;
     
    424409
    425410        /* 3rd field: mode - device permissions */
    426         bb_parse_mode(tokens[2], &G.cur_rule.mode);
     411        G.cur_rule.mode = bb_parse_mode(tokens[2], G.cur_rule.mode);
    427412
    428413        /* 4th field (opt): ">|=alias" or "!" to not create the node */
     
    489474        parse_next_rule();
    490475        if (G.rule_vec) { /* mdev -s */
    491             rule = memcpy(xmalloc(sizeof(G.cur_rule)), &G.cur_rule, sizeof(G.cur_rule));
     476            rule = xmemdup(&G.cur_rule, sizeof(G.cur_rule));
    492477            G.rule_vec = xrealloc_vector(G.rule_vec, 4, G.rule_idx);
    493478            G.rule_vec[G.rule_idx++] = rule;
     
    628613     */
    629614    type = S_IFCHR;
    630     if (strstr(path, "/block/") || (G.subsystem && strncmp(G.subsystem, "block", 5) == 0))
     615    if (strstr(path, "/block/") || (G.subsystem && is_prefixed_with(G.subsystem, "block")))
    631616        type = S_IFBLK;
    632617
     
    941926    struct timeval tv;
    942927    gettimeofday(&tv, NULL);
    943     sprintf(G.timestr, "%u.%06u", (unsigned)tv.tv_sec % 60, (unsigned)tv.tv_usec);
     928    sprintf(
     929        strftime_HHMMSS(G.timestr, sizeof(G.timestr), &tv.tv_sec),
     930        ".%06u",
     931        (unsigned)tv.tv_usec
     932    );
    944933    return G.timestr;
    945934}
     
    961950 */
    962951static int
    963 wait_for_seqfile(const char *seq)
     952wait_for_seqfile(unsigned expected_seq)
    964953{
    965954    /* We time out after 2 sec */
     
    976965    for (;;) {
    977966        int seqlen;
    978         char seqbuf[sizeof(int)*3 + 2];
     967        char seqbuf[sizeof(long)*3 + 2];
     968        unsigned seqbufnum;
    979969
    980970        if (seq_fd < 0) {
     
    982972            if (seq_fd < 0)
    983973                break;
     974            close_on_exec_on(seq_fd);
    984975        }
    985976        seqlen = pread(seq_fd, seqbuf, sizeof(seqbuf) - 1, 0);
     
    990981        }
    991982        seqbuf[seqlen] = '\0';
    992         if (seqbuf[0] == '\n') {
     983        if (seqbuf[0] == '\n' || seqbuf[0] == '\0') {
    993984            /* seed file: write out seq ASAP */
    994             xwrite_str(seq_fd, seq);
     985            xwrite_str(seq_fd, utoa(expected_seq));
    995986            xlseek(seq_fd, 0, SEEK_SET);
    996987            dbg2("first seq written");
    997988            break;
    998989        }
    999         if (strcmp(seq, seqbuf) == 0) {
     990        seqbufnum = atoll(seqbuf);
     991        if (seqbufnum == expected_seq) {
    1000992            /* correct idx */
    1001993            break;
    1002994        }
     995        if (seqbufnum > expected_seq) {
     996            /* a later mdev runs already (this was seen by users to happen) */
     997            /* do not overwrite seqfile on exit */
     998            close(seq_fd);
     999            seq_fd = -1;
     1000            break;
     1001        }
    10031002        if (do_once) {
    1004             dbg2("%s waiting for '%s'", curtime(), seqbuf);
     1003            dbg2("%s mdev.seq='%s', need '%u'", curtime(), seqbuf, expected_seq);
    10051004            do_once = 0;
    10061005        }
     
    10101009        }
    10111010        if (--timeout == 0) {
    1012             dbg1("%s waiting for '%s'", "timed out", seqbuf);
     1011            dbg1("%s mdev.seq='%s'", "timed out", seqbuf);
    10131012            break;
    10141013        }
     
    10931092        char *env_devpath;
    10941093        unsigned my_pid;
     1094        unsigned seqnum = seqnum; /* for compiler */
    10951095        int seq_fd;
    10961096        smalluint op;
     
    11011101         * DEVPATH is like "/block/sda" or "/class/input/mice"
    11021102         */
     1103        env_devname = getenv("DEVNAME"); /* can be NULL */
     1104        G.subsystem = getenv("SUBSYSTEM");
    11031105        action = getenv("ACTION");
    1104         op = index_in_strings(keywords, action);
    1105         env_devname = getenv("DEVNAME"); /* can be NULL */
    11061106        env_devpath = getenv("DEVPATH");
    1107         G.subsystem = getenv("SUBSYSTEM");
    11081107        if (!action || !env_devpath /*|| !G.subsystem*/)
    11091108            bb_show_usage();
    11101109        fw = getenv("FIRMWARE");
    11111110        seq = getenv("SEQNUM");
     1111        op = index_in_strings(keywords, action);
    11121112
    11131113        my_pid = getpid();
    11141114        open_mdev_log(seq, my_pid);
    11151115
    1116         seq_fd = seq ? wait_for_seqfile(seq) : -1;
     1116        seq_fd = -1;
     1117        if (seq) {
     1118            seqnum = atoll(seq);
     1119            seq_fd = wait_for_seqfile(seqnum);
     1120        }
    11171121
    11181122        dbg1("%s "
     
    11421146        dbg1("%s exiting", curtime());
    11431147        if (seq_fd >= 0) {
    1144             xwrite_str(seq_fd, utoa(xatou(seq) + 1));
     1148            xwrite_str(seq_fd, utoa(seqnum + 1));
    11451149            signal_mdevs(my_pid);
    11461150        }
  • branches/3.3/mindi-busybox/util-linux/minix.h

    r2725 r3621  
    6262    MINIX_BAD_INO           = 2,
    6363
     64#undef  MINIX1_SUPER_MAGIC
    6465    MINIX1_SUPER_MAGIC      = 0x137F,       /* original minix fs */
     66#undef  MINIX1_SUPER_MAGIC2
    6567    MINIX1_SUPER_MAGIC2     = 0x138F,       /* minix fs, 30 char names */
     68/* bionic has this define */
     69#undef  MINIX2_SUPER_MAGIC
    6670    MINIX2_SUPER_MAGIC      = 0x2468,       /* minix V2 fs */
     71#undef  MINIX2_SUPER_MAGIC2
    6772    MINIX2_SUPER_MAGIC2     = 0x2478,       /* minix V2 fs, 30 char names */
    6873    MINIX_VALID_FS          = 0x0001,       /* clean fs */
  • branches/3.3/mindi-busybox/util-linux/mkfs_ext2.c

    r3232 r3621  
    117117    uint32_t i;
    118118
    119 //bb_info_msg("ALLOC: [%u][%u][%u]: [%u-%u]:=[%x],[%x]", blocksize, start, end, start/8, blocksize - end/8 - 1, (1 << (start & 7)) - 1, (uint8_t)(0xFF00 >> (end & 7)));
     119//bb_error_msg("ALLOC: [%u][%u][%u]: [%u-%u]:=[%x],[%x]", blocksize, start, end, start/8, blocksize - end/8 - 1, (1 << (start & 7)) - 1, (uint8_t)(0xFF00 >> (end & 7)));
    120120    memset(bitmap, 0, blocksize);
    121121    i = start / 8;
     
    152152static void PUT(uint64_t off, void *buf, uint32_t size)
    153153{
    154 //  bb_info_msg("PUT[%llu]:[%u]", off, size);
     154    //bb_error_msg("PUT[%llu]:[%u]", off, size);
    155155    xlseek(fd, off, SEEK_SET);
    156156    xwrite(fd, buf, size);
     
    413413        // transition (at 16M).
    414414        if (remainder && (remainder < overhead + 50)) {
    415 //bb_info_msg("CHOP[%u]", remainder);
     415//bb_error_msg("CHOP[%u]", remainder);
    416416            nblocks -= remainder;
    417417            goto retry;
     
    569569
    570570        // mark preallocated blocks as allocated
    571 //bb_info_msg("ALLOC: [%u][%u][%u]", blocksize, overhead, blocks_per_group - (free_blocks + overhead));
     571//bb_error_msg("ALLOC: [%u][%u][%u]", blocksize, overhead, blocks_per_group - (free_blocks + overhead));
    572572        allocate(buf, blocksize,
    573573            // reserve "overhead" blocks
     
    648648    for (i = 0; i < lost_and_found_blocks; ++i)
    649649        STORE_LE(inode->i_block[i], i + n); // use next block
    650 //bb_info_msg("LAST BLOCK USED[%u]", i + n);
     650//bb_error_msg("LAST BLOCK USED[%u]", i + n);
    651651    PUT(((uint64_t)FETCH_LE32(gd[0].bg_inode_table) * blocksize) + (EXT2_GOOD_OLD_FIRST_INO-1) * inodesize,
    652652                buf, inodesize);
  • branches/3.3/mindi-busybox/util-linux/mkfs_minix.c

    r3232 r3621  
    196196# define BLKGETSIZE     _IO(0x12,96)    /* return device size */
    197197#endif
    198 
    199 
    200 static long valid_offset(int fd, int offset)
    201 {
    202     char ch;
    203 
    204     if (lseek(fd, offset, SEEK_SET) < 0)
    205         return 0;
    206     if (read(fd, &ch, 1) < 1)
    207         return 0;
    208     return 1;
    209 }
    210 
    211 static int count_blocks(int fd)
    212 {
    213     int high, low;
    214 
    215     low = 0;
    216     for (high = 1; valid_offset(fd, high); high *= 2)
    217         low = high;
    218 
    219     while (low < high - 1) {
    220         const int mid = (low + high) / 2;
    221 
    222         if (valid_offset(fd, mid))
    223             low = mid;
    224         else
    225             high = mid;
    226     }
    227     valid_offset(fd, 0);
    228     return (low + 1);
    229 }
    230 
    231 static int get_size(const char *file)
    232 {
    233     int fd;
    234     long size;
    235 
    236     fd = xopen(file, O_RDWR);
    237     if (ioctl(fd, BLKGETSIZE, &size) >= 0) {
    238         close(fd);
    239         return (size * 512);
    240     }
    241 
    242     size = count_blocks(fd);
    243     close(fd);
    244     return size;
    245 }
    246198
    247199static void write_tables(void)
     
    554506    listfile = xfopen_for_read(filename);
    555507    while (!feof(listfile)) {
    556         fscanf(listfile, "%ld\n", &blockno);
     508        fscanf(listfile, "%lu\n", &blockno);
    557509        mark_zone(blockno);
    558510        G.badblocks++;
     
    625577        unmark_inode(i);
    626578    G.inode_buffer = xzalloc(INODE_BUFFER_SIZE);
    627     printf("%ld inodes\n", (long)SB_INODES);
    628     printf("%ld blocks\n", (long)SB_ZONES);
    629     printf("Firstdatazone=%ld (%ld)\n", (long)SB_FIRSTZONE, (long)norm_firstzone);
    630     printf("Zonesize=%d\n", BLOCK_SIZE << SB_ZONE_SIZE);
    631     printf("Maxsize=%ld\n", (long)SB_MAXSIZE);
     579    printf("%lu inodes\n", (unsigned long)SB_INODES);
     580    printf("%lu blocks\n", (unsigned long)SB_ZONES);
     581    printf("Firstdatazone=%lu (%lu)\n", (unsigned long)SB_FIRSTZONE, (unsigned long)norm_firstzone);
     582    printf("Zonesize=%u\n", BLOCK_SIZE << SB_ZONE_SIZE);
     583    printf("Maxsize=%lu\n", (unsigned long)SB_MAXSIZE);
    632584}
    633585
     
    637589    unsigned opt;
    638590    char *tmp;
    639     struct stat statbuf;
    640591    char *str_i;
    641592    char *listfile = NULL;
     
    674625    }
    675626
    676     G.device_name = *argv++;
     627    G.device_name = argv[0];
    677628    if (!G.device_name)
    678629        bb_show_usage();
    679     if (*argv)
    680         G.total_blocks = xatou32(*argv);
    681     else
    682         G.total_blocks = get_size(G.device_name) / 1024;
     630
     631    /* Check if it is mounted */
     632    if (find_mount_point(G.device_name, 0))
     633        bb_error_msg_and_die("can't format mounted filesystem");
     634
     635    xmove_fd(xopen(G.device_name, O_RDWR), dev_fd);
     636
     637    G.total_blocks = get_volume_size_in_bytes(dev_fd, argv[1], 1024, /*extend:*/ 1) / 1024;
    683638
    684639    if (G.total_blocks < 10)
     
    691646    } else if (G.total_blocks > 65535)
    692647        G.total_blocks = 65535;
    693 
    694     /* Check if it is mounted */
    695     if (find_mount_point(G.device_name, 0))
    696         bb_error_msg_and_die("can't format mounted filesystem");
    697 
    698     xmove_fd(xopen(G.device_name, O_RDWR), dev_fd);
     648#if 0
     649    struct stat statbuf;
    699650    xfstat(dev_fd, &statbuf, G.device_name);
     651/* why? */
    700652    if (!S_ISBLK(statbuf.st_mode))
    701653        opt &= ~1; // clear -c (check)
    702 
     654#if 0
    703655/* I don't know why someone has special code to prevent mkfs.minix
    704656 * on IDE devices. Why IDE but not SCSI, etc?... */
    705 #if 0
    706657    else if (statbuf.st_rdev == 0x0300 || statbuf.st_rdev == 0x0340)
    707658        /* what is this? */
     
    709660            "to make filesystem on '%s'", G.device_name);
    710661#endif
    711 
     662#endif
    712663    tmp = G.root_block;
    713664    *(short *) tmp = 1;
  • branches/3.3/mindi-busybox/util-linux/mkfs_reiser.c

    r3232 r3621  
    6767    char s_magic[10];               /* 52 "ReIsErFs" or "ReIsEr2Fs" or "ReIsEr3Fs" */
    6868    uint16_t sb_fs_state;           /* 62 it is set to used by fsck to mark which phase of rebuilding is done (used for fsck debugging) */
    69     uint32_t sb_hash_function_code; /* 64 code of fuction which was/is/will be used to sort names in a directory. See codes in above */
     69    uint32_t sb_hash_function_code; /* 64 code of function which was/is/will be used to sort names in a directory. See codes in above */
    7070    uint16_t sb_tree_height;        /* 68 height of filesytem tree. Tree consisting of only one root block has 2 here */
    7171    uint16_t sb_bmap_nr;            /* 70 amount of bitmap blocks needed to address each block of file system */
     
    225225    STORE_LE(jp->jp_journal_1st_block, REISERFS_DISK_OFFSET_IN_BYTES / blocksize + 1/*sb*/ + 1/*bmp#0*/);
    226226    timestamp = time(NULL);
    227     srandom(timestamp);
    228     STORE_LE(jp->jp_journal_magic, random());
     227    srand(timestamp);
     228    STORE_LE(jp->jp_journal_magic, rand());
    229229    STORE_LE(jp->jp_journal_size, journal_blocks);
    230230    STORE_LE(jp->jp_journal_trans_max, JOURNAL_TRANS_MAX);
  • branches/3.3/mindi-busybox/util-linux/mkfs_vfat.c

    r3232 r3621  
    579579        start_data_block = (start_data_sector + SECTORS_PER_BLOCK - 1) / SECTORS_PER_BLOCK;
    580580
    581         bb_info_msg("searching for bad blocks ");
     581        bb_error_msg("searching for bad blocks");
    582582        currently_testing = 0;
    583583        try = TEST_BUFFER_BLOCKS;
     
    617617        free(blkbuf);
    618618        if (badblocks)
    619             bb_info_msg("%d bad block(s)", badblocks);
     619            bb_error_msg("%d bad block(s)", badblocks);
    620620    }
    621621#endif
  • branches/3.3/mindi-busybox/util-linux/mkswap.c

    r3232 r3621  
    1414
    1515#include "libbb.h"
     16#include "common_bufsiz.h"
    1617
    1718#if ENABLE_SELINUX
     
    7677#define NWORDS 129
    7778#define hdr ((struct swap_header_v1*)bb_common_bufsiz1)
     79#define INIT_G() do { setup_common_bufsiz(); } while (0)
    7880
    7981struct BUG_sizes {
     
    9294    off_t len;
    9395    const char *label = "";
     96
     97    INIT_G();
    9498
    9599    opt_complementary = "-1"; /* at least one param */
  • branches/3.3/mindi-busybox/util-linux/more.c

    r3232 r3621  
    2424
    2525#include "libbb.h"
     26#include "common_bufsiz.h"
    2627
    2728/* Support for FEATURE_USE_TERMIOS */
     
    3334} FIX_ALIASING;
    3435#define G (*(struct globals*)bb_common_bufsiz1)
    35 #define INIT_G() ((void)0)
    3636#define initial_settings (G.initial_settings)
    3737#define new_settings     (G.new_settings    )
    3838#define cin_fileno       (G.cin_fileno      )
     39#define INIT_G() do { setup_common_bufsiz(); } while (0)
    3940
    4041#define setTermSettings(fd, argp) \
  • branches/3.3/mindi-busybox/util-linux/mount.c

    r3232 r3621  
    1818//
    1919
     20//config:config MOUNT
     21//config:   bool "mount"
     22//config:   default y
     23//config:   select PLATFORM_LINUX
     24//config:   help
     25//config:     All files and filesystems in Unix are arranged into one big directory
     26//config:     tree. The 'mount' utility is used to graft a filesystem onto a
     27//config:     particular part of the tree. A filesystem can either live on a block
     28//config:     device, or it can be accessible over the network, as is the case with
     29//config:     NFS filesystems. Most people using BusyBox will also want to enable
     30//config:     the 'mount' utility.
     31//config:
     32//config:config FEATURE_MOUNT_FAKE
     33//config:   bool "Support option -f"
     34//config:   default y
     35//config:   depends on MOUNT
     36//config:   help
     37//config:     Enable support for faking a file system mount.
     38//config:
     39//config:config FEATURE_MOUNT_VERBOSE
     40//config:   bool "Support option -v"
     41//config:   default y
     42//config:   depends on MOUNT
     43//config:   help
     44//config:     Enable multi-level -v[vv...] verbose messages. Useful if you
     45//config:     debug mount problems and want to see what is exactly passed
     46//config:     to the kernel.
     47//config:
     48//config:config FEATURE_MOUNT_HELPERS
     49//config:   bool "Support mount helpers"
     50//config:   default n
     51//config:   depends on MOUNT
     52//config:   help
     53//config:     Enable mounting of virtual file systems via external helpers.
     54//config:     E.g. "mount obexfs#-b00.11.22.33.44.55 /mnt" will in effect call
     55//config:     "obexfs -b00.11.22.33.44.55 /mnt"
     56//config:     Also "mount -t sometype [-o opts] fs /mnt" will try
     57//config:     "sometype [-o opts] fs /mnt" if simple mount syscall fails.
     58//config:     The idea is to use such virtual filesystems in /etc/fstab.
     59//config:
     60//config:config FEATURE_MOUNT_LABEL
     61//config:   bool "Support specifying devices by label or UUID"
     62//config:   default y
     63//config:   depends on MOUNT
     64//config:   select VOLUMEID
     65//config:   help
     66//config:     This allows for specifying a device by label or uuid, rather than by
     67//config:     name. This feature utilizes the same functionality as blkid/findfs.
     68//config:     This also enables label or uuid support for swapon.
     69//config:
     70//config:config FEATURE_MOUNT_NFS
     71//config:   bool "Support mounting NFS file systems on Linux < 2.6.23"
     72//config:   default n
     73//config:   depends on MOUNT
     74//config:   select FEATURE_HAVE_RPC
     75//config:   select FEATURE_SYSLOG
     76//config:   help
     77//config:     Enable mounting of NFS file systems on Linux kernels prior
     78//config:     to version 2.6.23. Note that in this case mounting of NFS
     79//config:     over IPv6 will not be possible.
     80//config:
     81//config:     Note that this option links in RPC support from libc,
     82//config:     which is rather large (~10 kbytes on uclibc).
     83//config:
     84//config:config FEATURE_MOUNT_CIFS
     85//config:   bool "Support mounting CIFS/SMB file systems"
     86//config:   default y
     87//config:   depends on MOUNT
     88//config:   help
     89//config:     Enable support for samba mounts.
     90//config:
     91//config:config FEATURE_MOUNT_FLAGS
     92//config:   depends on MOUNT
     93//config:   bool "Support lots of -o flags in mount"
     94//config:   default y
     95//config:   help
     96//config:     Without this, mount only supports ro/rw/remount. With this, it
     97//config:     supports nosuid, suid, dev, nodev, exec, noexec, sync, async, atime,
     98//config:     noatime, diratime, nodiratime, loud, bind, move, shared, slave,
     99//config:     private, unbindable, rshared, rslave, rprivate, and runbindable.
     100//config:
     101//config:config FEATURE_MOUNT_FSTAB
     102//config:   depends on MOUNT
     103//config:   bool "Support /etc/fstab and -a"
     104//config:   default y
     105//config:   help
     106//config:     Support mount all and looking for files in /etc/fstab.
     107//config:
     108//config:config FEATURE_MOUNT_OTHERTAB
     109//config:   depends on FEATURE_MOUNT_FSTAB
     110//config:   bool "Support -T <alt_fstab>"
     111//config:   default y
     112//config:   help
     113//config:     Support mount -T (specifying an alternate fstab)
     114
    20115//usage:#define mount_trivial_usage
    21 //usage:       "[OPTIONS] [-o OPTS] DEVICE NODE"
     116//usage:       "[OPTIONS] [-o OPT] DEVICE NODE"
    22117//usage:#define mount_full_usage "\n\n"
    23118//usage:       "Mount a filesystem. Filesystem autodetection requires /proc.\n"
     
    42137////usage:   "\n    -s      Sloppy (ignored)"
    43138//usage:     "\n    -r      Read-only mount"
    44 //usage:     "\n    -w      Read-write mount (default)"
     139////usage:     "\n  -w      Read-write mount (default)"
    45140//usage:     "\n    -t FSTYPE[,...] Filesystem type(s)"
     141//usage:    IF_FEATURE_MOUNT_OTHERTAB(
     142//usage:     "\n    -T FILE     Read FILE instead of /etc/fstab"
     143//usage:    )
    46144//usage:     "\n    -O OPT      Mount only filesystems with option OPT (-a only)"
    47145//usage:     "\n-o OPT:"
     
    65163//usage:    )
    66164//usage:     "\n    remount     Remount a mounted filesystem, changing flags"
    67 //usage:     "\n    ro/rw       Same as -r/-w"
     165//usage:     "\n    ro      Same as -r"
    68166//usage:     "\n"
    69167//usage:     "\nThere are filesystem-specific -o flags."
     
    126224
    127225#include "libbb.h"
     226#include "common_bufsiz.h"
    128227#if ENABLE_FEATURE_MOUNT_LABEL
    129228# include "volume_id.h"
     
    162261// Not real flags, but we want to be able to check for this.
    163262enum {
    164     MOUNT_USERS  = (1 << 28) * ENABLE_DESKTOP,
     263    MOUNT_USERS  = (1 << 27) * ENABLE_DESKTOP,
     264    MOUNT_NOFAIL = (1 << 28) * ENABLE_DESKTOP,
    165265    MOUNT_NOAUTO = (1 << 29),
    166266    MOUNT_SWAP   = (1 << 30),
     267    MOUNT_FAKEFLAGS = MOUNT_USERS | MOUNT_NOFAIL | MOUNT_NOAUTO | MOUNT_SWAP
    167268};
    168269
    169270
    170 #define OPTION_STR "o:t:rwanfvsiO:"
     271#define OPTION_STR "o:t:rwanfvsiO:" IF_FEATURE_MOUNT_OTHERTAB("T:")
    171272enum {
    172273    OPT_o = (1 << 0),
     
    181282    OPT_i = (1 << 9),
    182283    OPT_O = (1 << 10),
     284    OPT_T = (1 << 11),
    183285};
    184286
     
    228330        IF_DESKTOP(/* "user"  */ MOUNT_USERS,)
    229331        IF_DESKTOP(/* "users" */ MOUNT_USERS,)
     332        IF_DESKTOP(/* "nofail" */ MOUNT_NOFAIL,)
    230333        /* "_netdev" */ 0,
    231334        IF_DESKTOP(/* "comment=" */ 0,) /* systemd uses this in fstab */
     
    275378};
    276379
    277 static const char mount_option_str[] =
     380static const char mount_option_str[] ALIGN1 =
    278381    IF_FEATURE_MOUNT_LOOP(
    279382        "loop\0"
     
    287390        IF_DESKTOP("user\0")
    288391        IF_DESKTOP("users\0")
     392        IF_DESKTOP("nofail\0")
    289393        "_netdev\0"
    290394        IF_DESKTOP("comment=\0") /* systemd uses this in fstab */
     
    345449} FIX_ALIASING;
    346450enum { GETMNTENT_BUFSIZE = COMMON_BUFSIZE - offsetof(struct globals, getmntent_buf) };
    347 #define G (*(struct globals*)&bb_common_bufsiz1)
     451#define G (*(struct globals*)bb_common_bufsiz1)
    348452#define nfs_mount_version (G.nfs_mount_version)
    349453#if ENABLE_FEATURE_MOUNT_VERBOSE
     
    354458#define fslist            (G.fslist           )
    355459#define getmntent_buf     (G.getmntent_buf    )
    356 #define INIT_G() do { } while (0)
     460#define INIT_G() do { setup_common_bufsiz(); } while (0)
    357461
    358462#if ENABLE_FEATURE_MTAB_SUPPORT
     
    543647
    544648        while ((buf = xmalloc_fgetline(f)) != NULL) {
    545             if (strncmp(buf, "nodev", 5) == 0 && isspace(buf[5]))
     649            if (is_prefixed_with(buf, "nodev") && isspace(buf[5]))
    546650                goto next;
    547651            fs = skip_whitespace(buf);
     
    573677{
    574678    int rc = 0;
     679
     680    vfsflags &= ~(unsigned long)MOUNT_FAKEFLAGS;
    575681
    576682    if (FAKE_IT) {
     
    8981004#endif
    8991005/* Convert each NFSERR_BLAH into EBLAH */
    900 static const uint8_t nfs_err_stat[] = {
     1006static const uint8_t nfs_err_stat[] ALIGN1 = {
    9011007     1,  2,  5,  6, 13, 17,
    9021008    19, 20, 21, 22, 27, 28,
     
    9111017typedef uint16_t nfs_err_type;
    9121018#endif
    913 static const nfs_err_type nfs_err_errnum[] = {
     1019static const nfs_err_type nfs_err_errnum[] ALIGN2 = {
    9141020    EPERM , ENOENT      , EIO      , ENXIO , EACCES, EEXIST,
    9151021    ENODEV, ENOTDIR     , EISDIR   , EINVAL, EFBIG , ENOSPC,
     
    12661372                continue;
    12671373            case 18: // "proto"
    1268                 if (!strncmp(opteq, "tcp", 3))
     1374                if (is_prefixed_with(opteq, "tcp"))
    12691375                    tcp = 1;
    1270                 else if (!strncmp(opteq, "udp", 3))
     1376                else if (is_prefixed_with(opteq, "udp"))
    12711377                    tcp = 0;
    12721378                else
     
    13611467                "acl\0";
    13621468            int val = 1;
    1363             if (!strncmp(opt, "no", 2)) {
     1469            if (is_prefixed_with(opt, "no")) {
    13641470                val = 0;
    13651471                opt += 2;
     
    18571963                share + len + 1  /* "dir1/dir2" */
    18581964            );
    1859             parse_mount_options(unc, &filteropts);
    1860             if (ENABLE_FEATURE_CLEAN_UP) free(unc);
     1965            parse_mount_options(unc, &filteropts);
     1966            if (ENABLE_FEATURE_CLEAN_UP) free(unc);
    18611967        }
    18621968
     
    18811987
    18821988    // Might this be an NFS filesystem?
    1883     if ((!mp->mnt_type || strncmp(mp->mnt_type, "nfs", 3) == 0)
     1989    if ((!mp->mnt_type || is_prefixed_with(mp->mnt_type, "nfs"))
    18841990     && strchr(mp->mnt_fsname, ':') != NULL
    18851991    ) {
     
    19532059        if (ENABLE_FEATURE_CLEAN_UP) {
    19542060            free(loopFile);
    1955             free(mp->mnt_fsname);
     2061            /* No, "rc != 0" needs it: free(mp->mnt_fsname); */
    19562062        }
    19572063    }
     
    19622068
    19632069    if (errno == EBUSY && ignore_busy)
     2070        return 0;
     2071    if (errno == ENOENT && (vfsflags & MOUNT_NOFAIL))
    19642072        return 0;
    19652073    if (rc != 0)
     
    20352143    char *storage_path;
    20362144    llist_t *lst_o = NULL;
    2037     const char *fstabname;
     2145    const char *fstabname = "/etc/fstab";
    20382146    FILE *fstab;
    20392147    int i, j;
     
    20622170    opt_complementary = "?2o::" IF_FEATURE_MOUNT_VERBOSE("vv");
    20632171    opt = getopt32(argv, OPTION_STR, &lst_o, &fstype, &O_optmatch
     2172            IF_FEATURE_MOUNT_OTHERTAB(, &fstabname)
    20642173            IF_FEATURE_MOUNT_VERBOSE(, &verbose));
    20652174    while (lst_o) append_mount_options(&cmdopts, llist_pop(&lst_o)); // -o
     
    21292238    }
    21302239
     2240    // A malicious user could overmount /usr without this.
     2241    if (ENABLE_FEATURE_MOUNT_OTHERTAB && nonroot)
     2242        fstabname = "/etc/fstab";
    21312243    // Open either fstab or mtab
    2132     fstabname = "/etc/fstab";
    21332244    if (cmdopt_flags & MS_REMOUNT) {
    21342245        // WARNING. I am not sure this matches util-linux's
  • branches/3.3/mindi-busybox/util-linux/rdate.c

    r3232 r3621  
    1212//usage:       "[-sp] HOST"
    1313//usage:#define rdate_full_usage "\n\n"
    14 //usage:       "Get and possibly set the system date/time from a remote HOST\n"
    15 //usage:     "\n    -s  Set the system date/time (default)"
    16 //usage:     "\n    -p  Print the date/time"
     14//usage:       "Get and possibly set system time from a remote HOST\n"
     15//usage:     "\n    -s  Set system time (default)"
     16//usage:     "\n    -p  Print time"
    1717
    1818#include "libbb.h"
     
    3737
    3838    if (safe_read(fd, &nett, 4) != 4)    /* read time from server */
    39         bb_error_msg_and_die("%s did not send the complete time", host);
     39        bb_error_msg_and_die("%s: %s", host, "short read");
    4040    if (ENABLE_FEATURE_CLEAN_UP)
    4141        close(fd);
  • branches/3.3/mindi-busybox/util-linux/readprofile.c

    r3232 r3621  
    153153    step = buf[0];
    154154    if (optInfo) {
    155         printf("Sampling_step: %i\n", step);
     155        printf("Sampling_step: %u\n", step);
    156156        return EXIT_SUCCESS;
    157157    }
     
    220220        ) {
    221221            if (optVerbose)
    222                 printf("%016llx %-40s %6i %8.4f\n", fn_add,
     222                printf("%016llx %-40s %6u %8.4f\n", fn_add,
    223223                    fn_name, this, this/(double)fn_len);
    224224            else
    225                 printf("%6i %-40s %8.4f\n",
     225                printf("%6u %-40s %8.4f\n",
    226226                    this, fn_name, this/(double)fn_len);
    227227            if (optSub) {
     
    247247
    248248    /* clock ticks, out of kernel text - probably modules */
    249     printf("%6i %s\n", buf[len/sizeof(*buf)-1], "*unknown*");
     249    printf("%6u %s\n", buf[len/sizeof(*buf)-1], "*unknown*");
    250250
    251251    /* trailer */
    252252    if (optVerbose)
    253         printf("%016x %-40s %6i %8.4f\n",
     253        printf("%016x %-40s %6u %8.4f\n",
    254254            0, "total", total, total/(double)(fn_add-add0));
    255255    else
    256         printf("%6i %-40s %8.4f\n",
     256        printf("%6u %-40s %8.4f\n",
    257257            total, "total", total/(double)(fn_add-add0));
    258258
  • branches/3.3/mindi-busybox/util-linux/rtcwake.c

    r3232 r3621  
    3333//usage:     "\n    -u,--utc    Clock is set to UTC time"
    3434//usage:     "\n    -d,--device=DEV Specify the RTC device"
    35 //usage:     "\n    -m,--mode=MODE  Set the sleep state (default: standby)"
    36 //usage:     "\n    -s,--seconds=SEC Set the timeout in SEC seconds from now"
    37 //usage:     "\n    -t,--time=TIME  Set the timeout to TIME seconds from epoch"
     35//usage:     "\n    -m,--mode=MODE  Set sleep state (default: standby)"
     36//usage:     "\n    -s,--seconds=SEC Set timeout in SEC seconds from now"
     37//usage:     "\n    -t,--time=TIME  Set timeout to TIME seconds from epoch"
    3838//usage:    )
    3939//usage:    IF_NOT_LONG_OPTS(
     
    4242//usage:     "\n    -u  Clock is set to UTC time"
    4343//usage:     "\n    -d DEV  Specify the RTC device"
    44 //usage:     "\n    -m MODE Set the sleep state (default: standby)"
    45 //usage:     "\n    -s SEC  Set the timeout in SEC seconds from now"
    46 //usage:     "\n    -t TIME Set the timeout to TIME seconds from epoch"
     44//usage:     "\n    -m MODE Set sleep state (default: standby)"
     45//usage:     "\n    -s SEC  Set timeout in SEC seconds from now"
     46//usage:     "\n    -t TIME Set timeout to TIME seconds from epoch"
    4747//usage:    )
    4848
     
    5252#define SYS_RTC_PATH   "/sys/class/rtc/%s/device/power/wakeup"
    5353#define SYS_POWER_PATH "/sys/power/state"
    54 #define DEFAULT_MODE   "standby"
    5554
    5655static NOINLINE bool may_wakeup(const char *rtcname)
     
    6867
    6968    /* wakeup events could be disabled or not supported */
    70     return strncmp(buf, "enabled\n", 8) == 0;
     69    return is_prefixed_with(buf, "enabled\n") != NULL;
    7170}
    7271
     
    123122int rtcwake_main(int argc UNUSED_PARAM, char **argv)
    124123{
    125     time_t rtc_time;
    126 
    127124    unsigned opt;
    128125    const char *rtcname = NULL;
    129     const char *suspend;
     126    const char *suspend = "standby";
    130127    const char *opt_seconds;
    131128    const char *opt_time;
    132129
     130    time_t rtc_time;
    133131    time_t sys_time;
    134     time_t alarm_time = 0;
    135     unsigned seconds = 0;
     132    time_t alarm_time = alarm_time;
     133    unsigned seconds = seconds; /* for compiler */
    136134    int utc = -1;
    137135    int fd;
     
    149147    applet_long_options = rtcwake_longopts;
    150148#endif
     149    /* Must have -s or -t, exclusive */
     150    opt_complementary = "s:t:s--t:t--s";
    151151    opt = getopt32(argv, "alud:m:s:t:", &rtcname, &suspend, &opt_seconds, &opt_time);
    152152
     
    157157    if (opt & (RTCWAKE_OPT_UTC | RTCWAKE_OPT_LOCAL))
    158158        utc = opt & RTCWAKE_OPT_UTC;
    159     if (!(opt & RTCWAKE_OPT_SUSPEND_MODE))
    160         suspend = DEFAULT_MODE;
    161     if (opt & RTCWAKE_OPT_SECONDS)
     159    if (opt & RTCWAKE_OPT_SECONDS) {
    162160        /* alarm time, seconds-to-sleep (relative) */
    163         seconds = xatoi(opt_seconds);
    164     if (opt & RTCWAKE_OPT_TIME)
     161        seconds = xatou(opt_seconds);
     162    } else {
     163        /* RTCWAKE_OPT_TIME */
    165164        /* alarm time, time_t (absolute, seconds since 1/1 1970 UTC) */
    166         alarm_time = xatol(opt_time);
    167 
    168     if (!alarm_time && !seconds)
    169         bb_error_msg_and_die("must provide wake time");
     165        if (sizeof(alarm_time) <= sizeof(long))
     166            alarm_time = xatol(opt_time);
     167        else
     168            alarm_time = xatoll(opt_time);
     169    }
    170170
    171171    if (utc == -1)
     
    178178    fd = rtc_xopen(&rtcname, O_RDONLY);
    179179
    180     if (strcmp(suspend, "on") && !may_wakeup(rtcname))
    181         bb_error_msg_and_die("%s not enabled for wakeup events", rtcname);
     180    if (strcmp(suspend, "on") != 0)
     181        if (!may_wakeup(rtcname))
     182            bb_error_msg_and_die("%s not enabled for wakeup events", rtcname);
    182183
    183184    /* relative or absolute alarm time, normalized to time_t */
     
    189190    }
    190191
    191 
    192     if (alarm_time) {
    193         if (alarm_time < sys_time)
     192    if (opt & RTCWAKE_OPT_TIME) {
     193        /* Correct for RTC<->system clock difference */
     194        alarm_time += rtc_time - sys_time;
     195        if (alarm_time < rtc_time)
     196            /*
     197             * Compat message text.
     198             * I'd say "RTC time is already ahead of ..." instead.
     199             */
    194200            bb_error_msg_and_die("time doesn't go backward to %s", ctime(&alarm_time));
    195         alarm_time += sys_time - rtc_time;
    196201    } else
    197202        alarm_time = rtc_time + seconds + 1;
     203
    198204    setup_alarm(fd, &alarm_time, rtc_time);
    199 
    200205    sync();
     206#if 0 /*debug*/
     207    printf("sys_time: %s", ctime(&sys_time));
     208    printf("rtc_time: %s", ctime(&rtc_time));
     209#endif
    201210    printf("wakeup from \"%s\" at %s", suspend, ctime(&alarm_time));
    202211    fflush_all();
    203212    usleep(10 * 1000);
    204213
    205     if (strcmp(suspend, "on"))
     214    if (strcmp(suspend, "on") != 0)
    206215        xopen_xwrite_close(SYS_POWER_PATH, suspend);
    207216    else {
  • branches/3.3/mindi-busybox/util-linux/script.c

    r3232 r3621  
    2424
    2525#include "libbb.h"
     26#include "common_bufsiz.h"
    2627
    2728int script_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
     
    7879        printf("Script started, file is %s\n", fname);
    7980    }
     81
    8082    shell = get_shell_name();
     83
     84    /* Some people run "script ... 0>&-".
     85     * Our code assumes that STDIN_FILENO != pty.
     86     * Ensure STDIN_FILENO is not closed:
     87     */
     88    bb_sanitize_stdio();
    8189
    8290    pty = xgetpty(pty_line);
     
    102110    if (child_pid) {
    103111        /* parent */
    104 #define buf bb_common_bufsiz1
    105112        struct pollfd pfd[2];
    106113        int outfd, count, loop;
    107114        double oldtime = ENABLE_SCRIPTREPLAY ? time(NULL) : 0;
    108115        smallint fd_count = 2;
     116#define buf bb_common_bufsiz1
     117        setup_common_bufsiz();
    109118
    110119        outfd = xopen(fname, mode);
     
    128137            if (pfd[0].revents) {
    129138                errno = 0;
    130                 count = safe_read(pty, buf, sizeof(buf));
     139                count = safe_read(pty, buf, COMMON_BUFSIZE);
    131140                if (count <= 0 && errno != EAGAIN) {
    132141                    /* err/eof from pty: exit */
     
    151160            }
    152161            if (pfd[1].revents) {
    153                 count = safe_read(STDIN_FILENO, buf, sizeof(buf));
     162                count = safe_read(STDIN_FILENO, buf, COMMON_BUFSIZE);
    154163                if (count <= 0) {
    155164                    /* err/eof from stdin: don't read stdin anymore */
     
    170179        loop = 999;
    171180        /* pty is in O_NONBLOCK mode, we exit as soon as buffer is empty */
    172         while (--loop && (count = safe_read(pty, buf, sizeof(buf))) > 0) {
     181        while (--loop && (count = safe_read(pty, buf, COMMON_BUFSIZE)) > 0) {
    173182            full_write(STDOUT_FILENO, buf, count);
    174183            full_write(outfd, buf, count);
  • branches/3.3/mindi-busybox/util-linux/setarch.c

    r3232 r3621  
    77 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
    88 */
     9//config:config SETARCH
     10//config:   bool "setarch"
     11//config:   default y
     12//config:   select PLATFORM_LINUX
     13//config:   help
     14//config:     The linux32 utility is used to create a 32bit environment for the
     15//config:     specified program (usually a shell). It only makes sense to have
     16//config:     this util on a system that supports both 64bit and 32bit userland
     17//config:     (like amd64/x86, ppc64/ppc, sparc64/sparc, etc...).
     18
     19//applet:IF_SETARCH(APPLET(setarch, BB_DIR_BIN, BB_SUID_DROP))
     20//applet:IF_SETARCH(APPLET_ODDNAME(linux32, setarch, BB_DIR_BIN, BB_SUID_DROP, linux32))
     21//applet:IF_SETARCH(APPLET_ODDNAME(linux64, setarch, BB_DIR_BIN, BB_SUID_DROP, linux64))
     22
     23//kbuild:lib-$(CONFIG_SETARCH) += setarch.o
    924
    1025//usage:#define setarch_trivial_usage
    11 //usage:       "personality PROG ARGS"
     26//usage:       "PERSONALITY [-R] PROG ARGS"
    1227//usage:#define setarch_full_usage "\n\n"
    13 //usage:       "Personality may be:\n"
    14 //usage:       "    linux32     Set 32bit uname emulation\n"
    15 //usage:       "    linux64     Set 64bit uname emulation"
     28//usage:       "PERSONALITY may be:"
     29//usage:   "\n""    linux32 Set 32bit uname emulation"
     30//usage:   "\n""    linux64 Set 64bit uname emulation"
     31//usage:   "\n"
     32//usage:   "\n""    -R  Disable address space randomization"
    1633//usage:
    1734//usage:#define linux32_trivial_usage NOUSAGE_STR
     
    2138//usage:#define linux64_full_usage ""
    2239
     40#include "libbb.h"
    2341#include <sys/personality.h>
    2442
    25 #include "libbb.h"
     43#ifndef ADDR_NO_RANDOMIZE
     44# define ADDR_NO_RANDOMIZE       0x0040000
     45#endif
    2646
    2747int setarch_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
    2848int setarch_main(int argc UNUSED_PARAM, char **argv)
    2949{
    30     int pers;
     50    unsigned opts;
     51    unsigned long pers;
    3152
    3253    /* Figure out what personality we are supposed to switch to ...
     
    3657     */
    3758    if (ENABLE_SETARCH && applet_name[0] == 's'
    38      && argv[1] && strncpy(argv[1], "linux", 5)
     59     && argv[1] && is_prefixed_with(argv[1], "linux")
    3960    ) {
    4061        applet_name = argv[1];
     
    4869        bb_show_usage();
    4970
    50     argv++;
    51     if (argv[0] == NULL)
    52         bb_show_usage();
     71    opts = getopt32(argv, "+R"); /* '+': stop at first non-option */
     72    if (opts)
     73        pers |= ADDR_NO_RANDOMIZE;
    5374
    5475    /* Try to set personality */
    55     if (personality(pers) >= 0) {
    56         /* Try to execute the program */
    57         BB_EXECVP(argv[0], argv);
    58     }
     76    if (personality(pers) < 0)
     77        bb_perror_msg_and_die("personality(0x%lx)", pers);
    5978
    60     bb_simple_perror_msg_and_die(argv[0]);
     79    argv += optind;
     80    if (!argv[0])
     81        (--argv)[0] = (char*)"/bin/sh";
     82
     83    /* Try to execute the program */
     84    BB_EXECVP_or_die(argv);
    6185}
  • branches/3.3/mindi-busybox/util-linux/swaponoff.c

    r3232 r3621  
    99
    1010//usage:#define swapon_trivial_usage
    11 //usage:       "[-a]" IF_FEATURE_SWAPON_PRI(" [-p PRI]") " [DEVICE]"
     11//usage:       "[-a] [-e]" IF_FEATURE_SWAPON_DISCARD(" [-d[POL]]") IF_FEATURE_SWAPON_PRI(" [-p PRI]") " [DEVICE]"
    1212//usage:#define swapon_full_usage "\n\n"
    1313//usage:       "Start swapping on DEVICE\n"
    1414//usage:     "\n    -a  Start swapping on all swap devices"
     15//usage:    IF_FEATURE_SWAPON_DISCARD(
     16//usage:     "\n    -d[POL] Discard blocks at swapon (POL=once),"
     17//usage:     "\n        as freed (POL=pages), or both (POL omitted)"
     18//usage:    )
     19//usage:     "\n    -e  Silently skip devices that do not exist"
    1520//usage:    IF_FEATURE_SWAPON_PRI(
    1621//usage:     "\n    -p PRI  Set swap device priority"
     
    2429
    2530#include "libbb.h"
     31#include "common_bufsiz.h"
    2632#include <mntent.h>
    2733#ifndef __BIONIC__
     
    3945#endif
    4046
    41 #if ENABLE_FEATURE_SWAPON_PRI
     47#if ENABLE_FEATURE_SWAPON_DISCARD
     48#ifndef SWAP_FLAG_DISCARD
     49#define SWAP_FLAG_DISCARD 0x10000
     50#endif
     51#ifndef SWAP_FLAG_DISCARD_ONCE
     52#define SWAP_FLAG_DISCARD_ONCE 0x20000
     53#endif
     54#ifndef SWAP_FLAG_DISCARD_PAGES
     55#define SWAP_FLAG_DISCARD_PAGES 0x40000
     56#endif
     57#define SWAP_FLAG_DISCARD_MASK \
     58    (SWAP_FLAG_DISCARD | SWAP_FLAG_DISCARD_ONCE | SWAP_FLAG_DISCARD_PAGES)
     59#endif
     60
     61
     62#if ENABLE_FEATURE_SWAPON_DISCARD || ENABLE_FEATURE_SWAPON_PRI
    4263struct globals {
    4364    int flags;
    4465} FIX_ALIASING;
    45 #define G (*(struct globals*)&bb_common_bufsiz1)
     66#define G (*(struct globals*)bb_common_bufsiz1)
    4667#define g_flags (G.flags)
     68#define save_g_flags()    int save_g_flags = g_flags
     69#define restore_g_flags() g_flags = save_g_flags
    4770#else
    4871#define g_flags 0
    49 #endif
    50 #define INIT_G() do { } while (0)
     72#define save_g_flags()    ((void)0)
     73#define restore_g_flags() ((void)0)
     74#endif
     75#define INIT_G() do { setup_common_bufsiz(); } while (0)
     76
     77#define do_swapoff   (applet_name[5] == 'f')
     78
     79/* Command line options */
     80enum {
     81    OPTBIT_a,                              /* -a all      */
     82    OPTBIT_e,                              /* -e ifexists */
     83    IF_FEATURE_SWAPON_DISCARD( OPTBIT_d ,) /* -d discard  */
     84    IF_FEATURE_SWAPON_PRI    ( OPTBIT_p ,) /* -p priority */
     85    OPT_a = 1 << OPTBIT_a,
     86    OPT_e = 1 << OPTBIT_e,
     87    OPT_d = IF_FEATURE_SWAPON_DISCARD((1 << OPTBIT_d)) + 0,
     88    OPT_p = IF_FEATURE_SWAPON_PRI    ((1 << OPTBIT_p)) + 0,
     89};
     90
     91#define OPT_ALL      (option_mask32 & OPT_a)
     92#define OPT_DISCARD  (option_mask32 & OPT_d)
     93#define OPT_IFEXISTS (option_mask32 & OPT_e)
     94#define OPT_PRIO     (option_mask32 & OPT_p)
    5195
    5296static int swap_enable_disable(char *device)
    5397{
    54     int status;
    55     struct stat st;
     98    int err = 0;
     99    int quiet = 0;
    56100
    57101    resolve_mount_spec(&device);
    58     xstat(device, &st);
    59 
    60 #if ENABLE_DESKTOP
    61     /* test for holes */
    62     if (S_ISREG(st.st_mode))
    63         if (st.st_blocks * (off_t)512 < st.st_size)
    64             bb_error_msg("warning: swap file has holes");
    65 #endif
    66 
    67     if (applet_name[5] == 'n')
    68         status = swapon(device, g_flags);
    69     else
    70         status = swapoff(device);
    71 
    72     if (status != 0) {
     102
     103    if (do_swapoff) {
     104        err = swapoff(device);
     105        /* Don't complain on OPT_ALL if not a swap device or if it doesn't exist */
     106        quiet = (OPT_ALL && (errno == EINVAL || errno == ENOENT));
     107    } else {
     108        /* swapon */
     109        struct stat st;
     110        err = stat(device, &st);
     111        if (!err) {
     112            if (ENABLE_DESKTOP && S_ISREG(st.st_mode)) {
     113                if (st.st_blocks * (off_t)512 < st.st_size) {
     114                    bb_error_msg("%s: file has holes", device);
     115                    return 1;
     116                }
     117            }
     118            err = swapon(device, g_flags);
     119            /* Don't complain on swapon -a if device is already in use */
     120            quiet = (OPT_ALL && errno == EBUSY);
     121        }
     122        /* Don't complain if file does not exist with -e option */
     123        if (err && OPT_IFEXISTS && errno == ENOENT)
     124            err = 0;
     125    }
     126
     127    if (err && !quiet) {
    73128        bb_simple_perror_msg(device);
    74129        return 1;
    75130    }
    76 
    77131    return 0;
    78132}
    79133
    80 static int do_em_all(void)
     134#if ENABLE_FEATURE_SWAPON_DISCARD
     135static void set_discard_flag(char *s)
     136{
     137    /* Unset the flag first to allow fstab options to override */
     138    /* options set on the command line */
     139    g_flags = (g_flags & ~SWAP_FLAG_DISCARD_MASK) | SWAP_FLAG_DISCARD;
     140
     141    if (!s) /* No optional policy value on the commandline */
     142        return;
     143    /* Skip prepended '=' */
     144    if (*s == '=')
     145        s++;
     146    /* For fstab parsing: remove other appended options */
     147    *strchrnul(s, ',') = '\0';
     148
     149    if (strcmp(s, "once") == 0)
     150        g_flags |= SWAP_FLAG_DISCARD_ONCE;
     151    if  (strcmp(s, "pages") == 0)
     152        g_flags |= SWAP_FLAG_DISCARD_PAGES;
     153}
     154#else
     155#define set_discard_flag(s) ((void)0)
     156#endif
     157
     158#if ENABLE_FEATURE_SWAPON_PRI
     159static void set_priority_flag(char *s)
     160{
     161    unsigned prio;
     162
     163    /* For fstab parsing: remove other appended options */
     164    *strchrnul(s, ',') = '\0';
     165    /* Max allowed 32767 (== SWAP_FLAG_PRIO_MASK) */
     166    prio = bb_strtou(s, NULL, 10);
     167    if (!errno) {
     168        /* Unset the flag first to allow fstab options to override */
     169        /* options set on the command line */
     170        g_flags = (g_flags & ~SWAP_FLAG_PRIO_MASK) | SWAP_FLAG_PREFER |
     171                    MIN(prio, SWAP_FLAG_PRIO_MASK);
     172    }
     173}
     174#else
     175#define set_priority_flag(s) ((void)0)
     176#endif
     177
     178static int do_em_all_in_fstab(void)
    81179{
    82180    struct mntent *m;
    83     FILE *f;
    84     int err;
    85 
    86     f = setmntent("/etc/fstab", "r");
    87     if (f == NULL)
    88         bb_perror_msg_and_die("/etc/fstab");
    89 
    90     err = 0;
     181    int err = 0;
     182    FILE *f = xfopen_for_read("/etc/fstab");
     183
    91184    while ((m = getmntent(f)) != NULL) {
    92185        if (strcmp(m->mnt_type, MNTTYPE_SWAP) == 0) {
    93186            /* swapon -a should ignore entries with noauto,
    94              * but swapoff -a should process them */
    95             if (applet_name[5] != 'n'
    96              || hasmntopt(m, MNTOPT_NOAUTO) == NULL
    97             ) {
    98                 err += swap_enable_disable(m->mnt_fsname);
     187             * but swapoff -a should process them
     188             */
     189            if (do_swapoff || hasmntopt(m, MNTOPT_NOAUTO) == NULL) {
     190                /* each swap space might have different flags */
     191                /* save global flags for the next round */
     192                save_g_flags();
     193                if (ENABLE_FEATURE_SWAPON_DISCARD) {
     194                    char *p = hasmntopt(m, "discard");
     195                    if (p) {
     196                        /* move to '=' or to end of string */
     197                        p += 7;
     198                        set_discard_flag(p);
     199                    }
     200                }
     201                if (ENABLE_FEATURE_SWAPON_PRI) {
     202                    char *p = hasmntopt(m, "pri");
     203                    if (p) {
     204                        set_priority_flag(p + 4);
     205                    }
     206                }
     207                err |= swap_enable_disable(m->mnt_fsname);
     208                restore_g_flags();
    99209            }
    100210        }
     
    107217}
    108218
     219static int do_all_in_proc_swaps(void)
     220{
     221    char *line;
     222    int err = 0;
     223    FILE *f = fopen_for_read("/proc/swaps");
     224    /* Don't complain if missing */
     225    if (f) {
     226        while ((line = xmalloc_fgetline(f)) != NULL) {
     227            if (line[0] == '/') {
     228                *strchrnul(line, ' ') = '\0';
     229                err |= swap_enable_disable(line);
     230            }
     231            free(line);
     232        }
     233        if (ENABLE_FEATURE_CLEAN_UP)
     234            fclose(f);
     235    }
     236
     237    return err;
     238}
     239
     240#define OPTSTR_SWAPON "ae" \
     241    IF_FEATURE_SWAPON_DISCARD("d::") \
     242    IF_FEATURE_SWAPON_PRI("p:")
     243
    109244int swap_on_off_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
    110245int swap_on_off_main(int argc UNUSED_PARAM, char **argv)
    111246{
    112     int ret;
     247    IF_FEATURE_SWAPON_PRI(char *prio;)
     248    IF_FEATURE_SWAPON_DISCARD(char *discard = NULL;)
     249    int ret = 0;
    113250
    114251    INIT_G();
    115252
    116 #if !ENABLE_FEATURE_SWAPON_PRI
    117     ret = getopt32(argv, "a");
    118 #else
    119     if (applet_name[5] == 'n')
    120         opt_complementary = "p+";
    121     ret = getopt32(argv, (applet_name[5] == 'n') ? "ap:" : "a", &g_flags);
    122 
    123     if (ret & 2) { // -p
    124         g_flags = SWAP_FLAG_PREFER |
    125             ((g_flags & SWAP_FLAG_PRIO_MASK) << SWAP_FLAG_PRIO_SHIFT);
    126         ret &= 1;
    127     }
    128 #endif
    129 
    130     if (ret /* & 1: not needed */) // -a
    131         return do_em_all();
     253    getopt32(argv, do_swapoff ? "ae" : OPTSTR_SWAPON
     254            IF_FEATURE_SWAPON_DISCARD(, &discard)
     255            IF_FEATURE_SWAPON_PRI(, &prio)
     256    );
    132257
    133258    argv += optind;
    134     if (!*argv)
     259
     260    if (OPT_DISCARD) {
     261        set_discard_flag(discard);
     262    }
     263    if (OPT_PRIO) {
     264        set_priority_flag(prio);
     265    }
     266
     267    if (OPT_ALL) {
     268        /* swapoff -a does also /proc/swaps */
     269        if (do_swapoff)
     270            ret = do_all_in_proc_swaps();
     271        ret |= do_em_all_in_fstab();
     272    } else if (!*argv) {
     273        /* if not -a we need at least one arg */
    135274        bb_show_usage();
    136 
    137     /* ret = 0; redundant */
    138     do {
    139         ret += swap_enable_disable(*argv);
    140     } while (*++argv);
    141 
     275    }
     276    /* Unset -a now to allow for more messages in swap_enable_disable */
     277    option_mask32 = option_mask32 & ~OPT_a;
     278    /* Now process devices on the commandline if any */
     279    while (*argv) {
     280        ret |= swap_enable_disable(*argv++);
     281    }
    142282    return ret;
    143283}
  • branches/3.3/mindi-busybox/util-linux/switch_root.c

    r3232 r3621  
    207207That's why the careful sequencing above: we cd into the new mount point before
    208208we do the mount --move.  Moving the mount point would otherwise make it
    209 totally inaccessible to is because cd-ing to the old path wouldn't give it to
     209totally inaccessible to us because cd-ing to the old path wouldn't give it to
    210210us anymore, and cd "/" just gives us the cached dentry from when the process
    211211was created (in this case the old initramfs one).  But the "." symlink gives
  • branches/3.3/mindi-busybox/util-linux/umount.c

    r3232 r3621  
    3131#include <mntent.h>
    3232#include <sys/mount.h>
     33#ifndef MNT_DETACH
     34# define MNT_DETACH 0x00000002
     35#endif
    3336#include "libbb.h"
     37#include "common_bufsiz.h"
    3438
    3539#if defined(__dietlibc__)
     
    8286
    8387    // MNT_FORCE and MNT_DETACH (from linux/fs.h) must match
    84     // OPT_FORCE and OPT_LAZY, otherwise this trick won't work:
    85     doForce = MAX((opt & OPT_FORCE), (opt & OPT_LAZY));
     88    // OPT_FORCE and OPT_LAZY.
     89    BUILD_BUG_ON(OPT_FORCE != MNT_FORCE || OPT_LAZY != MNT_DETACH);
     90    doForce = opt & (OPT_FORCE|OPT_LAZY);
    8691
    8792    /* Get a list of mount points from mtab.  We read them all in now mostly
     
    99104            bb_error_msg_and_die("can't open '%s'", bb_path_mtab_file);
    100105    } else {
    101         while (getmntent_r(fp, &me, bb_common_bufsiz1, sizeof(bb_common_bufsiz1))) {
     106        setup_common_bufsiz();
     107        while (getmntent_r(fp, &me, bb_common_bufsiz1, COMMON_BUFSIZE)) {
    102108            /* Match fstype if passed */
    103109            if (!match_fstype(&me, fstype))
     
    148154        if (m) zapit = m->dir;
    149155
     156// umount from util-linux 2.22.2 does not do this:
     157// umount -f uses umount2(MNT_FORCE) immediately,
     158// not trying umount() first.
     159// (Strangely, umount -fl ignores -f: it is equivalent to umount -l.
     160// We do pass both flags in this case)
     161#if 0
    150162        // Let's ask the thing nicely to unmount.
    151163        curstat = umount(zapit);
    152164
    153         // Force the unmount, if necessary.
     165        // Unmount with force and/or lazy flags, if necessary.
    154166        if (curstat && doForce)
     167#endif
    155168            curstat = umount2(zapit, doForce);
    156169
     
    169182            } else {
    170183                status = EXIT_FAILURE;
    171                 bb_perror_msg("can't %sumount %s", (doForce ? "forcibly " : ""), zapit);
     184                bb_perror_msg("can't unmount %s", zapit);
    172185            }
    173186        } else {
  • branches/3.3/mindi-busybox/util-linux/volume_id/Kbuild.src

    r3232 r3621  
    88
    99INSERT
    10 
    11 lib-$(CONFIG_BLKID)                             += get_devname.o
    12 lib-$(CONFIG_FINDFS)                            += get_devname.o
    13 lib-$(CONFIG_FEATURE_MOUNT_LABEL)               += get_devname.o
    14 
    15 lib-$(CONFIG_VOLUMEID)                          += volume_id.o util.o
    16 lib-$(CONFIG_FEATURE_VOLUMEID_BTRFS)            += btrfs.o
    17 lib-$(CONFIG_FEATURE_VOLUMEID_EXT)              += ext.o
    18 lib-$(CONFIG_FEATURE_VOLUMEID_FAT)              += fat.o
    19 lib-$(CONFIG_FEATURE_VOLUMEID_HFS)              += hfs.o
    20 ### lib-$(CONFIG_FEATURE_VOLUMEID_HIGHPOINTRAID)    += highpoint.o
    21 ### lib-$(CONFIG_FEATURE_VOLUMEID_ISWRAID)          += isw_raid.o
    22 ### lib-$(CONFIG_FEATURE_VOLUMEID_LSIRAID)          += lsi_raid.o
    23 ### lib-$(CONFIG_FEATURE_VOLUMEID_VIARAID)          += via_raid.o
    24 ### lib-$(CONFIG_FEATURE_VOLUMEID_SILICONRAID)      += silicon_raid.o
    25 ### lib-$(CONFIG_FEATURE_VOLUMEID_NVIDIARAID)       += nvidia_raid.o
    26 ### lib-$(CONFIG_FEATURE_VOLUMEID_PROMISERAID)      += promise_raid.o
    27 lib-$(CONFIG_FEATURE_VOLUMEID_ISO9660)          += iso9660.o
    28 lib-$(CONFIG_FEATURE_VOLUMEID_JFS)              += jfs.o
    29 lib-$(CONFIG_FEATURE_VOLUMEID_LINUXRAID)        += linux_raid.o
    30 lib-$(CONFIG_FEATURE_VOLUMEID_LINUXSWAP)        += linux_swap.o
    31 ### lib-$(CONFIG_FEATURE_VOLUMEID_LVM)              += lvm.o
    32 ### lib-$(CONFIG_FEATURE_VOLUMEID_MAC)              += mac.o
    33 ### lib-$(CONFIG_FEATURE_VOLUMEID_MSDOS)            += msdos.o
    34 lib-$(CONFIG_FEATURE_VOLUMEID_NILFS)            += nilfs.o
    35 lib-$(CONFIG_FEATURE_VOLUMEID_NTFS)             += ntfs.o
    36 lib-$(CONFIG_FEATURE_VOLUMEID_EXFAT)            += exfat.o
    37 lib-$(CONFIG_FEATURE_VOLUMEID_REISERFS)         += reiserfs.o
    38 lib-$(CONFIG_FEATURE_VOLUMEID_UDF)              += udf.o
    39 ### lib-$(CONFIG_FEATURE_VOLUMEID_UFS)              += ufs.o
    40 lib-$(CONFIG_FEATURE_VOLUMEID_XFS)              += xfs.o
    41 lib-$(CONFIG_FEATURE_VOLUMEID_CRAMFS)           += cramfs.o
    42 ### lib-$(CONFIG_FEATURE_VOLUMEID_HPFS)             += hpfs.o
    43 lib-$(CONFIG_FEATURE_VOLUMEID_ROMFS)            += romfs.o
    44 lib-$(CONFIG_FEATURE_VOLUMEID_SYSV)             += sysv.o
    45 ### lib-$(CONFIG_FEATURE_VOLUMEID_MINIX)            += minix.o
    46 lib-$(CONFIG_FEATURE_VOLUMEID_LUKS)             += luks.o
    47 lib-$(CONFIG_FEATURE_VOLUMEID_OCFS2)            += ocfs2.o
  • branches/3.3/mindi-busybox/util-linux/volume_id/btrfs.c

    r3232 r3621  
    1919 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    2020 */
     21
     22//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_BTRFS) += btrfs.o
     23
     24//config:
     25//config:config FEATURE_VOLUMEID_BTRFS
     26//config:   bool "btrfs filesystem"
     27//config:   default y
     28//config:   depends on VOLUMEID
     29//config:   help
     30//config:     TODO
     31//config:
    2132
    2233#include "volume_id_internal.h"
  • branches/3.3/mindi-busybox/util-linux/volume_id/cramfs.c

    r3232 r3621  
    1818 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    1919 */
     20
     21//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_CRAMFS) += cramfs.o
     22
     23//config:
     24//config:config FEATURE_VOLUMEID_CRAMFS
     25//config:   bool "cramfs filesystem"
     26//config:   default y
     27//config:   depends on VOLUMEID
     28//config:   help
     29//config:     TODO
     30//config:
    2031
    2132#include "volume_id_internal.h"
  • branches/3.3/mindi-busybox/util-linux/volume_id/exfat.c

    r3233 r3621  
    1818 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    1919 */
     20
     21//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_EXFAT) += exfat.o
     22
     23//config:
     24//config:config FEATURE_VOLUMEID_EXFAT
     25//config:   bool "exFAT filesystem"
     26//config:   default y
     27//config:   depends on VOLUMEID
     28//config:   help
     29//config:     exFAT (extended FAT) is a proprietary file system designed especially
     30//config:     for flash drives. It has many features from NTFS, but with less
     31//config:     overhead. exFAT is used on most SDXC cards for consumer electronics.
     32//config:
    2033
    2134#include "volume_id_internal.h"
  • branches/3.3/mindi-busybox/util-linux/volume_id/ext.c

    r3232 r3621  
    1818 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    1919 */
     20
     21//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_EXT) += ext.o
     22
     23//config:
     24//config:config FEATURE_VOLUMEID_EXT
     25//config:   bool "Ext filesystem"
     26//config:   default y
     27//config:   depends on VOLUMEID
     28//config:   help
     29//config:     TODO
     30//config:
    2031
    2132#include "volume_id_internal.h"
  • branches/3.3/mindi-busybox/util-linux/volume_id/fat.c

    r3232 r3621  
    1818 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    1919 */
     20
     21//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_FAT) += fat.o
     22
     23//config:
     24//config:config FEATURE_VOLUMEID_FAT
     25//config:   bool "fat filesystem"
     26//config:   default y
     27//config:   depends on VOLUMEID
     28//config:   help
     29//config:     TODO
     30//config:
    2031
    2132#include "volume_id_internal.h"
  • branches/3.3/mindi-busybox/util-linux/volume_id/get_devname.c

    r3232 r3621  
    88 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
    99 */
     10
     11//kbuild:lib-$(CONFIG_BLKID) += get_devname.o
     12//kbuild:lib-$(CONFIG_FINDFS) += get_devname.o
     13//kbuild:lib-$(CONFIG_FEATURE_MOUNT_LABEL) += get_devname.o
     14
    1015#include <sys/mount.h> /* BLKGETSIZE64 */
    1116#if !defined(BLKGETSIZE64)
     
    298303    char *tmp = *fsname;
    299304
    300     if (strncmp(*fsname, "UUID=", 5) == 0)
     305    if (is_prefixed_with(*fsname, "UUID="))
    301306        tmp = get_devname_from_uuid(*fsname + 5);
    302     else if (strncmp(*fsname, "LABEL=", 6) == 0)
     307    else if (is_prefixed_with(*fsname, "LABEL="))
    303308        tmp = get_devname_from_label(*fsname + 6);
    304309
  • branches/3.3/mindi-busybox/util-linux/volume_id/hfs.c

    r3232 r3621  
    1818 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    1919 */
     20
     21//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_HFS) += hfs.o
     22
     23//config:
     24//config:config FEATURE_VOLUMEID_HFS
     25//config:   bool "hfs filesystem"
     26//config:   default y
     27//config:   depends on VOLUMEID
     28//config:   help
     29//config:     TODO
     30//config:
    2031
    2132#include "volume_id_internal.h"
  • branches/3.3/mindi-busybox/util-linux/volume_id/iso9660.c

    r3232 r3621  
    1818 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    1919 */
     20
     21//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_ISO9660) += iso9660.o
     22
     23//config:
     24//config:config FEATURE_VOLUMEID_ISO9660
     25//config:   bool "iso9660 filesystem"
     26//config:   default y
     27//config:   depends on VOLUMEID
     28//config:   help
     29//config:     TODO
     30//config:
    2031
    2132#include "volume_id_internal.h"
  • branches/3.3/mindi-busybox/util-linux/volume_id/jfs.c

    r3232 r3621  
    1818 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    1919 */
     20
     21//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_JFS) += jfs.o
     22
     23//config:
     24//config:config FEATURE_VOLUMEID_JFS
     25//config:   bool "jfs filesystem"
     26//config:   default y
     27//config:   depends on VOLUMEID
     28//config:   help
     29//config:     TODO
     30//config:
    2031
    2132#include "volume_id_internal.h"
  • branches/3.3/mindi-busybox/util-linux/volume_id/linux_raid.c

    r3232 r3621  
    1818 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    1919 */
     20
     21//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_LINUXRAID) += linux_raid.o
     22
     23//config:
     24//config:config FEATURE_VOLUMEID_LINUXRAID
     25//config:   bool "linuxraid"
     26//config:   default y
     27//config:   depends on VOLUMEID
     28//config:   help
     29//config:     TODO
     30//config:
    2031
    2132#include "volume_id_internal.h"
  • branches/3.3/mindi-busybox/util-linux/volume_id/linux_swap.c

    r3232 r3621  
    1818 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    1919 */
     20
     21//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_LINUXSWAP) += linux_swap.o
     22
     23//config:
     24//config:config FEATURE_VOLUMEID_LINUXSWAP
     25//config:   bool "linux swap filesystem"
     26//config:   default y
     27//config:   depends on VOLUMEID
     28//config:   help
     29//config:     TODO
     30//config:
    2031
    2132#include "volume_id_internal.h"
  • branches/3.3/mindi-busybox/util-linux/volume_id/luks.c

    r3232 r3621  
    1919 */
    2020
     21//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_LUKS) += luks.o
     22
     23//config:
     24//config:config FEATURE_VOLUMEID_LUKS
     25//config:   bool "luks filesystem"
     26//config:   default y
     27//config:   depends on VOLUMEID
     28//config:   help
     29//config:     TODO
     30//config:
     31
    2132#include "volume_id_internal.h"
    2233
     
    3041#define LUKS_NUMKEYS             8
    3142
    32 static const uint8_t LUKS_MAGIC[] = { 'L','U','K','S', 0xba, 0xbe };
     43static const uint8_t LUKS_MAGIC[] ALIGN1 = { 'L','U','K','S', 0xba, 0xbe };
    3344
    3445struct luks_phdr {
  • branches/3.3/mindi-busybox/util-linux/volume_id/nilfs.c

    r3233 r3621  
    1919 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    2020 */
     21
     22//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_NILFS) += nilfs.o
     23
     24//config:
     25//config:config FEATURE_VOLUMEID_NILFS
     26//config:   bool "nilfs filesystem"
     27//config:   default y
     28//config:   depends on VOLUMEID
     29//config:   help
     30//config:     NILFS is a New Implementation of a Log-Structured File System (LFS)
     31//config:     that supports continuous snapshots. This provides features like
     32//config:     versioning of the entire filesystem, restoration of files that
     33//config:     were deleted a few minutes ago. NILFS keeps consistency like
     34//config:     conventional LFS, so it provides quick recovery after system crashes.
     35//config:
     36//config:     The possible use of NILFS includes versioning, tamper detection,
     37//config:     SOX compliance logging, and so forth. It can serve as an alternative
     38//config:     filesystem for Linux desktop environment, or as a basis of advanced
     39//config:     storage appliances.
     40//config:
    2141
    2242#include "volume_id_internal.h"
  • branches/3.3/mindi-busybox/util-linux/volume_id/ntfs.c

    r3232 r3621  
    1818 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    1919 */
     20
     21//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_NTFS) += ntfs.o
     22
     23//config:
     24//config:config FEATURE_VOLUMEID_NTFS
     25//config:   bool "ntfs filesystem"
     26//config:   default y
     27//config:   depends on VOLUMEID
     28//config:   help
     29//config:     TODO
     30//config:
    2031
    2132#include "volume_id_internal.h"
  • branches/3.3/mindi-busybox/util-linux/volume_id/ocfs2.c

    r3232 r3621  
    1818 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    1919 */
     20
     21//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_OCFS2) += ocfs2.o
     22
     23//config:
     24//config:config FEATURE_VOLUMEID_OCFS2
     25//config:   bool "ocfs2 filesystem"
     26//config:   default y
     27//config:   depends on VOLUMEID
     28//config:   help
     29//config:     TODO
     30//config:
    2031
    2132#include "volume_id_internal.h"
  • branches/3.3/mindi-busybox/util-linux/volume_id/reiserfs.c

    r3232 r3621  
    1919 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    2020 */
     21
     22//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_REISERFS) += reiserfs.o
     23
     24//config:
     25//config:config FEATURE_VOLUMEID_REISERFS
     26//config:   bool "Reiser filesystem"
     27//config:   default y
     28//config:   depends on VOLUMEID
     29//config:   help
     30//config:     TODO
     31//config:
    2132
    2233#include "volume_id_internal.h"
  • branches/3.3/mindi-busybox/util-linux/volume_id/romfs.c

    r3232 r3621  
    1818 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    1919 */
     20
     21//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_ROMFS) += romfs.o
     22
     23//config:
     24//config:config FEATURE_VOLUMEID_ROMFS
     25//config:   bool "romfs filesystem"
     26//config:   default y
     27//config:   depends on VOLUMEID
     28//config:   help
     29//config:     TODO
     30//config:
    2031
    2132#include "volume_id_internal.h"
  • branches/3.3/mindi-busybox/util-linux/volume_id/sysv.c

    r3232 r3621  
    1818 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    1919 */
     20
     21//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_SYSV) += sysv.o
     22
     23//config:
     24//config:config FEATURE_VOLUMEID_SYSV
     25//config:   bool "sysv filesystem"
     26//config:   default y
     27//config:   depends on VOLUMEID
     28//config:   help
     29//config:     TODO
     30//config:
    2031
    2132#include "volume_id_internal.h"
  • branches/3.3/mindi-busybox/util-linux/volume_id/udf.c

    r3232 r3621  
    1818 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    1919 */
     20
     21//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_UDF) += udf.o
     22
     23//config:
     24//config:config FEATURE_VOLUMEID_UDF
     25//config:   bool "udf filesystem"
     26//config:   default y
     27//config:   depends on VOLUMEID
     28//config:   help
     29//config:     TODO
     30//config:
    2031
    2132#include "volume_id_internal.h"
  • branches/3.3/mindi-busybox/util-linux/volume_id/unused_highpoint.c

    r2725 r3621  
    1818 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    1919 */
     20
     21//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_HIGHPOINTRAID) += highpoint.o
     22
     23//config:
     24//config:### config FEATURE_VOLUMEID_HIGHPOINTRAID
     25//config:###    bool "highpoint raid"
     26//config:###    default y
     27//config:###    depends on VOLUMEID
     28//config:###    help
     29//config:###      TODO
     30//config:
    2031
    2132#include "volume_id_internal.h"
  • branches/3.3/mindi-busybox/util-linux/volume_id/unused_hpfs.c

    r2725 r3621  
    1818 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    1919 */
     20
     21//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_HPFS) += hpfs.o
     22
     23//config:
     24//config:### config FEATURE_VOLUMEID_HPFS
     25//config:###    bool "hpfs filesystem"
     26//config:###    default y
     27//config:###    depends on VOLUMEID
     28//config:###    help
     29//config:###      TODO
     30//config:
    2031
    2132#include "volume_id_internal.h"
  • branches/3.3/mindi-busybox/util-linux/volume_id/unused_isw_raid.c

    r2725 r3621  
    1818 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    1919 */
     20
     21//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_ISWRAID) += isw_raid.o
     22
     23//config:
     24//config:### config FEATURE_VOLUMEID_ISWRAID
     25//config:###    bool "intel raid"
     26//config:###    default y
     27//config:###    depends on VOLUMEID
     28//config:###    help
     29//config:###      TODO
     30//config:
    2031
    2132#include "volume_id_internal.h"
  • branches/3.3/mindi-busybox/util-linux/volume_id/unused_lsi_raid.c

    r2725 r3621  
    1818 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    1919 */
     20
     21//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_LSIRAID) += lsi_raid.o
     22
     23//config:
     24//config:### config FEATURE_VOLUMEID_LSIRAID
     25//config:###    bool "lsi raid"
     26//config:###    default y
     27//config:###    depends on VOLUMEID
     28//config:###    help
     29//config:###      TODO
     30//config:
    2031
    2132#include "volume_id_internal.h"
  • branches/3.3/mindi-busybox/util-linux/volume_id/unused_lvm.c

    r2725 r3621  
    1818 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    1919 */
     20
     21//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_LVM) += lvm.o
     22
     23//config:
     24//config:### config FEATURE_VOLUMEID_LVM
     25//config:###    bool "lvm"
     26//config:###    default y
     27//config:###    depends on VOLUMEID
     28//config:###    help
     29//config:###      TODO
     30//config:
    2031
    2132#include "volume_id_internal.h"
  • branches/3.3/mindi-busybox/util-linux/volume_id/unused_mac.c

    r2725 r3621  
    1818 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    1919 */
     20
     21//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_MAC) += mac.o
     22
     23//config:
     24//config:### config FEATURE_VOLUMEID_MAC
     25//config:###    bool "mac filesystem"
     26//config:###    default y
     27//config:###    depends on VOLUMEID
     28//config:###    help
     29//config:###      TODO
     30//config:
    2031
    2132#include "volume_id_internal.h"
  • branches/3.3/mindi-busybox/util-linux/volume_id/unused_minix.c

    r2725 r3621  
    1818 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    1919 */
     20
     21//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_MINIX) += minix.o
     22
     23//config:
     24//config:### config FEATURE_VOLUMEID_MINIX
     25//config:###    bool "minix filesystem"
     26//config:###    default y
     27//config:###    depends on VOLUMEID
     28//config:###    help
     29//config:###      TODO
     30//config:
    2031
    2132#include "volume_id_internal.h"
  • branches/3.3/mindi-busybox/util-linux/volume_id/unused_msdos.c

    r3232 r3621  
    1818 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    1919 */
     20
     21//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_MSDOS) += msdos.o
     22
     23//config:
     24//config:### config FEATURE_VOLUMEID_MSDOS
     25//config:###    bool "msdos filesystem"
     26//config:###    default y
     27//config:###    depends on VOLUMEID
     28//config:###    help
     29//config:###      TODO
     30//config:
    2031
    2132#include "volume_id_internal.h"
     
    166177                    id->partition_count = 4;
    167178
    168                 p = &id->partitions[id->partition_count];
     179//              p = &id->partitions[id->partition_count];
    169180
    170181//              if (is_raid(part[i].sys_ind))
  • branches/3.3/mindi-busybox/util-linux/volume_id/unused_nvidia_raid.c

    r2725 r3621  
    1818 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    1919 */
     20
     21//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_NVIDIARAID) += nvidia_raid.o
     22
     23//config:
     24//config:### config FEATURE_VOLUMEID_NVIDIARAID
     25//config:###    bool "nvidia raid"
     26//config:###    default y
     27//config:###    depends on VOLUMEID
     28//config:###    help
     29//config:###      TODO
     30//config:
    2031
    2132#include "volume_id_internal.h"
  • branches/3.3/mindi-busybox/util-linux/volume_id/unused_promise_raid.c

    r2725 r3621  
    1818 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    1919 */
     20
     21//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_PROMISERAID) += promise_raid.o
     22
     23//config:
     24//config:### config FEATURE_VOLUMEID_PROMISERAID
     25//config:###    bool "promise raid"
     26//config:###    default y
     27//config:###    depends on VOLUMEID
     28//config:###    help
     29//config:###      TODO
     30//config:
    2031
    2132#include "volume_id_internal.h"
  • branches/3.3/mindi-busybox/util-linux/volume_id/unused_silicon_raid.c

    r3232 r3621  
    1818 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    1919 */
     20
     21//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_SILICONRAID) += silicon_raid.o
     22
     23//config:
     24//config:### config FEATURE_VOLUMEID_SILICONRAID
     25//config:###    bool "silicon raid"
     26//config:###    default y
     27//config:###    depends on VOLUMEID
     28//config:###    help
     29//config:###      TODO
     30//config:
    2031
    2132#include "volume_id_internal.h"
  • branches/3.3/mindi-busybox/util-linux/volume_id/unused_ufs.c

    r2725 r3621  
    1818 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    1919 */
     20
     21//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_UFS) += ufs.o
     22
     23//config:
     24//config:### config FEATURE_VOLUMEID_UFS
     25//config:###    bool "ufs filesystem"
     26//config:###    default y
     27//config:###    depends on VOLUMEID
     28//config:###    help
     29//config:###      TODO
     30//config:
    2031
    2132#include "volume_id_internal.h"
  • branches/3.3/mindi-busybox/util-linux/volume_id/unused_via_raid.c

    r2725 r3621  
    1818 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    1919 */
     20
     21//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_VIARAID) += via_raid.o
     22
     23//config:
     24//config:### config FEATURE_VOLUMEID_VIARAID
     25//config:###    bool "via raid"
     26//config:###    default y
     27//config:###    depends on VOLUMEID
     28//config:###    help
     29//config:###      TODO
     30//config:
    2031
    2132#include "volume_id_internal.h"
  • branches/3.3/mindi-busybox/util-linux/volume_id/volume_id.c

    r3232 r3621  
    1818 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    1919 */
     20
     21//kbuild:lib-$(CONFIG_VOLUMEID) += volume_id.o util.o
    2022
    2123#include "volume_id_internal.h"
     
    106108    volume_id_probe_xfs,
    107109#endif
     110#if ENABLE_FEATURE_VOLUMEID_BCACHE
     111    volume_id_probe_bcache,
     112#endif
    108113};
    109114
     
    136141#if ENABLE_FEATURE_VOLUMEID_UFS
    137142    volume_id_probe_ufs,
     143#endif
     144#if ENABLE_FEATURE_VOLUMEID_F2FS
     145    volume_id_probe_f2fs,
    138146#endif
    139147#if ENABLE_FEATURE_VOLUMEID_NILFS
  • branches/3.3/mindi-busybox/util-linux/volume_id/volume_id_internal.h

    r3232 r3621  
    9797#define SEEK_BUFFER_SIZE            0x10000
    9898
    99 #define bswap16(x) (uint16_t)   ( \
    100                 (((uint16_t)(x) & 0x00ffu) << 8) | \
    101                 (((uint16_t)(x) & 0xff00u) >> 8))
    102 
    103 #define bswap32(x) (uint32_t)   ( \
    104                 (((uint32_t)(x) & 0xff000000u) >> 24) | \
    105                 (((uint32_t)(x) & 0x00ff0000u) >>  8) | \
    106                 (((uint32_t)(x) & 0x0000ff00u) <<  8) | \
    107                 (((uint32_t)(x) & 0x000000ffu) << 24))
    108 
    109 #define bswap64(x) (uint64_t)   ( \
    110                 (((uint64_t)(x) & 0xff00000000000000ull) >> 56) | \
    111                 (((uint64_t)(x) & 0x00ff000000000000ull) >> 40) | \
    112                 (((uint64_t)(x) & 0x0000ff0000000000ull) >> 24) | \
    113                 (((uint64_t)(x) & 0x000000ff00000000ull) >>  8) | \
    114                 (((uint64_t)(x) & 0x00000000ff000000ull) <<  8) | \
    115                 (((uint64_t)(x) & 0x0000000000ff0000ull) << 24) | \
    116                 (((uint64_t)(x) & 0x000000000000ff00ull) << 40) | \
    117                 (((uint64_t)(x) & 0x00000000000000ffull) << 56))
    118 
    11999#if BB_LITTLE_ENDIAN
    120 #define le16_to_cpu(x) (x)
    121 #define le32_to_cpu(x) (x)
    122 #define le64_to_cpu(x) (x)
    123 #define be16_to_cpu(x) bswap16(x)
    124 #define be32_to_cpu(x) bswap32(x)
    125 #define cpu_to_le16(x) (x)
    126 #define cpu_to_le32(x) (x)
    127 #define cpu_to_be32(x) bswap32(x)
     100# define le16_to_cpu(x) (uint16_t)(x)
     101# define le32_to_cpu(x) (uint32_t)(x)
     102# define le64_to_cpu(x) (uint64_t)(x)
     103# define be16_to_cpu(x) (uint16_t)(bswap_16(x))
     104# define be32_to_cpu(x) (uint32_t)(bswap_32(x))
     105# define cpu_to_le16(x) (uint16_t)(x)
     106# define cpu_to_le32(x) (uint32_t)(x)
     107# define cpu_to_be32(x) (uint32_t)(bswap_32(x))
    128108#else
    129 #define le16_to_cpu(x) bswap16(x)
    130 #define le32_to_cpu(x) bswap32(x)
    131 #define le64_to_cpu(x) bswap64(x)
    132 #define be16_to_cpu(x) (x)
    133 #define be32_to_cpu(x) (x)
    134 #define cpu_to_le16(x) bswap16(x)
    135 #define cpu_to_le32(x) bswap32(x)
    136 #define cpu_to_be32(x) (x)
     109# define le16_to_cpu(x) (uint16_t)(bswap_16(x))
     110# define le32_to_cpu(x) (uint32_t)(bswap_32(x))
     111# define le64_to_cpu(x) (uint64_t)(bb_bswap_64(x))
     112# define be16_to_cpu(x) (uint16_t)(x)
     113# define be32_to_cpu(x) (uint32_t)(x)
     114# define cpu_to_le16(x) (uint16_t)(bswap_16(x))
     115# define cpu_to_le32(x) (uint32_t)(bswap_32(x))
     116# define cpu_to_be32(x) (uint32_t)(x)
    137117#endif
    138118
     
    190170/* FS */
    191171
     172int FAST_FUNC volume_id_probe_bcache(struct volume_id *id /*,uint64_t off*/);
     173
    192174int FAST_FUNC volume_id_probe_btrfs(struct volume_id *id /*,uint64_t off*/);
    193175
     
    216198//int FAST_FUNC volume_id_probe_msdos_part_table(struct volume_id *id /*,uint64_t off*/);
    217199
     200int FAST_FUNC volume_id_probe_f2fs(struct volume_id *id /*,uint64_t off*/);
     201
    218202int FAST_FUNC volume_id_probe_nilfs(struct volume_id *id /*,uint64_t off*/);
    219203
  • branches/3.3/mindi-busybox/util-linux/volume_id/xfs.c

    r3232 r3621  
    1818 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    1919 */
     20
     21//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_XFS) += xfs.o
     22
     23//config:
     24//config:config FEATURE_VOLUMEID_XFS
     25//config:   bool "xfs filesystem"
     26//config:   default y
     27//config:   depends on VOLUMEID
     28//config:   help
     29//config:     TODO
     30//config:
    2031
    2132#include "volume_id_internal.h"
Note: See TracChangeset for help on using the changeset viewer.