Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Creating branch before_newconf

  • Loading branch information...
commit a2bbf881d563d68d2b655de3810e64df92c7bd39 1 parent 2127fd0
cvs authored
Showing with 0 additions and 36,584 deletions.
  1. +0 −35 Makefile
  2. +0 −7 bin/Makefile
  3. +0 −5 bin/Makefile.inc
  4. +0 −6 bin/cat/Makefile
  5. +0 −122 bin/cat/cat.1
  6. +0 −256 bin/cat/cat.c
  7. +0 −6 bin/chmod/Makefile
  8. +0 −296 bin/chmod/chmod.1
  9. +0 −203 bin/chmod/chmod.c
  10. +0 −7 bin/cp/Makefile
  11. +0 −212 bin/cp/cp.1
  12. +0 −449 bin/cp/cp.c
  13. +0 −56 bin/cp/extern.h
  14. +0 −286 bin/cp/utils.c
  15. +0 −45 bin/csh/Makefile
  16. +0 −8 bin/csh/USD.doc/Makefile
  17. +0 −1,013 bin/csh/USD.doc/csh.1
  18. +0 −1,306 bin/csh/USD.doc/csh.2
  19. +0 −651 bin/csh/USD.doc/csh.3
  20. +0 −179 bin/csh/USD.doc/csh.4
  21. +0 −96 bin/csh/USD.doc/csh.a
  22. +0 −1,722 bin/csh/USD.doc/csh.g
  23. +0 −35 bin/csh/USD.doc/tabs
  24. +0 −125 bin/csh/alloc.c
  25. +0 −312 bin/csh/char.c
  26. +0 −97 bin/csh/char.h
  27. +0 −161 bin/csh/const.c
  28. +0 −2,176 bin/csh/csh.1
  29. +0 −1,353 bin/csh/csh.c
  30. +0 −553 bin/csh/csh.h
  31. +0 −931 bin/csh/dir.c
  32. +0 −46 bin/csh/dir.h
  33. +0 −979 bin/csh/dol.c
  34. +0 −408 bin/csh/err.c
  35. +0 −737 bin/csh/exec.c
  36. +0 −712 bin/csh/exp.c
  37. +0 −339 bin/csh/extern.h
  38. +0 −685 bin/csh/file.c
  39. +0 −1,499 bin/csh/func.c
  40. +0 −940 bin/csh/glob.c
  41. +0 −185 bin/csh/hist.c
  42. +0 −135 bin/csh/init.c
  43. +0 −1,640 bin/csh/lex.c
  44. +0 −421 bin/csh/misc.c
  45. +0 −699 bin/csh/parse.c
  46. +0 −42 bin/csh/pathnames.h
  47. +0 −410 bin/csh/printf.c
  48. +0 −1,357 bin/csh/proc.c
  49. +0 −102 bin/csh/proc.h
  50. +0 −646 bin/csh/sem.c
  51. +0 −845 bin/csh/set.c
  52. +0 −468 bin/csh/str.c
  53. +0 −317 bin/csh/time.c
  54. +0 −9 bin/date/Makefile
  55. +0 −231 bin/date/date.1
  56. +0 −241 bin/date/date.c
  57. +0 −37 bin/date/extern.h
  58. +0 −184 bin/date/netdate.c
  59. +0 −7 bin/dd/Makefile
  60. +0 −387 bin/dd/args.c
  61. +0 −261 bin/dd/conv.c
  62. +0 −358 bin/dd/conv_tab.c
  63. +0 −349 bin/dd/dd.1
  64. +0 −396 bin/dd/dd.c
  65. +0 −97 bin/dd/dd.h
  66. +0 −66 bin/dd/extern.h
  67. +0 −101 bin/dd/misc.c
  68. +0 −167 bin/dd/position.c
  69. +0 −8 bin/df/Makefile
  70. +0 −104 bin/df/df.1
  71. +0 −327 bin/df/df.c
  72. +0 −6 bin/domainname/Makefile
  73. +0 −66 bin/domainname/domainname.1
  74. +0 −92 bin/domainname/domainname.c
  75. +0 −6 bin/echo/Makefile
  76. +0 −71 bin/echo/echo.1
  77. +0 −72 bin/echo/echo.c
  78. +0 −11 bin/ed/Makefile
  79. +0 −101 bin/ed/POSIX
  80. +0 −22 bin/ed/README
  81. +0 −286 bin/ed/buf.c
  82. +0 −421 bin/ed/cbc.c
  83. +0 −1,000 bin/ed/ed.1
  84. +0 −295 bin/ed/ed.h
  85. +0 −223 bin/ed/glbl.c
  86. +0 −375 bin/ed/io.c
  87. +0 −1,432 bin/ed/main.c
  88. +0 −132 bin/ed/re.c
  89. +0 −263 bin/ed/sub.c
  90. +0 −1  bin/ed/test/=.err
  91. +0 −23 bin/ed/test/Makefile
  92. +0 −30 bin/ed/test/README
  93. +0 −15 bin/ed/test/TODO
  94. +0 −5 bin/ed/test/a.d
  95. +0 −8 bin/ed/test/a.r
  96. +0 −9 bin/ed/test/a.t
  97. +0 −3  bin/ed/test/a1.err
  98. +0 −3  bin/ed/test/a2.err
  99. +0 −9 bin/ed/test/addr.d
  100. +0 −2  bin/ed/test/addr.r
  101. +0 −5 bin/ed/test/addr.t
  102. +0 −1  bin/ed/test/addr1.err
  103. +0 −1  bin/ed/test/addr2.err
  104. BIN  bin/ed/test/ascii.d
  105. BIN  bin/ed/test/ascii.r
  106. 0  bin/ed/test/ascii.t
  107. 0  bin/ed/test/bang1.d
  108. +0 −1  bin/ed/test/bang1.err
  109. +0 −1  bin/ed/test/bang1.r
  110. +0 −5 bin/ed/test/bang1.t
  111. +0 −1  bin/ed/test/bang2.err
  112. +0 −5 bin/ed/test/c.d
  113. +0 −4 bin/ed/test/c.r
  114. +0 −12 bin/ed/test/c.t
  115. +0 −3  bin/ed/test/c1.err
  116. +0 −3  bin/ed/test/c2.err
  117. +0 −35 bin/ed/test/ckscripts.sh
  118. +0 −5 bin/ed/test/d.d
  119. +0 −1  bin/ed/test/d.err
  120. +0 −1  bin/ed/test/d.r
  121. +0 −3  bin/ed/test/d.t
  122. +0 −1  bin/ed/test/e1.d
  123. +0 −1  bin/ed/test/e1.err
  124. +0 −1  bin/ed/test/e1.r
  125. +0 −1  bin/ed/test/e1.t
  126. +0 −1  bin/ed/test/e2.d
  127. +0 −1  bin/ed/test/e2.err
  128. +0 −1  bin/ed/test/e2.r
  129. +0 −1  bin/ed/test/e2.t
  130. +0 −1  bin/ed/test/e3.d
  131. +0 −6 bin/ed/test/e3.ed
  132. +0 −1  bin/ed/test/e3.err
  133. +0 −1  bin/ed/test/e3.o
  134. +0 −1  bin/ed/test/e3.r
  135. +0 −1  bin/ed/test/e3.t
  136. +0 −1  bin/ed/test/e4.d
  137. +0 −1  bin/ed/test/e4.r
  138. +0 −1  bin/ed/test/e4.t
  139. +0 −1  bin/ed/test/f1.err
  140. +0 −1  bin/ed/test/f2.err
  141. +0 −5 bin/ed/test/g1.d
  142. +0 −11 bin/ed/test/g1.ed
  143. +0 −1  bin/ed/test/g1.err
  144. +0 −15 bin/ed/test/g1.o
  145. +0 −15 bin/ed/test/g1.r
  146. +0 −6 bin/ed/test/g1.t
  147. +0 −5 bin/ed/test/g2.d
  148. +0 −7 bin/ed/test/g2.ed
  149. +0 −1  bin/ed/test/g2.err
  150. +0 −1  bin/ed/test/g2.o
  151. +0 −1  bin/ed/test/g2.r
  152. +0 −2  bin/ed/test/g2.t
  153. +0 −5 bin/ed/test/g3.d
  154. +0 −1  bin/ed/test/g3.err
  155. +0 −5 bin/ed/test/g3.r
  156. +0 −4 bin/ed/test/g3.t
  157. +0 −5 bin/ed/test/g4.d
  158. +0 −7 bin/ed/test/g4.r
  159. +0 −13 bin/ed/test/g4.t
  160. +0 −3  bin/ed/test/g5.d
  161. +0 −9 bin/ed/test/g5.r
  162. +0 −2  bin/ed/test/g5.t
  163. +0 −1  bin/ed/test/h.err
  164. +0 −5 bin/ed/test/i.d
  165. +0 −14 bin/ed/test/i.ed
  166. +0 −8 bin/ed/test/i.o
  167. +0 −8 bin/ed/test/i.r
  168. +0 −9 bin/ed/test/i.t
  169. +0 −3  bin/ed/test/i1.err
  170. +0 −3  bin/ed/test/i2.err
  171. +0 −3  bin/ed/test/i3.err
  172. +0 −5 bin/ed/test/j.d
  173. +0 −7 bin/ed/test/j.ed
  174. +0 −4 bin/ed/test/j.o
  175. +0 −4 bin/ed/test/j.r
  176. +0 −2  bin/ed/test/j.t
  177. +0 −5 bin/ed/test/k.d
  178. +0 −5 bin/ed/test/k.r
  179. +0 −10 bin/ed/test/k.t
  180. +0 −1  bin/ed/test/k1.err
  181. +0 −1  bin/ed/test/k2.err
  182. +0 −1  bin/ed/test/k3.err
  183. +0 −6 bin/ed/test/k4.err
  184. 0  bin/ed/test/l.d
  185. +0 −5 bin/ed/test/l.ed
  186. 0  bin/ed/test/l.o
  187. 0  bin/ed/test/l.r
  188. 0  bin/ed/test/l.t
  189. +0 −5 bin/ed/test/m.d
  190. +0 −12 bin/ed/test/m.ed
  191. +0 −4 bin/ed/test/m.err
  192. +0 −5 bin/ed/test/m.o
  193. +0 −5 bin/ed/test/m.r
  194. +0 −7 bin/ed/test/m.t
  195. +0 −73 bin/ed/test/mkscripts.sh
  196. 0  bin/ed/test/n.d
  197. +0 −5 bin/ed/test/n.ed
  198. 0  bin/ed/test/n.o
  199. 0  bin/ed/test/n.r
  200. 0  bin/ed/test/n.t
  201. +0 −1  bin/ed/test/nl.err
  202. +0 −8 bin/ed/test/nl.r
  203. +0 −8 bin/ed/test/nl.t
  204. +0 −5 bin/ed/test/nl1.d
  205. +0 −8 bin/ed/test/nl1.r
  206. +0 −8 bin/ed/test/nl1.t
  207. +0 −5 bin/ed/test/nl2.d
  208. +0 −6 bin/ed/test/nl2.r
  209. +0 −4 bin/ed/test/nl2.t
  210. 0  bin/ed/test/p.d
  211. +0 −5 bin/ed/test/p.ed
  212. 0  bin/ed/test/p.o
  213. 0  bin/ed/test/p.r
  214. 0  bin/ed/test/p.t
  215. 0  bin/ed/test/q.d
  216. 0  bin/ed/test/q.r
  217. +0 −5 bin/ed/test/q.t
  218. +0 −1  bin/ed/test/q1.err
  219. +0 −5 bin/ed/test/r1.d
  220. +0 −8 bin/ed/test/r1.ed
  221. +0 −1  bin/ed/test/r1.err
  222. +0 −7 bin/ed/test/r1.o
  223. +0 −7 bin/ed/test/r1.r
  224. +0 −3  bin/ed/test/r1.t
  225. +0 −5 bin/ed/test/r2.d
  226. +0 −6 bin/ed/test/r2.ed
  227. +0 −1  bin/ed/test/r2.err
  228. +0 −10 bin/ed/test/r2.o
  229. +0 −10 bin/ed/test/r2.r
  230. +0 −1  bin/ed/test/r2.t
  231. +0 −1  bin/ed/test/r3.d
  232. +0 −6 bin/ed/test/r3.ed
  233. +0 −2  bin/ed/test/r3.o
  234. +0 −2  bin/ed/test/r3.r
  235. +0 −1  bin/ed/test/r3.t
  236. +0 −5 bin/ed/test/s1.d
  237. +0 −11 bin/ed/test/s1.ed
  238. +0 −1  bin/ed/test/s1.err
  239. +0 −5 bin/ed/test/s1.o
  240. +0 −5 bin/ed/test/s1.r
  241. +0 −6 bin/ed/test/s1.t
  242. +0 −4 bin/ed/test/s10.err
  243. +0 −5 bin/ed/test/s2.d
  244. +0 −9 bin/ed/test/s2.ed
  245. +0 −4 bin/ed/test/s2.err
  246. +0 −5 bin/ed/test/s2.o
  247. +0 −5 bin/ed/test/s2.r
  248. +0 −4 bin/ed/test/s2.t
  249. 0  bin/ed/test/s3.d
  250. +0 −1  bin/ed/test/s3.err
  251. +0 −1  bin/ed/test/s3.r
  252. +0 −6 bin/ed/test/s3.t
  253. +0 −1  bin/ed/test/s4.err
  254. +0 −1  bin/ed/test/s5.err
  255. +0 −1  bin/ed/test/s6.err
  256. +0 −5 bin/ed/test/s7.err
  257. +0 −4 bin/ed/test/s8.err
  258. +0 −4 bin/ed/test/s9.err
  259. +0 −5 bin/ed/test/t.d
  260. +0 −8 bin/ed/test/t.ed
  261. +0 −16 bin/ed/test/t.o
  262. +0 −16 bin/ed/test/t.r
  263. +0 −3  bin/ed/test/t.t
  264. +0 −5 bin/ed/test/t1.d
  265. +0 −1  bin/ed/test/t1.err
  266. +0 −16 bin/ed/test/t1.r
  267. +0 −3  bin/ed/test/t1.t
  268. +0 −5 bin/ed/test/t2.d
  269. +0 −1  bin/ed/test/t2.err
  270. +0 −6 bin/ed/test/t2.r
  271. +0 −1  bin/ed/test/t2.t
  272. +0 −5 bin/ed/test/u.d
  273. +0 −36 bin/ed/test/u.ed
  274. +0 −1  bin/ed/test/u.err
  275. +0 −9 bin/ed/test/u.o
  276. +0 −9 bin/ed/test/u.r
  277. +0 −31 bin/ed/test/u.t
  278. +0 −5 bin/ed/test/v.d
  279. +0 −11 bin/ed/test/v.ed
  280. +0 −11 bin/ed/test/v.o
  281. +0 −11 bin/ed/test/v.r
  282. +0 −6 bin/ed/test/v.t
  283. +0 −5 bin/ed/test/w.d
  284. +0 −7 bin/ed/test/w.ed
  285. +0 −10 bin/ed/test/w.o
  286. +0 −10 bin/ed/test/w.r
  287. +0 −2  bin/ed/test/w.t
  288. +0 −1  bin/ed/test/w1.err
  289. +0 −1  bin/ed/test/w2.err
  290. +0 −1  bin/ed/test/w3.err
  291. +0 −1  bin/ed/test/x.err
  292. +0 −2  bin/ed/test/z.err
  293. +0 −154 bin/ed/undo.c
  294. +0 −6 bin/expr/Makefile
  295. +0 −2  bin/expr/TODO
  296. +0 −132 bin/expr/expr.1
  297. +0 −530 bin/expr/expr.c
  298. +0 −6 bin/hostname/Makefile
  299. +0 −68 bin/hostname/hostname.1
  300. +0 −98 bin/hostname/hostname.c
