Lines Matching refs:try
112 int (*callback)(struct dirtree *try);
126 static int cp_node(struct dirtree *try) in cp_node() argument
128 int fdout = -1, cfd = try->parent ? try->parent->extra : AT_FDCWD, in cp_node()
129 tfd = dirtree_parentfd(try); in cp_node()
131 char *catch = try->parent ? try->name : TT.destname, *err = "%s"; in cp_node()
134 if (!dirtree_notdotdot(try)) return 0; in cp_node()
137 if (S_ISDIR(try->st.st_mode) && try->again) { in cp_node()
138 fdout = try->extra; in cp_node()
143 if (S_ISLNK(try->st.st_mode) && (flags & FLAG_d)) flags |= FLAG_r; in cp_node()
147 if ((TT.top.st_dev == try->st.st_dev && TT.top.st_ino == try->st.st_ino in cp_node()
149 || (!fstatat(cfd, catch, &cst, 0) && cst.st_dev == try->st.st_dev in cp_node()
150 && cst.st_ino == try->st.st_ino)) in cp_node()
152 error_msg("'%s' is '%s'", catch, err = dirtree_path(try, 0)); in cp_node()
163 if (S_ISDIR(try->st.st_mode)) { in cp_node()
164 error_msg("dir at '%s'", s = dirtree_path(try, 0)); in cp_node()
173 s = dirtree_path(try, 0)); in cp_node()
180 char *s = dirtree_path(try, 0); in cp_node()
192 if (S_ISDIR(try->st.st_mode)) { in cp_node()
197 catch = try->name; in cp_node()
208 if (!mkdirat(cfd, catch, try->st.st_mode | 0200) || errno == EEXIST) in cp_node()
209 if (-1 != (try->extra = openat(cfd, catch, O_NOFOLLOW))) in cp_node()
210 if (!fstat(try->extra, &st2) && S_ISDIR(st2.st_mode)) in cp_node()
217 if (!linkat(tfd, try->name, cfd, catch, 0)) err = 0; in cp_node()
227 s = dirtree_path(try, 0); in cp_node()
228 for (or = try; or->parent; or = or->parent) dotdots++; in cp_node()
247 } else if (!S_ISREG(try->st.st_mode) in cp_node()
248 && (try->parent || (flags & (FLAG_a|FLAG_r)))) in cp_node()
253 if (S_ISLNK(try->st.st_mode) in cp_node()
254 ? ((i = readlinkat0(tfd, try->name, toybuf, sizeof(toybuf))) && in cp_node()
256 : !mknodat(cfd, catch, try->st.st_mode, try->st.st_rdev)) in cp_node()
266 fdin = openat(tfd, try->name, O_RDONLY); in cp_node()
268 catch = try->name; in cp_node()
271 fdout = openat(cfd, catch, O_RDWR|O_CREAT|O_TRUNC, try->st.st_mode); in cp_node()
318 rc = fchownat(cfd, catch, try->st.st_uid, try->st.st_gid, in cp_node()
320 else rc = fchown(fdout, try->st.st_uid, try->st.st_gid); in cp_node()
324 perror_msg("chown '%s'", pp = dirtree_path(try, 0)); in cp_node()
331 struct timespec times[] = {try->st.st_atim, try->st.st_mtim}; in cp_node()
339 if (TT.pflags & _CP_mode) fchmod(fdout, try->st.st_mode); in cp_node()
344 if (unlinkat(tfd, try->name, S_ISDIR(try->st.st_mode) ? AT_REMOVEDIR :0)) in cp_node()
351 if (catch == try->name) { in cp_node()
352 f = dirtree_path(try, 0); in cp_node()
353 while (try->parent) try = try->parent; in cp_node()
354 catch = xmprintf("%s%s", TT.destname, f+strlen(try->name)); in cp_node()
458 static int install_node(struct dirtree *try) in install_node() argument
460 try->st.st_mode = (TT.i.mode) in install_node()
461 ? string_to_mode(TT.i.mode, try->st.st_mode) : 0755; in install_node()
462 if (TT.i.group) try->st.st_gid = TT.gid; in install_node()
463 if (TT.i.user) try->st.st_uid = TT.uid; in install_node()
466 cp_node(try); in install_node()