2 * (C) Copyright 10/12/86 by Carnegie Mellon University
6 * Revision 1.2 89/09/13 11:36:48
7 * Various fixes so it can compile under AIX.
9 * Revision 1.1 89/06/14 11:06:03
12 * Revision 1.3 88/07/28 13:41:05
13 * working simulation moved over to the beta cell
15 * Revision 1.2 88/02/26 05:07:56
16 * simulation of package with a yacc parser
18 * Revision 1.1 88/02/23 02:17:14
23 #include <afs/param.h>
24 #include <sys/param.h>
26 #include <sys/types.h>
39 #include <sys/fcntl.h>
50 loudonly_message("mv %s %s", from, to);
51 if (!opt_lazy && rename(from, to) < 0) {
52 #if defined(AFS_HPUX_ENV)
55 if (errno == ETXTBSY) {
56 (void)strcpy(pnameBusy, to);
57 (void)strcat(pnameBusy, ".BUSY");
58 if (rename(to, pnameBusy) == 0) {
59 if (rename(from, to) < 0) {
61 if (errno == ETXTBSY) {
62 message("rename %s %s; %m (ignored)", from, to);
65 message("rename %s %s; %m", from, to);
70 } else if (errno == ETXTBSY) {
71 message("rename %s %s; %m (ignored)", to, pnameBusy);
75 #endif /* AFS_HPUX_ENV */
76 message("rename %s %s; %m", from, to);
87 register struct dirent *de;
91 if (lstat(path, &stb) < 0) {
92 /* message("lstat %s; %m",path); */
96 if (opt_kflag && (stb.st_mode & 0222) == 0) {
97 loudonly_message("INHIBIT %s removal", path);
101 if ((stb.st_mode & S_IFMT) != S_IFDIR) {
102 loudonly_message("rm %s", path);
103 if (!opt_lazy && unlink(path) < 0) {
104 message("unlink %s; %m", path);
109 endp = path + strlen(path);
110 if ((dp = opendir(path)) == 0) {
111 message("opendir %s; %m", path);
115 while ((de = readdir(dp)) != 0) {
116 if (de->d_name[0] == '.') {
117 if (de->d_name[1] == 0)
119 if (de->d_name[1] == '.' && de->d_name[2] == 0)
122 (void)strcpy(endp, de->d_name);
127 loudonly_message("rmdir %s", path);
128 if (!opt_lazy && rmdir(path) < 0) {
129 message("rmdir %s; %m", path);
142 register int ffd, tfd, cc;
145 loudonly_message("cp %s %s", from, to);
148 if ((ffd = open(from, O_RDONLY)) < 0) {
149 message("open %s; %m", from);
152 if ((tfd = open(to, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0) {
153 message("open %s; %m", to);
158 if ((cc = read(ffd, buffer, sizeof(buffer))) < 0) {
159 message("read %s; %m", from);
166 if (cc != write(tfd, buffer, cc)) {
167 message("write %s; %m", to);
173 if (close(ffd) < 0) {
174 message("close %s; %m", from);
178 if (close(tfd) < 0) {
179 message("close %s; %m", to);
191 loudonly_message("ln %s %s", from, to);
192 if (!opt_lazy && link(from, to) < 0) {
193 message("ln %s %s; %m", from, to);
206 register char *u, *l, *endp;
210 loudonly_message("mklost+found %s", path);
213 endp = path + strlen(path);
216 for (u = "0123456789abcdef"; *u; u++) {
217 for (l = "0123456789abcdef"; *l; l++) {
220 f = open(path, O_CREAT | O_TRUNC | O_WRONLY, 0666);
222 message("open %s; %m", path);
228 for (u = "0123456789abcdef"; *u; u++) {
229 for (l = "0123456789abcdef"; *l; l++) {
232 if (lstat(path, &stb) >= 0)
233 if ((stb.st_mode & S_IFMT) != S_IFDIR)
234 if (unlink(path) < 0)
235 message("unlink %s; %m", path);