Lines Matching defs:toname
192 char *linkprefix, *owner, *group, *cp, *cwd, *todir, *toname, *name, *base, *linkname, *bp, buf[BUFSIZ];
283 toname = (char*)xmalloc(tdlen + 1 + bnlen + 1);
284 sprintf(toname, "%s/%s", todir, base);
285 exists = (lstat(toname, &tosb) == 0);
290 (void) unlink(toname);
293 if (!exists && mkdir(toname, mode) < 0)
294 fail("cannot make directory %s", toname);
295 if ((owner || group) && chown(toname, uid, gid) < 0)
296 fail("cannot change owner of %s", toname);
329 readlink(toname, buf, sizeof buf) != len ||
331 (void) (S_ISDIR(tosb.st_mode) ? rmdir : unlink)(toname);
334 if (!exists && symlink(name, toname) < 0)
335 fail("cannot make symbolic link %s", toname);
337 if ((owner || group) && lchown(toname, uid, gid) < 0)
338 fail("cannot change owner of %s", toname);
346 /* Copy from name to toname, which might be the same file. */
350 if (exists && (!S_ISREG(tosb.st_mode) || access(toname, W_OK) < 0))
351 (void) (S_ISDIR(tosb.st_mode) ? rmdir : unlink)(toname);
352 tofd = open(toname, O_CREAT | O_WRONLY, 0666);
354 fail("cannot create %s", toname);
364 fail("cannot write to %s", toname);
370 fail("cannot truncate %s", toname);
379 if (utime(toname, &utb) < 0)
380 fail("cannot set times of %s", toname);
385 if (chmod(toname, mode) < 0)
387 fail("cannot change mode of %s", toname);
390 fail("cannot change owner of %s", toname);
394 fail("cannot write to %s", toname);
397 if (chmod(toname, mode) < 0)
398 fail("cannot change mode of %s", toname);
402 if (utime(toname, &utb) < 0)
403 fail("cannot set times of %s", toname);
408 free(toname);