proto 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. .TH PROTO 2
  2. .SH NAME
  3. rdproto \- parse and process a proto file listing
  4. .SH SYNOPSIS
  5. .nf
  6. .ft L
  7. #include <u.h>
  8. #include <libc.h>
  9. #include <disk.h>
  10. .ft
  11. .PP
  12. .B
  13. typedef void Protoenum(char *new, char *old, Dir *d, void *a)
  14. .PP
  15. .B
  16. typedef void Protowarn(char *msg, void *a)
  17. .PP
  18. .B
  19. int rdproto(char *proto, char *root, Protoenum *enm,
  20. .br
  21. .B
  22. Protowarn *warn, void *a)
  23. .SH DESCRIPTION
  24. .I Rdproto
  25. reads and interprets the named
  26. .I proto
  27. file relative to the
  28. root directory
  29. .IR root .
  30. .PP
  31. Each line of the
  32. .I proto
  33. file specifies a file to copy.
  34. Blank lines and lines beginning with
  35. .B #
  36. are ignored.
  37. Indentation (usually tabs) is significant,
  38. with each level of indentation corresponding to a level in the file tree.
  39. Fields within a line are separated by white space.
  40. The first field is the last path element in the destination file tree.
  41. The second field specifies the permissions.
  42. The third field is the owner of the file,
  43. and the fourth is the group owning the file.
  44. The fifth field is the name of the file from which to copy;
  45. this file is read from the current name space,
  46. not the source file tree.
  47. All fields except the first are optional.
  48. Specifying
  49. .B -
  50. for permissions, owner, or group
  51. causes
  52. .I rdproto
  53. to fetch the corresponding information
  54. from the file rather than override it.
  55. (This is the default behavior when the fields
  56. are not present; explicitly specifying
  57. .B -
  58. is useful when one wishes to set, say,
  59. the file owner without setting the permissions.)
  60. .PP
  61. Names beginning with a
  62. .L $
  63. are expanded as environment variables.
  64. If the first file specified in a directory is
  65. .LR * ,
  66. all of the files in that directory are considered listed.
  67. If the first file is
  68. .LR + ,
  69. all of the files are copied, and all subdirectories
  70. are recursively considered listed.
  71. All files are considered relative to
  72. .IR root .
  73. .PP
  74. For each file named by the
  75. .IR proto ,
  76. .I enm
  77. is called with
  78. .I new
  79. pointing at the name of the file (without the root prefix),
  80. .I old
  81. pointing at the name of the source file (with the root prefix,
  82. when applicable),
  83. and
  84. .I Dir
  85. at the desired directory information for the new file.
  86. Only the
  87. .BR name ,
  88. .BR uid ,
  89. .BR gid ,
  90. .BR mode ,
  91. .BR mtime ,
  92. and
  93. .B length
  94. fields are guaranteed to be valid.
  95. The argument
  96. .I a
  97. is the same argument passed to
  98. .IR rdproto ;
  99. typically it points at some extra state
  100. used by the enumeration function.
  101. .PP
  102. When files or directories do not exist or
  103. cannot be read by
  104. .IR rdproto ,
  105. it formats a warning message, calls
  106. .IR warn ,
  107. and continues processing;
  108. if
  109. .I warn
  110. is nil,
  111. .I rdproto
  112. prints the warning message to standard error.
  113. .PP
  114. .I Rdproto
  115. returns zero
  116. if
  117. .I proto
  118. was processed, \-1 if it could not be opened.
  119. .SH FILES
  120. .TF /sys/lib/sysconfig/proto/portproto
  121. .TP
  122. .B /sys/lib/sysconfig/proto/
  123. directory of prototype files.
  124. .TP
  125. .B /sys/lib/sysconfig/proto/portproto
  126. generic prototype file.
  127. .SH SOURCE
  128. .B /sys/src/libdisk/proto.c
  129. .SH SEE ALSO
  130. .IR mk9660 (8),
  131. .IR mkfs (8)