Changeset 3215 for trunk/src/kmk/kmkbuiltin/mv.c
- Timestamp:
- Mar 31, 2018, 12:01:55 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/kmkbuiltin/mv.c
r3192 r3215 51 51 * Header Files * 52 52 *********************************************************************************************************************************/ 53 #define FAKES_NO_GETOPT_H /* bird */ 53 54 #include "config.h" 54 55 #include <sys/types.h> … … 80 81 #endif 81 82 #include <unistd.h> 82 #include "getopt .h"83 #include "getopt_r.h" 83 84 #ifdef __sun__ 84 85 # include "solfakes.h" … … 121 122 122 123 static int do_move(PMVINSTANCE, char *, char *); 123 #if def CROSS_DEVICE_MOVE124 #if 0 // def CROSS_DEVICE_MOVE 124 125 static int fastcopy(char *, char *, struct stat *); 125 126 static int copy(char *, char *); … … 128 129 129 130 130 #if !defined(__FreeBSD__) && !defined(__APPLE__) && !defined(__DragonFly__) && !defined(__OpenBSD__)131 # ifdef __OS2__132 static133 # endif134 const char *user_from_uid(uid_t id, int x)135 {136 static char s_buf[64];137 sprintf(s_buf, "%ld", (long int)id);138 (void)x;139 return s_buf;140 }141 # ifdef __OS2__142 static143 # endif144 const char *group_from_gid(gid_t id, int x)145 {146 static char s_buf[64];147 sprintf(s_buf, "%ld", (long int)id);148 (void)x;149 return s_buf;150 }151 #endif /* 'not in libc' */152 153 154 131 int 155 132 kmk_builtin_mv(int argc, char **argv, char **envp, PKMKBUILTINCTX pCtx) 156 133 { 157 134 MVINSTANCE This; 135 struct getopt_state_r gos; 158 136 size_t baselen, len; 159 137 int rval; … … 170 148 This.vflg = 0; 171 149 172 /* kmk: reset getopt and set progname */ 173 opterr = 1; 174 optarg = NULL; 175 optopt = 0; 176 optind = 0; /* init */ 177 178 while ((ch = getopt_long(argc, argv, "finv", long_options, NULL)) != -1) 150 getopt_initialize_r(&gos, argc, argv, "finv", long_options, envp, pCtx); 151 while ((ch = getopt_long_r(&gos, NULL)) != -1) 179 152 switch (ch) { 180 153 case 'i': … … 201 174 return usage(pCtx, 1); 202 175 } 203 argc -= optind;204 argv += optind;176 argc -= gos.optind; 177 argv += gos.optind; 205 178 206 179 if (argc < 2) … … 301 274 } else if (access(to, W_OK) && !stat(to, &sb)) { 302 275 bsd_strmode(sb.st_mode, modep); 276 #if 0 /* probably not thread safe, also BSDism. */ 303 277 (void)fprintf(stderr, "override %s%s%s/%s for %s? %s", 304 278 modep + 1, modep[9] == ' ' ? "" : " ", 305 279 user_from_uid((unsigned long)sb.st_uid, 0), 306 280 group_from_gid((unsigned long)sb.st_gid, 0), to, YESNO); 281 #else 282 (void)fprintf(stderr, "override %s%s%ul/%ul for %s? %s", 283 modep + 1, modep[9] == ' ' ? "" : " ", 284 (unsigned long)sb.st_uid, (unsigned long)sb.st_gid, 285 to, YESNO); 286 #endif 307 287 ask = 1; 308 288 } … … 335 315 336 316 if (errno == EXDEV) { 337 #if ndef CROSS_DEVICE_MOVE317 #if 1 //ndef CROSS_DEVICE_MOVE 338 318 warnx(pThis->pCtx, "cannot move `%s' to a different device: `%s'", from, to); 339 319 return (1); … … 368 348 } 369 349 370 #if def CROSS_DEVICE_MOVE350 #if 0//def CROSS_DEVICE_MOVE 371 351 /* 372 352 * If rename fails because we're trying to cross devices, and … … 383 363 } 384 364 385 #if def CROSS_DEVICE_MOVE365 #if 0 //def CROSS_DEVICE_MOVE - using static buffers and fork. 386 366 int 387 367 static fastcopy(char *from, char *to, struct stat *sbp)
Note:
See TracChangeset
for help on using the changeset viewer.