Changeset 3621 in MondoRescue for branches/3.3/mindi-busybox/coreutils/touch.c


Ignore:
Timestamp:
Dec 20, 2016, 4:07:32 PM (7 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:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/3.3/mindi-busybox/coreutils/touch.c

    r3232 r3621  
    2727//config:     modification timestamp of specified files.
    2828//config:
     29//config:config FEATURE_TOUCH_NODEREF
     30//config:   bool "Add support for -h"
     31//config:   default y
     32//config:   depends on TOUCH
     33//config:   help
     34//config:     Enable touch to have the -h option.
     35//config:     This requires libc support for lutimes() function.
     36//config:
    2937//config:config FEATURE_TOUCH_SUSV3
    3038//config:   bool "Add support for SUSV3 features (-d -t -r)"
     
    4351//usage:       "Update the last-modified date on the given FILE[s]\n"
    4452//usage:     "\n    -c  Don't create files"
     53//usage:    IF_FEATURE_TOUCH_NODEREF(
     54//usage:     "\n    -h  Don't follow links"
     55//usage:    )
    4556//usage:    IF_FEATURE_TOUCH_SUSV3(
    4657//usage:     "\n    -d DT   Date/time to use"
     
    6677 * -f   (ignored, BSD compat)
    6778 * -m   change only the modification time
     79 * -h, --no-dereference
    6880 * -r, --reference=FILE
    6981 *      use this file's times instead of current time
     
    8092    int status = EXIT_SUCCESS;
    8193    int opts;
     94    enum {
     95        OPT_c = (1 << 0),
     96        OPT_r = (1 << 1) * ENABLE_FEATURE_TOUCH_SUSV3,
     97        OPT_d = (1 << 2) * ENABLE_FEATURE_TOUCH_SUSV3,
     98        OPT_t = (1 << 3) * ENABLE_FEATURE_TOUCH_SUSV3,
     99        OPT_h = (1 << 4) * ENABLE_FEATURE_TOUCH_NODEREF,
     100    };
    82101#if ENABLE_FEATURE_TOUCH_SUSV3
    83102# if ENABLE_LONG_OPTS
     
    87106        "reference\0"         Required_argument "r"
    88107        "date\0"              Required_argument "d"
     108        IF_FEATURE_TOUCH_NODEREF("no-dereference\0" No_argument "h")
    89109    ;
    90110# endif
     
    106126     * We accept the same formats for both */
    107127    opts = getopt32(argv, "c" IF_FEATURE_TOUCH_SUSV3("r:d:t:")
     128                IF_FEATURE_TOUCH_NODEREF("h")
    108129                /*ignored:*/ "fma"
    109130                IF_FEATURE_TOUCH_SUSV3(, &reference_file)
     
    112133    );
    113134
    114     opts &= 1; /* only -c bit is left */
    115135    argv += optind;
    116136    if (!*argv) {
     
    122142        xstat(reference_file, &stbuf);
    123143        timebuf[1].tv_sec = timebuf[0].tv_sec = stbuf.st_mtime;
     144        /* Can use .st_mtim.tv_nsec
     145         * (or is it .st_mtimensec?? see date.c)
     146         * to set microseconds too.
     147         */
    124148    }
    125149
     
    142166
    143167    do {
    144         if (utimes(*argv, (reference_file || date_str) ? timebuf : NULL) != 0) {
    145             if (errno == ENOENT) { /* no such file */
    146                 if (opts) { /* creation is disabled, so ignore */
     168        int result;
     169        result = (
     170#if ENABLE_FEATURE_TOUCH_NODEREF
     171            (opts & OPT_h) ? lutimes :
     172#endif
     173            utimes)(*argv, (reference_file || date_str) ? timebuf : NULL);
     174        if (result != 0) {
     175            if (errno == ENOENT) { /* no such file? */
     176                if (opts & OPT_c) {
     177                    /* Creation is disabled, so ignore */
    147178                    continue;
    148179                }
Note: See TracChangeset for help on using the changeset viewer.