Lines Matching refs:try

112   int (*callback)(struct dirtree *try);
126 static int cp_node(struct dirtree *try)
128 int fdout = -1, cfd = try->parent ? try->parent->extra : AT_FDCWD,
129 tfd = dirtree_parentfd(try);
131 char *catch = try->parent ? try->name : TT.destname, *err = "%s";
134 if (!dirtree_notdotdot(try)) return 0;
137 if (S_ISDIR(try->st.st_mode) && try->again) {
138 fdout = try->extra;
143 if (S_ISLNK(try->st.st_mode) && (flags & FLAG_d)) flags |= FLAG_r;
147 if ((TT.top.st_dev == try->st.st_dev && TT.top.st_ino == try->st.st_ino
149 || (!fstatat(cfd, catch, &cst, 0) && cst.st_dev == try->st.st_dev
150 && cst.st_ino == try->st.st_ino))
152 error_msg("'%s' is '%s'", catch, err = dirtree_path(try, 0));
163 if (S_ISDIR(try->st.st_mode)) {
164 error_msg("dir at '%s'", s = dirtree_path(try, 0));
173 s = dirtree_path(try, 0));
180 char *s = dirtree_path(try, 0);
192 if (S_ISDIR(try->st.st_mode)) {
197 catch = try->name;
208 if (!mkdirat(cfd, catch, try->st.st_mode | 0200) || errno == EEXIST)
209 if (-1 != (try->extra = openat(cfd, catch, O_NOFOLLOW)))
210 if (!fstat(try->extra, &st2) && S_ISDIR(st2.st_mode))
216 if (!linkat(tfd, try->name, cfd, catch, 0)) err = 0;
226 s = dirtree_path(try, 0);
227 for (or = try; or->parent; or = or->parent) dotdots++;
246 } else if (!S_ISREG(try->st.st_mode)
247 && (try->parent || (flags & (FLAG_a|FLAG_r))))
252 if (S_ISLNK(try->st.st_mode)
253 ? ((i = readlinkat0(tfd, try->name, toybuf, sizeof(toybuf))) &&
256 : !mknodat(cfd, catch, try->st.st_mode, try->st.st_rdev))
266 fdin = openat(tfd, try->name, O_RDONLY);
268 catch = try->name;
272 if (S_ISLNK(try->st.st_mode)) fstat(fdin, &try->st);
273 fdout = openat(cfd, catch, O_RDWR|O_CREAT|O_TRUNC, try->st.st_mode);
320 rc = fchownat(cfd, catch, try->st.st_uid, try->st.st_gid,
322 else rc = fchown(fdout, try->st.st_uid, try->st.st_gid);
326 perror_msg("chown '%s'", pp = dirtree_path(try, 0));
333 struct timespec times[] = {try->st.st_atim, try->st.st_mtim};
341 if (TT.pflags & _CP_mode) fchmod(fdout, try->st.st_mode);
346 if (unlinkat(tfd, try->name, S_ISDIR(try->st.st_mode) ? AT_REMOVEDIR :0))
353 if (catch == try->name) {
354 f = dirtree_path(try, 0);
355 while (try->parent) try = try->parent;
356 catch = xmprintf("%s%s", TT.destname, f+strlen(try->name));
443 // if -n and dest exists, don't try to rename() or copy
478 static int install_node(struct dirtree *try)
480 try->st.st_mode = TT.i.m ? string_to_mode(TT.i.m, try->st.st_mode) : 0755;
481 if (TT.i.g) try->st.st_gid = TT.gid;
482 if (TT.i.o) try->st.st_uid = TT.uid;
485 cp_node(try);