Sorry, we could not display the entire diff because too many files (13,309) changed.
View
35 Makefile
@@ -1,35 +0,0 @@
-# $Id: Makefile,v 1.19 1994/06/14 04:40:29 cgd Exp $
-
-# NOTE THAT etc *DOES NOT* BELONG IN THE LIST BELOW
-
-SUBDIR+= lib include bin libexec sbin usr.bin usr.sbin share games
-SUBDIR+= gnu
-
-SUBDIR+= sys
-
-.if exists(regress)
-.ifmake !(install)
-SUBDIR+= regress
-.endif
-
-regression-tests:
- @echo Running regression tests...
- @(cd regress && ${MAKE} regress)
-.endif
-
-afterinstall:
-.ifndef NOMAN
- (cd share/man && ${MAKE} makedb)
-.endif
-
-build:
- (cd include && ${MAKE} install)
- ${MAKE} cleandir
- (cd lib && ${MAKE} depend && ${MAKE} && ${MAKE} install)
- (cd gnu/lib && ${MAKE} depend && ${MAKE} && ${MAKE} install)
-.if exists(kerberosIV)
- (cd kerberosIV && ${MAKE} depend && ${MAKE} && ${MAKE} install)
-.endif
- ${MAKE} depend && ${MAKE} && ${MAKE} install
-
-.include <bsd.subdir.mk>
View
7 bin/Makefile
@@ -1,7 +0,0 @@
-# from: @(#)Makefile 5.33.1.1 (Berkeley) 5/6/91
-# $Id: Makefile,v 1.11 1994/06/13 16:48:41 jtc Exp $
-
-SUBDIR= cat chmod cp csh date dd df domainname echo ed expr hostname kill ln \
- ls mkdir mt mv pax ps pwd rcp rm rmail rmdir sh sleep stty sync test
-
-.include <bsd.subdir.mk>
View
5 bin/Makefile.inc
@@ -1,5 +0,0 @@
-# from: @(#)Makefile.inc 5.1 (Berkeley) 5/11/90
-# $Id: Makefile.inc,v 1.6 1993/11/08 02:34:22 cgd Exp $
-
-BINDIR?= /bin
-LDSTATIC= -static
View
6 bin/cat/Makefile
@@ -1,6 +0,0 @@
-# from: @(#)Makefile 8.1 (Berkeley) 5/31/93
-# $Id: Makefile,v 1.5 1994/09/20 01:24:07 mycroft Exp $
-
-PROG= cat
-
-.include <bsd.prog.mk>
View
122 bin/cat/cat.1
@@ -1,122 +0,0 @@
-.\" Copyright (c) 1989, 1990, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" This code is derived from software contributed to Berkeley by
-.\" the Institute of Electrical and Electronics Engineers, Inc.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" from: @(#)cat.1 8.1 (Berkeley) 6/29/93
-.\" $Id: cat.1,v 1.7 1994/09/20 01:24:10 mycroft Exp $
-.\"
-.Dd June 29, 1993
-.Dt CAT 1
-.Os BSD 3
-.Sh NAME
-.Nm cat
-.Nd concatenate and print files
-.Sh SYNOPSIS
-.Nm cat
-.Op Fl benstuv
-.Op Fl
-.Op Ar
-.Sh DESCRIPTION
-The
-.Nm cat
-utility reads files sequentially, writing them to the standard output.
-The
-.Ar file
-operands are processed in command line order.
-A single dash represents the standard input.
-.Pp
-The options are as follows:
-.Bl -tag -width Ds
-.It Fl b
-Implies the
-.Fl n
-option but doesn't number blank lines.
-.It Fl e
-Implies the
-.Fl v
-option, and displays a dollar sign
-.Pq Ql \&$
-at the end of each line
-as well.
-.It Fl n
-Number the
-.Ar output
-lines, starting at 1.
-.It Fl s
-Squeeze multiple adjacent empty lines, causing the output to be
-single spaced.
-.It Fl t
-Implies the
-.Fl v
-option, and displays tab characters as
-.Pq Ql ^I
-as well.
-.It Fl u
-The
-.Fl u
-option guarantees that the output is unbuffered.
-.It Fl v
-Displays non-printing characters so they are visible.
-Control characters print as
-.Ql ^X
-for control-X; the delete
-character (octal 0177) prints as
-.Ql ^?
-Non-ascii characters (with the high bit set) are printed as
-.Ql M-
-(for meta) followed by the character for the low 7 bits.
-.El
-.Pp
-The
-.Nm cat
-utility exits 0 on success, and >0 if an error occurs.
-.Sh BUGS
-Because of the shell language mechanism used to perform output
-redirection, the command
-.Dq Li cat file1 file 2 > file1
-will cause the original data in file1 to be destroyed!
-.Sh SEE ALSO
-.Xr head 1 ,
-.Xr more 1 ,
-.Xr pr 1 ,
-.Xr tail 1
-.Rs
-.%A Rob Pike
-.%T "UNIX Style, or cat -v Considered Harmful"
-.%J "USENIX Summer Conference Proceedings"
-.%D 1983
-.Re
-.Sh HISTORY
-A
-.Nm
-command appeared in Version 6 AT&T UNIX.
View
256 bin/cat/cat.c
@@ -1,256 +0,0 @@
-/*
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Kevin Fall.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char copyright[] =
-"@(#) Copyright (c) 1989, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-/*static char sccsid[] = "from: @(#)cat.c 8.1 (Berkeley) 7/19/93";*/
-static char *rcsid = "$Id: cat.c,v 1.9 1994/09/20 01:24:11 mycroft Exp $";
-#endif /* not lint */
-
-#include <sys/param.h>
-#include <sys/stat.h>
-
-#include <locale.h>
-#include <ctype.h>
-#include <err.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-int bflag, eflag, nflag, sflag, tflag, vflag;
-int rval;
-char *filename;
-
-void cook_args __P((char *argv[]));
-void cook_buf __P((FILE *));
-void raw_args __P((char *argv[]));
-void raw_cat __P((int));
-
-int
-main(argc, argv)
- int argc;
- char *argv[];
-{
- extern int optind;
- int ch;
-
- setlocale(LC_ALL, "");
-
- while ((ch = getopt(argc, argv, "benstuv")) != -1)
- switch (ch) {
- case 'b':
- bflag = nflag = 1; /* -b implies -n */
- break;
- case 'e':
- eflag = vflag = 1; /* -e implies -v */
- break;
- case 'n':
- nflag = 1;
- break;
- case 's':
- sflag = 1;
- break;
- case 't':
- tflag = vflag = 1; /* -t implies -v */
- break;
- case 'u':
- setbuf(stdout, (char *)NULL);
- break;
- case 'v':
- vflag = 1;
- break;
- default:
- case '?':
- (void)fprintf(stderr,
- "usage: cat [-benstuv] [-] [file ...]\n");
- exit(1);
- }
- argv += optind;
-
- if (bflag || eflag || nflag || sflag || tflag || vflag)
- cook_args(argv);
- else
- raw_args(argv);
- if (fclose(stdout))
- err(1, "stdout");
- exit(rval);
-}
-
-void
-cook_args(argv)
- char **argv;
-{
- register FILE *fp;
-
- fp = stdin;
- filename = "stdin";
- do {
- if (*argv) {
- if (!strcmp(*argv, "-"))
- fp = stdin;
- else if ((fp = fopen(*argv, "r")) == NULL) {
- warn("%s", *argv);
- ++argv;
- continue;
- }
- filename = *argv++;
- }
- cook_buf(fp);
- if (fp != stdin)
- (void)fclose(fp);
- } while (*argv);
-}
-
-void
-cook_buf(fp)
- register FILE *fp;
-{
- register int ch, gobble, line, prev;
-
- line = gobble = 0;
- for (prev = '\n'; (ch = getc(fp)) != EOF; prev = ch) {
- if (prev == '\n') {
- if (ch == '\n') {
- if (sflag) {
- if (!gobble && putchar(ch) == EOF)
- break;
- gobble = 1;
- continue;
- }
- if (nflag && !bflag) {
- (void)fprintf(stdout, "%6d\t", ++line);
- if (ferror(stdout))
- break;
- }
- } else if (nflag) {
- (void)fprintf(stdout, "%6d\t", ++line);
- if (ferror(stdout))
- break;
- }
- }
- gobble = 0;
- if (ch == '\n') {
- if (eflag)
- if (putchar('$') == EOF)
- break;
- } else if (ch == '\t') {
- if (tflag) {
- if (putchar('^') == EOF || putchar('I') == EOF)
- break;
- continue;
- }
- } else if (vflag) {
- if (!isascii(ch)) {
- if (putchar('M') == EOF || putchar('-') == EOF)
- break;
- ch = toascii(ch);
- }
- if (iscntrl(ch)) {
- if (putchar('^') == EOF ||
- putchar(ch == '\177' ? '?' :
- ch | 0100) == EOF)
- break;
- continue;
- }
- }
- if (putchar(ch) == EOF)
- break;
- }
- if (ferror(fp)) {
- warn("%s", filename);
- clearerr(fp);
- }
- if (ferror(stdout))
- err(1, "stdout");
-}
-
-void
-raw_args(argv)
- char **argv;
-{
- register int fd;
-
- fd = fileno(stdin);
- filename = "stdin";
- do {
- if (*argv) {
- if (!strcmp(*argv, "-"))
- fd = fileno(stdin);
- else if ((fd = open(*argv, O_RDONLY, 0)) < 0) {
- warn("%s", *argv);
- ++argv;
- continue;
- }
- filename = *argv++;
- }
- raw_cat(fd);
- if (fd != fileno(stdin))
- (void)close(fd);
- } while (*argv);
-}
-
-void
-raw_cat(rfd)
- register int rfd;
-{
- register int nr, nw, off, wfd;
- static int bsize;
- static char *buf;
- struct stat sbuf;
-
- wfd = fileno(stdout);
- if (buf == NULL) {
- if (fstat(wfd, &sbuf))
- err(1, "%s", filename);
- bsize = MAX(sbuf.st_blksize, 1024);
- if ((buf = malloc((u_int)bsize)) == NULL)
- err(1, NULL);
- }
- while ((nr = read(rfd, buf, bsize)) > 0)
- for (off = 0; nr; nr -= nw, off += nw)
- if ((nw = write(wfd, buf + off, nr)) < 0)
- err(1, "stdout");
- if (nr < 0)
- warn("%s", filename);
-}
View
6 bin/chmod/Makefile
@@ -1,6 +0,0 @@
-# from: @(#)Makefile 8.1 (Berkeley) 5/31/93
-# $Id: Makefile,v 1.5 1994/09/20 04:07:01 mycroft Exp $
-
-PROG= chmod
-
-.include <bsd.prog.mk>
View
296 bin/chmod/chmod.1
@@ -1,296 +0,0 @@
-.\" Copyright (c) 1989, 1990, 1993, 1994
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" This code is derived from software contributed to Berkeley by
-.\" the Institute of Electrical and Electronics Engineers, Inc.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" from: @(#)chmod.1 8.4 (Berkeley) 3/31/94
-.\" $Id: chmod.1,v 1.7 1994/09/20 04:07:03 mycroft Exp $
-.\"
-.Dd March 31, 1994
-.Dt CHMOD 1
-.Os
-.Sh NAME
-.Nm chmod
-.Nd change file modes
-.Sh SYNOPSIS
-.Nm chmod
-.Oo
-.Fl R
-.Op Fl H | Fl L | Fl P
-.Oc
-.Ar mode
-.Ar file ...
-.Sh DESCRIPTION
-The
-.Nm chmod
-utility modifies the file mode bits of the listed files
-as specified by the
-.Ar mode
-operand.
-.Pp
-The options are as follows:
-.Bl -tag -width Ds
-.It Fl H
-If the
-.Fl R
-option is specified, symbolic links on the command line are followed.
-(Symbolic links encountered in the tree traversal are not followed.)
-.It Fl L
-If the
-.Fl R
-option is specified, all symbolic links are followed.
-.It Fl P
-If the
-.Fl R
-option is specified, no symbolic links are followed.
-.It Fl R
-Change the modes of the file hierarchies rooted in the files
-instead of just the files themselves.
-.El
-.Pp
-Symbolic links do not have modes, so unless the
-.Fl H
-or
-.Fl L
-option is set,
-.Nm chmod
-on a symbolic link always succeeds and has no effect.
-The
-.Fl H ,
-.Fl L
-and
-.Fl P
-options are ignored unless the
-.Fl R
-option is specified.
-In addition, these options override each other and the
-command's actions are determined by the last one specified.
-.Pp
-Only the owner of a file or the super-user is permitted to change
-the mode of a file.
-.Pp
-The
-.Nm chmod
-utility exits 0 on success, and >0 if an error occurs.
-.Sh MODES
-Modes may be absolute or symbolic.
-An absolute mode is an octal number constructed by
-.Ar or-ing
-the following values:
-.Pp
-.Bl -tag -width 6n -compact -offset indent
-.It Li 4000
-set-user-ID-on-execution
-.It Li 2000
-set-group-ID-on-execution
-.It Li 1000
-sticky bit, see chmod(2)
-.It Li 0400
-read by owner
-.It Li 0200
-write by owner
-.It Li 0100
-execute (or search for directories) by owner
-.It Li 0070
-read, write, execute/search by group
-.It Li 0007
-read, write, execute/search by others
-.El
-.Pp
-The read, write, and execute/search values for group and others
-are encoded as described for owner.
-.Pp
-The symbolic mode is described by the following grammar:
-.Bd -literal -offset indent
-mode ::= clause [, clause ...]
-clause ::= [who ...] [action ...] last_action
-action ::= op [perm ...]
-last_action ::= op [perm ...]
-who ::= a | u | g | o
-op ::= + | \- | =
-perm ::= r | s | t | w | x | X | u | g | o
-.Ed
-.Pp
-The
-.Ar who
-symbols ``u'', ``g'', and ``o'' specify the user, group, and other parts
-of the mode bits, respectively.
-The
-.Ar who
-symbol ``a'' is equivalent to ``ugo''.
-.Pp
-.ne 1i
-The
-.Ar perm
-symbols represent the portions of the mode bits as follows:
-.Pp
-.Bl -tag -width Ds -compact -offset indent
-.It r
-The read bits.
-.It s
-The set-user-ID-on-execution and set-group-ID-on-execution bits.
-.It t
-The sticky bit.
-.It w
-The write bits.
-.It x
-The execute/search bits.
-.It X
-The execute/search bits if the file is a directory or any of the
-execute/search bits are set in the original (unmodified) mode.
-Operations with the
-.Ar perm
-symbol ``X'' are only meaningful in conjunction with the
-.Ar op
-symbol ``+'', and are ignored in all other cases.
-.It u
-The user permission bits in the mode of the original file.
-.It g
-The group permission bits in the mode of the original file.
-.It o
-The other permission bits in the mode of the original file.
-.El
-.Pp
-The
-.Ar op
-symbols represent the operation performed, as follows:
-.Bl -tag -width 4n
-.It +
-If no value is supplied for
-.Ar perm ,
-the ``+'' operation has no effect.
-If no value is supplied for
-.Ar who ,
-each permission bit specified in
-.Ar perm ,
-for which the corresponding bit in the file mode creation mask
-is clear, is set.
-Otherwise, the mode bits represented by the specified
-.Ar who
-and
-.Ar perm
-values are set.
-.It \&\-
-If no value is supplied for
-.Ar perm ,
-the ``\-'' operation has no effect.
-If no value is supplied for
-.Ar who ,
-each permission bit specified in
-.Ar perm ,
-for which the corresponding bit in the file mode creation mask
-is clear, is cleared.
-Otherwise, the mode bits represented by the specified
-.Ar who
-and
-.Ar perm
-values are cleared.
-.It =
-The mode bits specified by the
-.Ar who
-value are cleared, or, if no who value is specified, the owner, group
-and other mode bits are cleared.
-Then, if no value is supplied for
-.Ar who ,
-each permission bit specified in
-.Ar perm ,
-for which the corresponding bit in the file mode creation mask
-is clear, is set.
-Otherwise, the mode bits represented by the specified
-.Ar who
-and
-.Ar perm
-values are set.
-.El
-.Pp
-Each
-.Ar clause
-specifies one or more operations to be performed on the mode
-bits, and each operation is applied to the mode bits in the
-order specified.
-.Pp
-Operations upon the other permissions only (specified by the symbol
-``o'' by itself), in combination with the
-.Ar perm
-symbols ``s'' or ``t'', are ignored.
-.Sh EXAMPLES
-.Bl -tag -width "u=rwx,go=u-w" -compact
-.It Li 644
-make a file readable by anyone and writable by the owner only.
-.Pp
-.It Li go-w
-deny write permission to group and others.
-.Pp
-.It Li =rw,+X
-set the read and write permissions to the usual defaults, but
-retain any execute permissions that are currently set.
-.Pp
-.It Li +X
-make a directory or file searchable/executable by everyone if it is
-already searchable/executable by anyone.
-.Pp
-.It Li 755
-.It Li u=rwx,go=rx
-.It Li u=rwx,go=u-w
-make a file readable/executable by everyone and writable by the owner only.
-.Pp
-.It Li go=
-clear all mode bits for group and others.
-.Pp
-.It Li g=u-w
-set the group bits equal to the user bits, but clear the group write bit.
-.El
-.Sh BUGS
-There's no
-.Ar perm
-option for the naughty bits.
-.Sh SEE ALSO
-.Xr install 1 ,
-.Xr chmod 2 ,
-.Xr stat 2 ,
-.Xr umask 2 ,
-.Xr fts 3 ,
-.Xr setmode 3 ,
-.Xr symlink 7 ,
-.Xr chown 8
-.Sh STANDARDS
-The
-.Nm chmod
-utility is expected to be
-.St -p1003.2
-compatible with the exception of the
-.Ar perm
-symbols
-.Dq t
-and
-.Dq X
-which are not included in that standard.
View
203 bin/chmod/chmod.c
@@ -1,203 +0,0 @@
-/*
- * Copyright (c) 1989, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char copyright[] =
-"@(#) Copyright (c) 1989, 1993, 1994\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-/*static char sccsid[] = "from: @(#)chmod.c 8.8 (Berkeley) 4/1/94";*/
-static char *rcsid = "$Id: chmod.c,v 1.10 1994/09/20 04:08:23 mycroft Exp $";
-#endif /* not lint */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include <err.h>
-#include <errno.h>
-#include <fts.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <limits.h>
-
-void usage __P((void));
-
-int
-main(argc, argv)
- int argc;
- char *argv[];
-{
- FTS *ftsp;
- FTSENT *p;
- mode_t *set;
- long val;
- int oct, omode;
- int Hflag, Lflag, Pflag, Rflag, ch, fflag, fts_options, hflag, rval;
- char *ep, *mode;
-
- Hflag = Lflag = Pflag = Rflag = fflag = hflag = 0;
- while ((ch = getopt(argc, argv, "HLPRXfgorstuwx")) != -1)
- switch (ch) {
- case 'H':
- Hflag = 1;
- Lflag = Pflag = 0;
- break;
- case 'L':
- Lflag = 1;
- Hflag = Pflag = 0;
- break;
- case 'P':
- Pflag = 1;
- Hflag = Lflag = 0;
- break;
- case 'R':
- Rflag = 1;
- break;
- case 'f': /* XXX: undocumented. */
- fflag = 1;
- break;
- case 'h':
- /*
- * In System V (and probably POSIX.2) the -h option
- * causes chmod to change the mode of the symbolic
- * link. 4.4BSD's symbolic links don't have modes,
- * so it's an undocumented noop. Do syntax checking,
- * though.
- */
- hflag = 1;
- break;
- /*
- * XXX
- * "-[rwx]" are valid mode commands. If they are the entire
- * argument, getopt has moved past them, so decrement optind.
- * Regardless, we're done argument processing.
- */
- case 'g': case 'o': case 'r': case 's':
- case 't': case 'u': case 'w': case 'X': case 'x':
- if (argv[optind - 1][0] == '-' &&
- argv[optind - 1][1] == ch &&
- argv[optind - 1][2] == '\0')
- --optind;
- goto done;
- case '?':
- default:
- usage();
- }
-done: argv += optind;
- argc -= optind;
-
- if (argc < 2)
- usage();
-
- fts_options = FTS_PHYSICAL;
- if (Rflag) {
- if (hflag)
- errx(1,
- "the -R and -h options may not be specified together.");
- if (Hflag)
- fts_options |= FTS_COMFOLLOW;
- if (Lflag) {
- fts_options &= ~FTS_PHYSICAL;
- fts_options |= FTS_LOGICAL;
- }
- }
-
- mode = *argv;
- if (*mode >= '0' && *mode <= '7') {
- errno = 0;
- val = strtol(mode, &ep, 8);
- if (val > INT_MAX || val < 0)
- errno = ERANGE;
- if (errno)
- err(1, "invalid file mode: %s", mode);
- if (*ep)
- errx(1, "invalid file mode: %s", mode);
- omode = val;
- oct = 1;
- } else {
- if ((set = setmode(mode)) == NULL)
- errx(1, "invalid file mode: %s", mode);
- oct = 0;
- }
-
- if ((ftsp = fts_open(++argv, fts_options, 0)) == NULL)
- err(1, NULL);
- for (rval = 0; (p = fts_read(ftsp)) != NULL;) {
- switch (p->fts_info) {
- case FTS_D:
- if (Rflag) /* Change it at FTS_DP. */
- continue;
- fts_set(ftsp, p, FTS_SKIP);
- break;
- case FTS_DNR: /* Warn, chmod, continue. */
- warnx("%s: %s", p->fts_path, strerror(p->fts_errno));
- rval = 1;
- break;
- case FTS_ERR: /* Warn, continue. */
- case FTS_NS:
- warnx("%s: %s", p->fts_path, strerror(p->fts_errno));
- rval = 1;
- continue;
- case FTS_SL: /* Ignore. */
- case FTS_SLNONE:
- /*
- * The only symlinks that end up here are ones that
- * don't point to anything and ones that we found
- * doing a physical walk.
- */
- continue;
- default:
- break;
- }
- if (chmod(p->fts_accpath, oct ? omode :
- getmode(set, p->fts_statp->st_mode)) && !fflag) {
- warn(p->fts_path);
- rval = 1;
- }
- }
- if (errno)
- err(1, "fts_read");
- exit(rval);
-}
-
-void
-usage()
-{
- (void)fprintf(stderr,
- "usage: chmod [-R [-H | -L | -P]] mode file ...\n");
- exit(1);
-}
View
7 bin/cp/Makefile
@@ -1,7 +0,0 @@
-# from: @(#)Makefile 8.1 (Berkeley) 5/31/93
-# $Id: Makefile,v 1.6 1994/09/22 09:24:35 mycroft Exp $
-
-PROG= cp
-SRCS= cp.c utils.c
-
-.include <bsd.prog.mk>
View
212 bin/cp/cp.1
@@ -1,212 +0,0 @@
-.\" Copyright (c) 1989, 1990, 1993, 1994
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" This code is derived from software contributed to Berkeley by
-.\" the Institute of Electrical and Electronics Engineers, Inc.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" from: @(#)cp.1 8.3 (Berkeley) 4/18/94
-.\" $Id: cp.1,v 1.6 1994/09/22 09:24:38 mycroft Exp $
-.\"
-.Dd April 18, 1994
-.Dt CP 1
-.Os BSD 4
-.Sh NAME
-.Nm cp
-.Nd copy files
-.Sh SYNOPSIS
-.Nm cp
-.Oo
-.Fl R
-.Op Fl H | Fl L | Fl P
-.Oc
-.Op Fl fip
-.Ar source_file target_file
-.Nm cp
-.Oo
-.Fl R
-.Op Fl H | Fl L | Fl P
-.Oc
-.Op Fl fip
-.Ar source_file ... target_directory
-.Sh DESCRIPTION
-In the first synopsis form, the
-.Nm cp
-utility copies the contents of the
-.Ar source_file
-to the
-.Ar target_file .
-In the second synopsis form,
-the contents of each named
-.Ar source_file
-is copied to the destination
-.Ar target_directory .
-The names of the files themselves are not changed.
-If
-.Nm cp
-detects an attempt to copy a file to itself, the copy will fail.
-.Pp
-The following options are available:
-.Bl -tag -width flag
-.It Fl H
-If the
-.Fl R
-option is specified, symbolic links on the command line are followed.
-(Symbolic links encountered in the tree traversal are not followed.)
-.It Fl L
-If the
-.Fl R
-option is specified, all symbolic links are followed.
-.It Fl P
-If the
-.Fl R
-option is specified, no symbolic links are followed.
-.It Fl R
-If
-.Ar source_file
-designates a directory,
-.Nm cp
-copies the directory and the entire subtree connected at that point.
-This option also causes symbolic links to be copied, rather than
-indirected through, and for
-.Nm cp
-to create special files rather than copying them as normal files.
-Created directories have the same mode as the corresponding source
-directory, unmodified by the process' umask.
-.It Fl f
-For each existing destination pathname, remove it and
-create a new file, without prompting for confirmation
-regardless of its permissions.
-(The
-.Fl i
-option is ignored if the
-.Fl f
-option is specified.)
-.It Fl i
-Causes
-.Nm cp
-to write a prompt to the standard error output before copying a file
-that would overwrite an existing file.
-If the response from the standard input begins with the character
-.Sq Li y ,
-the file copy is attempted.
-.It Fl p
-Causes
-.Nm cp
-to preserve in the copy as many of the modification time, access time,
-file flags, file mode, user ID, and group ID as allowed by permissions.
-.Pp
-If the user ID and group ID cannot be preserved, no error message
-is displayed and the exit value is not altered.
-.Pp
-If the source file has its set user ID bit on and the user ID cannot
-be preserved, the set user ID bit is not preserved
-in the copy's permissions.
-If the source file has its set group ID bit on and the group ID cannot
-be preserved, the set group ID bit is not preserved
-in the copy's permissions.
-If the source file has both its set user ID and set group ID bits on,
-and either the user ID or group ID cannot be preserved, neither
-the set user ID or set group ID bits are preserved in the copy's
-permissions.
-.El
-.Pp
-For each destination file that already exists, its contents are
-overwritten if permissions allow, but its mode, user ID, and group
-ID are unchanged.
-.Pp
-In the second synopsis form,
-.Ar target_directory
-must exist unless there is only one named
-.Ar source_file
-which is a directory and the
-.Fl R
-flag is specified.
-.Pp
-If the destination file does not exist, the mode of the source file is
-used as modified by the file mode creation mask
-.Pf ( Ic umask ,
-see
-.Xr csh 1 ) .
-If the source file has its set user ID bit on, that bit is removed
-unless both the source file and the destination file are owned by the
-same user.
-If the source file has its set group ID bit on, that bit is removed
-unless both the source file and the destination file are in the same
-group and the user is a member of that group.
-If both the set user ID and set group ID bits are set, all of the above
-conditions must be fulfilled or both bits are removed.
-.Pp
-Appropriate permissions are required for file creation or overwriting.
-.Pp
-Symbolic links are always followed unless the
-.Fl R
-flag is set, in which case symbolic links are not followed, by default.
-The
-.Fl H
-or
-.Fl L
-flags (in conjunction with the
-.Fl R
-flag) cause symbolic links to be followed as described above.
-The
-.Fl H ,
-.Fl L
-and
-.Fl P
-options are ignored unless the
-.Fl R
-option is specified.
-In addition, these options override each other and the
-command's actions are determined by the last one specified.
-.Pp
-.Nm Cp
-exits 0 on success, >0 if an error occurred.
-.Sh COMPATIBILITY
-Historic versions of the
-.Nm cp
-utility had a
-.Fl r
-option.
-This implementation supports that option, however, its use is strongly
-discouraged, as it does not correctly copy special files, symbolic links
-or fifo's.
-.Sh SEE ALSO
-.Xr mv 1 ,
-.Xr rcp 1 ,
-.Xr umask 2 ,
-.Xr fts 3 ,
-.Xr symlink 7
-.Sh HISTORY
-The
-.Nm cp
-command is expected to be
-.St -p1003.2
-compatible.
View
449 bin/cp/cp.c
@@ -1,449 +0,0 @@
-/*
- * Copyright (c) 1988, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * David Hitz of Auspex Systems Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char copyright[] =
-"@(#) Copyright (c) 1988, 1993, 1994\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-/*static char sccsid[] = "from: @(#)cp.c 8.2 (Berkeley) 4/1/94";*/
-static char *rcsid = "$Id: cp.c,v 1.10 1994/09/22 09:24:40 mycroft Exp $";
-#endif /* not lint */
-
-/*
- * Cp copies source files to target files.
- *
- * The global PATH_T structure "to" always contains the path to the
- * current target file. Since fts(3) does not change directories,
- * this path can be either absolute or dot-relative.
- *
- * The basic algorithm is to initialize "to" and use fts(3) to traverse
- * the file hierarchy rooted in the argument list. A trivial case is the
- * case of 'cp file1 file2'. The more interesting case is the case of
- * 'cp file1 file2 ... fileN dir' where the hierarchy is traversed and the
- * path (relative to the root of the traversal) is appended to dir (stored
- * in "to") to form the final target path.
- */
-
-#include <sys/param.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <sys/time.h>
-
-#include <dirent.h>
-#include <err.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <fts.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "extern.h"
-
-#define STRIP_TRAILING_SLASH(p) { \
- while ((p).p_end > (p).p_path && (p).p_end[-1] == '/') \
- *--(p).p_end = 0; \
-}
-
-PATH_T to = { to.p_path, "" };
-
-uid_t myuid;
-int Rflag, iflag, pflag, rflag;
-int myumask;
-
-enum op { FILE_TO_FILE, FILE_TO_DIR, DIR_TO_DNE };
-
-int copy __P((char *[], enum op, int));
-int mastercmp __P((const FTSENT **, const FTSENT **));
-
-int
-main(argc, argv)
- int argc;
- char *argv[];
-{
- struct stat to_stat, tmp_stat;
- enum op type;
- int Hflag, Lflag, Pflag, ch, fts_options, r;
- char *target;
-
- Hflag = Lflag = Pflag = Rflag = 0;
- while ((ch = getopt(argc, argv, "HLPRfipr")) != EOF)
- switch (ch) {
- case 'H':
- Hflag = 1;
- Lflag = Pflag = 0;
- break;
- case 'L':
- Lflag = 1;
- Hflag = Pflag = 0;
- break;
- case 'P':
- Pflag = 1;
- Hflag = Lflag = 0;
- break;
- case 'R':
- Rflag = 1;
- break;
- case 'f':
- iflag = 0;
- break;
- case 'i':
- iflag = isatty(fileno(stdin));
- break;
- case 'p':
- pflag = 1;
- break;
- case 'r':
- rflag = 1;
- break;
- case '?':
- default:
- usage();
- break;
- }
- argc -= optind;
- argv += optind;
-
- if (argc < 2)
- usage();
-
- fts_options = FTS_NOCHDIR | FTS_PHYSICAL;
- if (rflag) {
- if (Rflag)
- errx(1,
- "the -R and -r options may not be specified together.");
- if (Hflag || Lflag || Pflag)
- errx(1,
- "the -H, -L, and -P options may not be specified with the -r option.");
- fts_options &= ~FTS_PHYSICAL;
- fts_options |= FTS_LOGICAL;
- }
- if (Rflag) {
- if (Hflag)
- fts_options |= FTS_COMFOLLOW;
- if (Lflag) {
- fts_options &= ~FTS_PHYSICAL;
- fts_options |= FTS_LOGICAL;
- }
- } else {
- fts_options &= ~FTS_PHYSICAL;
- fts_options |= FTS_LOGICAL;
- }
-
- myuid = getuid();
-
- /* Copy the umask for explicit mode setting. */
- myumask = umask(0);
- (void)umask(myumask);
-
- /* Save the target base in "to". */
- target = argv[--argc];
- if (strlen(target) > MAXPATHLEN)
- errx(1, "%s: name too long", target);
- (void)strcpy(to.p_path, target);
- to.p_end = to.p_path + strlen(to.p_path);
- if (to.p_path == to.p_end) {
- *to.p_end++ = '.';
- *to.p_end = 0;
- }
- STRIP_TRAILING_SLASH(to);
- to.target_end = to.p_end;
-
- /* Set end of argument list for fts(3). */
- argv[argc] = NULL;
-
- /*
- * Cp has two distinct cases:
- *
- * cp [-R] source target
- * cp [-R] source1 ... sourceN directory
- *
- * In both cases, source can be either a file or a directory.
- *
- * In (1), the target becomes a copy of the source. That is, if the
- * source is a file, the target will be a file, and likewise for
- * directories.
- *
- * In (2), the real target is not directory, but "directory/source".
- */
- r = stat(to.p_path, &to_stat);
- if (r == -1 && errno != ENOENT)
- err(1, "%s", to.p_path);
- if (r == -1 || !S_ISDIR(to_stat.st_mode)) {
- /*
- * Case (1). Target is not a directory.
- */
- if (argc > 1) {
- usage();
- exit(1);
- }
- /*
- * Need to detect the case:
- * cp -R dir foo
- * Where dir is a directory and foo does not exist, where
- * we want pathname concatenations turned on but not for
- * the initial mkdir().
- */
- if (r == -1) {
- if (rflag || (Rflag && (Lflag || Hflag)))
- stat(*argv, &tmp_stat);
- else
- lstat(*argv, &tmp_stat);
-
- if (S_ISDIR(tmp_stat.st_mode) && (Rflag || rflag))
- type = DIR_TO_DNE;
- else
- type = FILE_TO_FILE;
- } else
- type = FILE_TO_FILE;
- } else
- /*
- * Case (2). Target is a directory.
- */
- type = FILE_TO_DIR;
-
- exit (copy(argv, type, fts_options));
-}
-
-int
-copy(argv, type, fts_options)
- char *argv[];
- enum op type;
- int fts_options;
-{
- struct stat to_stat;
- FTS *ftsp;
- FTSENT *curr;
- int base, dne, nlen, rval;
- char *p;
-
- if ((ftsp = fts_open(argv, fts_options, mastercmp)) == NULL)
- err(1, NULL);
- for (rval = 0; (curr = fts_read(ftsp)) != NULL;) {
- switch (curr->fts_info) {
- case FTS_NS:
- case FTS_ERR:
- warnx("%s: %s",
- curr->fts_path, strerror(curr->fts_errno));
- rval = 1;
- continue;
- case FTS_DC: /* Warn, continue. */
- warnx("%s: directory causes a cycle", curr->fts_path);
- rval = 1;
- continue;
- case FTS_DP: /* Ignore, continue. */
- continue;
- }
-
- /*
- * If we are in case (2) or (3) above, we need to append the
- * source name to the target name.
- */
- if (type != FILE_TO_FILE) {
- if ((curr->fts_namelen +
- to.target_end - to.p_path + 1) > MAXPATHLEN) {
- warnx("%s/%s: name too long (not copied)",
- to.p_path, curr->fts_name);
- rval = 1;
- continue;
- }
-
- /*
- * Need to remember the roots of traversals to create
- * correct pathnames. If there's a directory being
- * copied to a non-existent directory, e.g.
- * cp -R a/dir noexist
- * the resulting path name should be noexist/foo, not
- * noexist/dir/foo (where foo is a file in dir), which
- * is the case where the target exists.
- *
- * Also, check for "..". This is for correct path
- * concatentation for paths ending in "..", e.g.
- * cp -R .. /tmp
- * Paths ending in ".." are changed to ".". This is
- * tricky, but seems the easiest way to fix the problem.
- *
- * XXX
- * Since the first level MUST be FTS_ROOTLEVEL, base
- * is always initialized.
- */
- if (curr->fts_level == FTS_ROOTLEVEL)
- if (type != DIR_TO_DNE) {
- p = strrchr(curr->fts_path, '/');
- base = (p == NULL) ? 0 :
- (int)(p - curr->fts_path + 1);
-
- if (!strcmp(&curr->fts_path[base],
- ".."))
- base += 1;
- } else
- base = curr->fts_pathlen;
-
- if (to.target_end[-1] != '/') {
- *to.target_end = '/';
- *(to.target_end + 1) = 0;
- }
- p = &curr->fts_path[base];
- nlen = curr->fts_pathlen - base;
-
- (void)strncat(to.target_end + 1, p, nlen);
- to.p_end = to.target_end + nlen + 1;
- *to.p_end = 0;
- STRIP_TRAILING_SLASH(to);
- }
-
- /* Not an error but need to remember it happened */
- if (stat(to.p_path, &to_stat) == -1)
- dne = 1;
- else {
- if (to_stat.st_dev == curr->fts_statp->st_dev &&
- to_stat.st_ino == curr->fts_statp->st_ino) {
- warnx("%s and %s are identical (not copied).",
- to.p_path, curr->fts_path);
- rval = 1;
- if (S_ISDIR(curr->fts_statp->st_mode))
- (void)fts_set(ftsp, curr, FTS_SKIP);
- continue;
- }
- if (!S_ISDIR(curr->fts_statp->st_mode) &&
- S_ISDIR(to_stat.st_mode)) {
- warnx("cannot overwrite directory %s with non-directory %s.",
- to.p_path, curr->fts_path);
- rval = 1;
- continue;
- }
- dne = 0;
- }
-
- switch (curr->fts_statp->st_mode & S_IFMT) {
- case S_IFLNK:
- if (copy_link(curr, !dne))
- rval = 1;
- break;
- case S_IFDIR:
- if (!Rflag && !rflag) {
- warnx("%s is a directory (not copied).",
- curr->fts_path);
- (void)fts_set(ftsp, curr, FTS_SKIP);
- rval = 1;
- break;
- }
- /*
- * If the directory doesn't exist, create the new
- * one with the from file mode plus owner RWX bits,
- * modified by the umask. Trade-off between being
- * able to write the directory (if from directory is
- * 555) and not causing a permissions race. If the
- * umask blocks owner writes, we fail..
- */
- if (dne) {
- if (mkdir(to.p_path,
- curr->fts_statp->st_mode | S_IRWXU) < 0)
- err(1, "%s", to.p_path);
- } else if (!S_ISDIR(to_stat.st_mode)) {
- errno = ENOTDIR;
- err(1, "%s: %s", to.p_path);
- }
- /*
- * If not -p and directory didn't exist, set it to be
- * the same as the from directory, umodified by the
- * umask; arguably wrong, but it's been that way
- * forever.
- */
- if (pflag && setfile(curr->fts_statp, 0))
- rval = 1;
- else if (dne)
- (void)chmod(to.p_path,
- curr->fts_statp->st_mode);
- break;
- case S_IFBLK:
- case S_IFCHR:
- if (Rflag) {
- if (copy_special(curr->fts_statp, !dne))
- rval = 1;
- } else
- if (copy_file(curr, dne))
- rval = 1;
- break;
- case S_IFIFO:
- if (Rflag)
- if (copy_fifo(curr->fts_statp, !dne))
- rval = 1;
- else
- if (copy_file(curr, dne))
- rval = 1;
- break;
- default:
- if (copy_file(curr, dne))
- rval = 1;
- break;
- }
- }
- if (errno)
- err(1, "fts_read");
- return (rval);
-}
-
-/*
- * mastercmp --
- * The comparison function for the copy order. The order is to copy
- * non-directory files before directory files. The reason for this
- * is because files tend to be in the same cylinder group as their
- * parent directory, whereas directories tend not to be. Copying the
- * files first reduces seeking.
- */
-int
-mastercmp(a, b)
- const FTSENT **a, **b;
-{
- int a_info, b_info;
-
- a_info = (*a)->fts_info;
- if (a_info == FTS_ERR || a_info == FTS_NS || a_info == FTS_DNR)
- return (0);
- b_info = (*b)->fts_info;
- if (b_info == FTS_ERR || b_info == FTS_NS || b_info == FTS_DNR)
- return (0);
- if (a_info == FTS_D)
- return (-1);
- if (b_info == FTS_D)
- return (1);
- return (0);
-}
View
56 bin/cp/extern.h
@@ -1,56 +0,0 @@
-/*-
- * Copyright (c) 1991, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * from: @(#)extern.h 8.2 (Berkeley) 4/1/94
- * $Id: extern.h,v 1.2 1994/09/22 09:24:41 mycroft Exp $
- */
-
-typedef struct {
- char *p_end; /* pointer to NULL at end of path */
- char *target_end; /* pointer to end of target base */
- char p_path[MAXPATHLEN + 1]; /* pointer to the start of a path */
-} PATH_T;
-
-extern PATH_T to;
-extern uid_t myuid;
-extern int iflag, pflag, myumask;
-
-#include <sys/cdefs.h>
-
-__BEGIN_DECLS
-int copy_fifo __P((struct stat *, int));
-int copy_file __P((FTSENT *, int));
-int copy_link __P((FTSENT *, int));
-int copy_special __P((struct stat *, int));
-int setfile __P((struct stat *, int));
-void usage __P((void));
-__END_DECLS
View
286 bin/cp/utils.c
@@ -1,286 +0,0 @@
-/*-
- * Copyright (c) 1991, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-/*static char sccsid[] = "from: @(#)utils.c 8.3 (Berkeley) 4/1/94";*/
-static char *rcsid = "$Id: utils.c,v 1.2 1994/09/22 09:24:43 mycroft Exp $";
-#endif /* not lint */
-
-#include <sys/param.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <sys/time.h>
-
-#include <err.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <fts.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "extern.h"
-
-int
-copy_file(entp, dne)
- FTSENT *entp;
- int dne;
-{
- static char buf[MAXBSIZE];
- struct stat to_stat, *fs;
- int ch, checkch, from_fd, rcount, rval, to_fd, wcount;
-#ifdef VM_AND_BUFFER_CACHE_SYNCHRONIZED
- char *p;
-#endif
-
- if ((from_fd = open(entp->fts_path, O_RDONLY, 0)) == -1) {
- warn("%s", entp->fts_path);
- return (1);
- }
-
- fs = entp->fts_statp;
-
- /*
- * If the file exists and we're interactive, verify with the user.
- * If the file DNE, set the mode to be the from file, minus setuid
- * bits, modified by the umask; arguably wrong, but it makes copying
- * executables work right and it's been that way forever. (The
- * other choice is 666 or'ed with the execute bits on the from file
- * modified by the umask.)
- */
- if (!dne) {
- if (iflag) {
- (void)fprintf(stderr, "overwrite %s? ", to.p_path);
- checkch = ch = getchar();
- while (ch != '\n' && ch != EOF)
- ch = getchar();
- if (checkch != 'y' && checkch != 'Y') {
- (void)close(from_fd);
- return (0);
- }
- }
- to_fd = open(to.p_path, O_WRONLY | O_TRUNC, 0);
- } else
- to_fd = open(to.p_path, O_WRONLY | O_TRUNC | O_CREAT,
- fs->st_mode & ~(S_ISUID | S_ISGID));
-
- if (to_fd == -1) {
- warn("%s", to.p_path);
- (void)close(from_fd);
- return (1);;
- }
-
- rval = 0;
-
- /*
- * Mmap and write if less than 8M (the limit is so we don't totally
- * trash memory on big files. This is really a minor hack, but it
- * wins some CPU back.
- */
-#ifdef VM_AND_BUFFER_CACHE_SYNCHRONIZED
- if (fs->st_size <= 8 * 1048576) {
- if ((p = mmap(NULL, (size_t)fs->st_size, PROT_READ,
- 0, from_fd, (off_t)0)) == (char *)-1) {
- warn("%s", entp->fts_path);
- rval = 1;
- } else {
- if (write(to_fd, p, fs->st_size) != fs->st_size) {
- warn("%s", to.p_path);
- rval = 1;
- }
- /* Some systems don't unmap on close(2). */
- if (munmap(p, fs->st_size) < 0) {
- warn("%s", entp->fts_path);
- rval = 1;
- }
- }
- } else
-#endif
- {
- while ((rcount = read(from_fd, buf, MAXBSIZE)) > 0) {
- wcount = write(to_fd, buf, rcount);
- if (rcount != wcount || wcount == -1) {
- warn("%s", to.p_path);
- rval = 1;
- break;
- }
- }
- if (rcount < 0) {
- warn("%s", entp->fts_path);
- rval = 1;
- }
- }
-
- /* If the copy went bad, lose the file. */
- if (rval == 1) {
- (void)unlink(to.p_path);
- (void)close(from_fd);
- (void)close(to_fd);
- return (1);
- }
-
- if (pflag && setfile(fs, to_fd))
- rval = 1;
- /*
- * If the source was setuid or setgid, lose the bits unless the
- * copy is owned by the same user and group.
- */
-#define RETAINBITS \
- (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO)
- else if (fs->st_mode & (S_ISUID | S_ISGID) && fs->st_uid == myuid)
- if (fstat(to_fd, &to_stat)) {
- warn("%s", to.p_path);
- rval = 1;
- } else if (fs->st_gid == to_stat.st_gid &&
- fchmod(to_fd, fs->st_mode & RETAINBITS & ~myumask)) {
- warn("%s", to.p_path);
- rval = 1;
- }
- (void)close(from_fd);
- if (close(to_fd)) {
- warn("%s", to.p_path);
- rval = 1;
- }
- return (rval);
-}
-
-int
-copy_link(p, exists)
- FTSENT *p;
- int exists;
-{
- int len;
- char link[MAXPATHLEN];
-
- if ((len = readlink(p->fts_path, link, sizeof(link))) == -1) {
- warn("readlink: %s", p->fts_path);
- return (1);
- }
- link[len] = '\0';
- if (exists && unlink(to.p_path)) {
- warn("unlink: %s", to.p_path);
- return (1);
- }
- if (symlink(link, to.p_path)) {
- warn("symlink: %s", link);
- return (1);
- }
- return (0);
-}
-
-int
-copy_fifo(from_stat, exists)
- struct stat *from_stat;
- int exists;
-{
- if (exists && unlink(to.p_path)) {
- warn("unlink: %s", to.p_path);
- return (1);
- }
- if (mkfifo(to.p_path, from_stat->st_mode)) {
- warn("mkfifo: %s", to.p_path);
- return (1);
- }
- return (pflag ? setfile(from_stat, 0) : 0);
-}
-
-int
-copy_special(from_stat, exists)
- struct stat *from_stat;
- int exists;
-{
- if (exists && unlink(to.p_path)) {
- warn("unlink: %s", to.p_path);
- return (1);
- }
- if (mknod(to.p_path, from_stat->st_mode, from_stat->st_rdev)) {
- warn("mknod: %s", to.p_path);
- return (1);
- }
- return (pflag ? setfile(from_stat, 0) : 0);
-}
-
-
-int
-setfile(fs, fd)
- register struct stat *fs;
- int fd;
-{
- static struct timeval tv[2];
- int rval;
-
- rval = 0;
- fs->st_mode &= S_ISUID | S_ISGID | S_IRWXU | S_IRWXG | S_IRWXO;
-
- TIMESPEC_TO_TIMEVAL(&tv[0], &fs->st_atimespec);
- TIMESPEC_TO_TIMEVAL(&tv[1], &fs->st_mtimespec);
- if (utimes(to.p_path, tv)) {
- warn("utimes: %s", to.p_path);
- rval = 1;
- }
- /*
- * Changing the ownership probably won't succeed, unless we're root
- * or POSIX_CHOWN_RESTRICTED is not set. Set uid/gid before setting
- * the mode; current BSD behavior is to remove all setuid bits on
- * chown. If chown fails, lose setuid/setgid bits.
- */
- if (fd ? fchown(fd, fs->st_uid, fs->st_gid) :
- chown(to.p_path, fs->st_uid, fs->st_gid)) {
- if (errno != EPERM) {
- warn("chown: %s", to.p_path);
- rval = 1;
- }
- fs->st_mode &= ~(S_ISUID | S_ISGID);
- }
- if (fd ? fchmod(fd, fs->st_mode) : chmod(to.p_path, fs->st_mode)) {
- warn("chown: %s", to.p_path);
- rval = 1;
- }
-
- if (fd ?
- fchflags(fd, fs->st_flags) : chflags(to.p_path, fs->st_flags)) {
- warn("chflags: %s", to.p_path);
- rval = 1;
- }
- return (rval);
-}
-
-void
-usage()
-{
- (void)fprintf(stderr, "%s\n%s\n",
-"usage: cp [-R [-H | -L | -P] [-fip] src target",
-" cp [-R [-H | -L | -P] [-fip] src1 ... srcN directory");
- exit(1);
-}
View
45 bin/csh/Makefile
@@ -1,45 +0,0 @@
-# from: @(#)Makefile 8.1 (Berkeley) 5/31/93
-# $Id: Makefile,v 1.6 1994/09/21 00:10:23 mycroft Exp $
-#
-# C Shell with process control; VM/UNIX VAX Makefile
-# Bill Joy UC Berkeley; Jim Kulp IIASA, Austria
-#
-# To profile, put -DPROF in DEFS and -pg in CFLAGS, and recompile.
-
-PROG= csh
-DFLAGS=-DBUILTIN -DFILEC -DNLS -DSHORT_STRINGS
-#CFLAGS+=-g
-#CFLAGS+=-Wall -ansi -pedantic
-CFLAGS+=-I${.CURDIR} -I. ${DFLAGS}
-SRCS= alloc.c char.c const.c csh.c dir.c dol.c err.c exec.c exp.c file.c \
- func.c glob.c hist.c init.c lex.c misc.c parse.c printf.c proc.c \
- sem.c set.c str.c time.c
-#.PATH: ${.CURDIR}/../../usr.bin/printf
-
-MAN1= csh.0
-MLINKS= csh.1 limit.1 csh.1 alias.1 csh.1 bg.1 csh.1 dirs.1 csh.1 fg.1 \
- csh.1 foreach.1 csh.1 history.1 csh.1 jobs.1 csh.1 popd.1 \
- csh.1 pushd.1 csh.1 rehash.1 csh.1 repeat.1 csh.1 suspend.1 \
- csh.1 stop.1 csh.1 source.1
-CLEANFILES+=err.h const.h
-