1Hiding files on a CD
2=====================
3
4This document attempts to show how to hide files from being seen by an
5operating system accessing a CD as an ISO9660/Rock Ridge, Joliet or HFS
6CD. It also highlights some of the limitations ...
7
8Note: this document is about the various -hide options - not be confused with
9the -hidden options.
10
11The -hidden options set the 'EXISTENCE' bit in the directory entry which
12means the file or directory will be invisible - unless some special option
13is used to mount or view the CD - Linux has the 'unhide' mount option to
14make these files visible. i.e. the directory entry exists on the CD.
15
16With hindsight, to avoid confusion with the -hidden option, it would have
17been better to chose an option name like '-omit' instead of '-hide'...
18
19The various -hide options actually exclude the relevant directory entry
20from the directory tree. Therefore, it is not possible to access a file
21or directory that has be hidden with the -hide option when the ISO9600/Rock
22Ridge directory is mounted - because the directory entry does not exist on the
23CD (but the file data does). You would probably be able to access this file
24or directory when mounted as a Joliet or HFS CD (depending on other options
25used). Similarly, a directory entry hidden with the -hide-joliet option
26will not be accessible when mounted as an Joliet CD. Similarly for -hide-hfs
27etc.
28
29If you don't want a file or directory to appear on the CD at all, then use the
30-exclude options, not the -hide options (mkisofs completely ignores any
31file/directory excluded with the -exclude options).
32
33
34Using the hide options
35======================
36
37There are 6 hide options:
38
39-hide		   Hide a file/directory from the ISO9660/Rock Ridge directory
40-hide-list	   As above, but read file names from a file
41-hide-joliet	   Hide a file/directory from the Joliet directory
42-hide-joliet-list  As above, but read file names from a file
43-hide-hfs	   Hide a file/directory from the HFS directory
44-hide-hfs-list	   As above, but read file names from a file
45
46You can use the -hide, -hide-joliet and/or -hide-hfs options as many times
47as you like on the command line, but if you have many files to hide, then
48it may be better to put your file names in a file (one per line) and use
49the corresponding 'list' option. You can also use the three -hide-list options
50as many times as you want.
51
52The arguments to the -hide options are either the 'basename' or the 'whole
53path name' of a file. That is, if you use the option:
54
55% mkisofs -hide ABC [-other-options] CD_directory
56
57then any file with the name ABC will be hidden. If you want to be more
58specific, then use the whole name - as seen by mkisofs e.g.:
59
60% mkisofs -hide CD_directory/XYZ/ABC [-other-options] CD_directory
61
62will hide just the file 'CD_directory/XYZ/ABC' - not any other file called
63'ABC' that might exist under 'CD_directory'. However, if your command line
64is like:
65
66% mkisofs -hide CD_directory/XYZ/ABC [-other-options] ./CD_directory
67
68Then the file 'CD_directory/XYZ/ABC' will not be hidden because as far as
69mkisofs is concerned. Its whole path is actually './CD_directory/XYZ/ABC'.
70
71You can use wild cards in the -hide arguments.
72
73If the file name to be hidden is a directory, then the directory and all
74its contents are hidden.
75
76The main use of the hide options is on a multi platform (hybrid CD) to hide
77various files/directories that are operating system specific from been seen
78on the CD when mounted on another OS. i.e. You may want to hide Macintosh
79executables from being seen when the CD is mounted as a Joliet CD on a PC etc.
80
81For example, say we want to create a ISO9660/Rock Ridge, Joliet, HFS hybrid
82CD from files/directories in the directory called 'cd_dir' - which are:
83
84MAC/
85MAC/app
86MAC/data/
87MAC/data/file1
88PC/
89PC/app
90PC/data/
91PC/data/file1
92UNIX/
93UNIX/app
94UNIX/data
95UNIX/data/file1
96COMMON/
97COMMON/some_files
98
99We could use the command line:
100
101% mkisofs -r -J -hfs -hide MAC -hide PC -hide-joliet MAC \
102	-hide-joliet UNIX -hide-hfs PC -hide-hfs UNIX -o cd.iso cd_dir
103
104This will give a CD that when mounted as a Rock Ridge CD, you will only
105see the directories UNIX and COMMON, as a Joliet CD the directories
106PC and COMMON, and as an HFS CD the directories MAC and COMMON.
107
108If you also had the three files in the current directory called README.hfs,
109README.joliet and README.unix - but you wanted to have each of these
110files appear as just 'README' when mounted, then you could use the above
111command line with the following:
112
113% mkisofs -r -J -hfs -graft-points -hide MAC -hide PC -hide-joliet MAC \
114	-hide-joliet UNIX -hide-hfs PC -hide-hfs UNIX \
115	-hide README.hfs -hide README.joliet -hide-joliet README.hfs \
116	-hide-joliet README.uni -hide-hfs README.joliet -hide-hfs README.unix \
117	README=README.hfs README=README.joliet README=README.unix \
118	-o cd.iso cd_dir
119
120Note: we've used the -graft-points option as we're using the '=' syntax
121to insert the files called README.hfs, README.joliet and README.unix as
122'README'
123
124The resulting CD when mounted as a Rock Ridge CD, will have the directories
125UNIX and COMMON - with the file called README - which was originally
126called README.unix.
127
128However, in most circumstances, it would be better to have the contents
129of each of the OS specific directories (plus the contents of the COMMON
130directory) to appear at the top level of the CD. i.e. when the CD is mounted
131(as ISO9660/Rock Ridge, Joliet or HFS) it has the contents:
132
133README
134app
135data/file1
136some_files
137
138Unfortunately, this is not as straight forward as it may seem - i.e. doing
139the following may seem OK, but it won't work - for reasons I'll explain
140later:
141
142It gets a bit messy using the -graft-points syntax above, so we'll assume
143each of the MAC, UNIX and PC directories contain the correct README, We'll
144also change to the 'cd_dir' directory and use the command:
145
146mkisofs -r -J -hfs -hide MAC -hide PC -hide-joliet MAC \
147	-hide-joliet UNIX -hide-hfs PC -hide-hfs UNIX \
148	-o cd.iso MAC PC UNIX COMMON
149
150You will get errors like:
151
152mkisofs: Error: UNIX/README and MAC/README have the same Rock Ridge name
153...
154mkisofs: Unable to sort directory
155
156This is because you can not hide "pathspecs" that are directories ("pathspecs"
157are file names given on the command line, or in a path-list file). This a
158"feature" of mkisofs. In this case nothing is actually hidden at all.
159
160So you might think that the following may work:
161
162mkisofs -r -J -hfs -hide "MAC/*" -hide "PC/*" -hide-joliet "MAC/*" \
163	-hide-joliet "UNIX/*" -hide-hfs "PC/*" -hide-hfs "UNIX/*" \
164	-o cd.iso MAC PC UNIX COMMON
165
166which may appear to work - but when the CD is mounted as an ISO9660/Rock Ridge
167or Joliet CD, then the directory "data" is missing.
168
169Again this is a feature of mkisofs - the directories PC/data and UNIX/data
170are mapped by mkisofs to the same output directory called "/data" - the
171various "hide" flags are stored with this directory info - in this case as
172the output directory "/data" is first hidden from the ISO9660/Rock Ridge and
173then the Joliet directory, the net result is that "/data" gets hidden from
174both directories ... the way mkisofs hides HFS directories is slightly
175different, so in this case the directory "data" exists on the HFS volume
176and contains the correct contents.
177
178However, it is possible to obtain the required result, but we have to be
179careful about hiding multiple input directories that map to a single output
180directory.
181
182To do this we have to hide just the files in these directories (or more
183accurately, all the non-directories). This is best done by using lists of
184files to hide for example:
185
186find PC -type f -print > pc.list
187find UNIX -type f -print > unix.list
188find MAC -type f -print > mac.list
189
190mkisofs -r -J -hfs -hide-list pc.list -hide-list mac.list \
191	-hide-joliet-list unix.list -hide-joliet-list mac.list \
192	-hide-hfs-list pc.list -hide-hfs-list unix.list \
193	-o cd.iso MAC PC UNIX COMMON
194
195i.e. instead of trying to hide a directory and letting mkisofs hide its
196contents, we explicitly hide all the files in the directory, but not the
197directory and any of its sub-directories.
198
199This will work for the above input files, but if your directory trees contain
200symbolic links and/or directories that will not get merged, then the hide lists
201will have to be tailored to get the required result.
202
203
204James Pearson 22-Nov-2001
205
206Any comments/problems to j.pearson@ge.ucl.ac.uk
207