10 #define FATAL "install: fatal: "
14 void h(home,uid,gid,mode)
20 if (mkdir(home,0700) == -1)
21 if (errno != error_exist)
22 strerr_die4sys(111,FATAL,"unable to mkdir ",home,": ");
23 if (chown(home,uid,gid) == -1)
24 strerr_die4sys(111,FATAL,"unable to chown ",home,": ");
25 if (chmod(home,mode) == -1)
26 strerr_die4sys(111,FATAL,"unable to chmod ",home,": ");
29 void d(home,subdir,uid,gid,mode)
36 if (chdir(home) == -1)
37 strerr_die4sys(111,FATAL,"unable to switch to ",home,": ");
38 if (mkdir(subdir,0700) == -1)
39 if (errno != error_exist)
40 strerr_die6sys(111,FATAL,"unable to mkdir ",home,"/",subdir,": ");
41 if (chown(subdir,uid,gid) == -1)
42 strerr_die6sys(111,FATAL,"unable to chown ",home,"/",subdir,": ");
43 if (chmod(subdir,mode) == -1)
44 strerr_die6sys(111,FATAL,"unable to chmod ",home,"/",subdir,": ");
47 void p(home,fifo,uid,gid,mode)
54 if (chdir(home) == -1)
55 strerr_die4sys(111,FATAL,"unable to switch to ",home,": ");
56 if (fifo_make(fifo,0700) == -1)
57 if (errno != error_exist)
58 strerr_die6sys(111,FATAL,"unable to mkfifo ",home,"/",fifo,": ");
59 if (chown(fifo,uid,gid) == -1)
60 strerr_die6sys(111,FATAL,"unable to chown ",home,"/",fifo,": ");
61 if (chmod(fifo,mode) == -1)
62 strerr_die6sys(111,FATAL,"unable to chmod ",home,"/",fifo,": ");
65 char inbuf[SUBSTDIO_INSIZE];
66 char outbuf[SUBSTDIO_OUTSIZE];
70 void c(home,subdir,file,uid,gid,mode)
81 if (fchdir(fdsourcedir) == -1)
82 strerr_die2sys(111,FATAL,"unable to switch back to source directory: ");
84 fdin = open_read(file);
86 strerr_die4sys(111,FATAL,"unable to read ",file,": ");
87 substdio_fdbuf(&ssin,read,fdin,inbuf,sizeof inbuf);
89 if (chdir(home) == -1)
90 strerr_die4sys(111,FATAL,"unable to switch to ",home,": ");
91 if (chdir(subdir) == -1)
92 strerr_die6sys(111,FATAL,"unable to switch to ",home,"/",subdir,": ");
94 fdout = open_trunc(file);
96 strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": ");
97 substdio_fdbuf(&ssout,write,fdout,outbuf,sizeof outbuf);
99 switch(substdio_copy(&ssout,&ssin)) {
101 strerr_die4sys(111,FATAL,"unable to read ",file,": ");
103 strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": ");
107 if (substdio_flush(&ssout) == -1)
108 strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": ");
109 if (fsync(fdout) == -1)
110 strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": ");
111 if (close(fdout) == -1) /* NFS silliness */
112 strerr_die6sys(111,FATAL,"unable to write .../",subdir,"/",file,": ");
114 if (chown(file,uid,gid) == -1)
115 strerr_die6sys(111,FATAL,"unable to chown .../",subdir,"/",file,": ");
116 if (chmod(file,mode) == -1)
117 strerr_die6sys(111,FATAL,"unable to chmod .../",subdir,"/",file,": ");
120 void z(home,file,len,uid,gid,mode)
130 if (chdir(home) == -1)
131 strerr_die4sys(111,FATAL,"unable to switch to ",home,": ");
133 fdout = open_trunc(file);
135 strerr_die6sys(111,FATAL,"unable to write ",home,"/",file,": ");
136 substdio_fdbuf(&ssout,write,fdout,outbuf,sizeof outbuf);
139 if (substdio_put(&ssout,"",1) == -1)
140 strerr_die6sys(111,FATAL,"unable to write ",home,"/",file,": ");
142 if (substdio_flush(&ssout) == -1)
143 strerr_die6sys(111,FATAL,"unable to write ",home,"/",file,": ");
144 if (fsync(fdout) == -1)
145 strerr_die6sys(111,FATAL,"unable to write ",home,"/",file,": ");
146 if (close(fdout) == -1) /* NFS silliness */
147 strerr_die6sys(111,FATAL,"unable to write ",home,"/",file,": ");
149 if (chown(file,uid,gid) == -1)
150 strerr_die6sys(111,FATAL,"unable to chown ",home,"/",file,": ");
151 if (chmod(file,mode) == -1)
152 strerr_die6sys(111,FATAL,"unable to chmod ",home,"/",file,": ");
162 fdsourcedir = open_read(".");
163 if (fdsourcedir == -1)
164 strerr_die2sys(111,FATAL,"unable to open current directory: ");