Changeset 3621 in MondoRescue for branches/3.3/mindi-busybox/coreutils/touch.c
- Timestamp:
- Dec 20, 2016, 4:07:32 PM (8 years ago)
- Location:
- branches/3.3
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3/mindi-busybox/coreutils/touch.c
r3232 r3621 27 27 //config: modification timestamp of specified files. 28 28 //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: 29 37 //config:config FEATURE_TOUCH_SUSV3 30 38 //config: bool "Add support for SUSV3 features (-d -t -r)" … … 43 51 //usage: "Update the last-modified date on the given FILE[s]\n" 44 52 //usage: "\n -c Don't create files" 53 //usage: IF_FEATURE_TOUCH_NODEREF( 54 //usage: "\n -h Don't follow links" 55 //usage: ) 45 56 //usage: IF_FEATURE_TOUCH_SUSV3( 46 57 //usage: "\n -d DT Date/time to use" … … 66 77 * -f (ignored, BSD compat) 67 78 * -m change only the modification time 79 * -h, --no-dereference 68 80 * -r, --reference=FILE 69 81 * use this file's times instead of current time … … 80 92 int status = EXIT_SUCCESS; 81 93 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 }; 82 101 #if ENABLE_FEATURE_TOUCH_SUSV3 83 102 # if ENABLE_LONG_OPTS … … 87 106 "reference\0" Required_argument "r" 88 107 "date\0" Required_argument "d" 108 IF_FEATURE_TOUCH_NODEREF("no-dereference\0" No_argument "h") 89 109 ; 90 110 # endif … … 106 126 * We accept the same formats for both */ 107 127 opts = getopt32(argv, "c" IF_FEATURE_TOUCH_SUSV3("r:d:t:") 128 IF_FEATURE_TOUCH_NODEREF("h") 108 129 /*ignored:*/ "fma" 109 130 IF_FEATURE_TOUCH_SUSV3(, &reference_file) … … 112 133 ); 113 134 114 opts &= 1; /* only -c bit is left */115 135 argv += optind; 116 136 if (!*argv) { … … 122 142 xstat(reference_file, &stbuf); 123 143 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 */ 124 148 } 125 149 … … 142 166 143 167 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 */ 147 178 continue; 148 179 }
Note:
See TracChangeset
for help on using the changeset viewer.