home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / compress / xfh132.lzh / XFH / advanced_usage.doc next >
Text File  |  1993-01-19  |  24KB  |  500 lines

  1.  
  2.  
  3.                   Xpk File System Handler v1.32
  4.  
  5.                       By Kristian Nielsen
  6.  
  7.  
  8. This package may be distributed freely for non-commercial purposes along
  9. with Xpk or on its own, provided that all files and subdirectories are
  10. left intact. However, all rights remain with the author. And as usual,
  11. the author will in no way be held responsible for any damage, directly,
  12. implicit or otherwise, resulting from the use of this program. After
  13. all, you get this program for free; use it or not as you like, and at
  14. your own risk. 
  15.  
  16. The file 'XFH.doc' (which should be distributed alone with this file)
  17. gives information on how to get started quickly while this text gives
  18. a more technical discussion of the XFH file system handler and
  19. describe some of the more obscure options that are not accessible
  20. through the gui. Some knowledge of the more technical aspects of the
  21. Amiga is assumed. Also, this document is pretty unstructured, being
  22. just a random collection of notes gathered together over the last year
  23. of XFH development. Do read XFH.doc first to get an overview of what
  24. XFH is. A lot of users probably don't wan't to read this file at all;
  25. XFH.doc will tell them all they need to know.
  26.  
  27.  
  28.                               --- O ---
  29.  
  30.  
  31. What's possible.
  32.  
  33.    XFH, when used with Xpk, makes it possible to store data in compressed
  34. format without this being visible to the user or to application programs -
  35. XFH will make the compressed data appear like ordinary files. This is by
  36. no means a new idea. In MS-DOS world, a (commercial) program called
  37. 'Stacker' has been available for some time, which makes it possible to
  38. compress a whole partition on a harddisk. On the amiga, people have long
  39. used powerpacker along with programs like PPMore to store data files in
  40. packed formats (but relying on the application to recognise that the file
  41. is in compressed format), and programs like PPPatch have been used to
  42. change dos.library to recognise the powerpacker format automatically.
  43. However, none of these approaches are perfect in all situations, and so
  44. there is room for another alternative - the XFH.
  45.  
  46.    XFH works in conjuction with the Xpk approach to data compression. This
  47. in itself gives a number of advantages - a flexible interface to the 
  48. compressing algorithms, lots of different packers available with the
  49. possibility to add new ones etc. But compared to approaches like 
  50. 'Stacker', there is an additional advantage: access to the compressed 
  51. data is not limited to XFH - most of the time, the XFH way will be the 
  52. most convenient way to access data, but if needed, the complete range of 
  53. Xpk applications is available to the user. The file orientated nature of 
  54. Xpk also means that XFH - like PPPatch etc., but unlike Stacker - will 
  55. co-exists nicely with any other Amiga filing system without the need to 
  56. set up any new partitions or prepare the disk with a special program. In 
  57. fact, if you happened to have a CD-Rom (read only) stuffed with 
  58. powerpacked files (or any other format that the current version of Xpk 
  59. supports), you could dump an XFH unit on top of it and largely forget 
  60. about the disk being compressed from then on.
  61.  
  62.    So, what is possible is to mount a XFH unit on top of each of one or
  63. more standard AmigaDOS directories. It is now possible for programs to
  64. access the directories as usual, data being decompressed and optionally
  65. compressed as needed in a completely transparent way - programs will
  66. never know the difference between compressed and uncompressed files -
  67. while still having access to the compressed data using conventional
  68. compress/uncompress programs. So the dream is that of doubling the
  69. capacity of your hard- or floppydisks for zero cost. 
  70.  
  71.    As an example of the possibilities of the XFH, I have been using it
  72. for holding various doc files, metafont sources and little used emacs
  73. scripts and shell commands on HD, saving in the order of perhaps 60%
  74. file space with no noticeable degrading of overall system performance.
  75.  
  76.  
  77.                               --- O ---
  78.  
  79.  
  80. What is the catch?
  81.  
  82.    Of course, as everyone knows, nothing comes for free. Obviously,
  83. there is a speed penalty to compressing or uncompressing a file.  This
  84. speed penalty will be highly dependent on the actual compression
  85. algorithm and data media used; for example an algebraic compression
  86. scheme used with a superfast HD will probably be rather slow, while a
  87. fast algorithm may actually result in a speed-up of floppy access since
  88. the disk access time saved by the smaller file size more that accounts
  89. for the time taken decompressing. And of course with the coming of ever
  90. more powerful CPU's the speed will be less of a problem. Some things
  91. will always be slow, though. Especially directory listning is a
  92. problem, since every single file has to be opened in order to check
  93. whether the file is compressed or not. In fact, I'll admit that running
  94. XFH from floppy on an unaccelerated amiga will sometimes seem a bit
  95. slow. However, XFH was not written to be as fast and small as possible,
  96. but rather to be flexible and expandable. And I'm sure a lot of users
  97. will find it very useful even on 'small' amigas. On an A3000, XFH runs
  98. like a dream, of course. And there is still the possibility for speed
  99. improvements in later versions. 
  100.  
  101.    Aside from the problem of speed, V1.32 of the XFH comes with a few 
  102. other limitations that I'm hoping to remove in later versions. Most 
  103. important is the lack of most of the new 2.0 packets, a lack that will 
  104. become more severe as more 2.0-only programs start to depend on these 
  105. packets. Another problem is that XFH in the present version is somewhat 
  106. memory-hungry, in that it will keep any compressed file completely 
  107. unpacked in memory as long as that file is open. This is mostly due to 
  108. limitations in the current Xpk interface, and I'm hoping to remove this 
  109. in a later release. However, currently this means that it is impossible 
  110. to open a compressed file if it is larger than available memory.
  111. [One way to solve this would be to have XFH use one of the 'virtual
  112. memory' programs that are starting to appear. In fact, I have had one
  113. or two reports about this actually working. If someone wants to
  114. discuss this I'd very much wellcome it.]
  115.  
  116.    A number of other problems to look out for are detailed in a later 
  117. section in this doc file. Most of these are things that could be fixed in 
  118. later versions.
  119.  
  120.  
  121.  
  122.                               --- O ---
  123.  
  124.  
  125. Instructions for use.
  126.  
  127.    XFH is implemented as an AmigaDOS device handler. The 'L:'
  128. directory contains examples of other such device handlers, and this is
  129. usually also the best place to put XFH (the file 'XFH-Handler', to be
  130. precise). Like other handlers, XFH must be mounted before it can be
  131. used. This can be done by creating an entry for it in the
  132. 'DEVS:Mountlist' file (just the mountlist for short) and issuing the
  133. command 'Mount <device>', where <device> is the name given to the
  134. device in the mountlist. The supplied file 'Devs/Mountlist.custom'
  135. contains example entries for the XFH; it might be convenient to append
  136. this file to the end of 'DEVS:Mountlist' (the entries assume an assign
  137. 'xfhdir:' to the XFH distribution directory). The most important part
  138. of each mountlist entry is the Device name (XH1: etc) and the 'Startup'
  139. entry, since these are used to configure the various options of XFH..
  140. Further information on the mechanism of mountlists and handlers in
  141. general can be found in various places; I will not attempt any lenghty
  142. explanation here.
  143.  
  144.    Unlike most other 'normal' device handlers, XFH needs additional 
  145. information to function correctly. Most importantly it needs to be told 
  146. what directory it should use as its root directory (that is, where it 
  147. should look for compressed files). In the simplest case, this can be done 
  148. by having an assigning (or device volume name)  'nn:' to this
  149. directory and mounting an XFH partition with the name 'Xnn:' (any
  150. letter will do, not just 'X'). However, XFH also provides 'options',
  151. some of which cannot be controlled by the gui but only through the
  152. Mountlist or by using Arexx.
  153.  
  154. Options can be specified in the mountlist or in an option file, and
  155. can be changed dynamically using AREXX. An option is specified as a
  156. string following the same conventions as the TOOLTYPES of the
  157. Workbench.
  158.  
  159. If the number of options that should be set are limited, it can be
  160. convenient to put them directly in the mountlist entry. This is done
  161. by using the 'Startup' keyword. Use a line of the form
  162.  
  163.     Startup = "!<opt1>=<value1>!<opt2>=<value2>...!<optN>=<valueN>"
  164.  
  165. (that is, a list of option assignments preceded by '!' (no spaces).
  166. The '"'s are optional and the '='s can be replaced with '&'s (this is
  167. nessesary to be compatible with some mount commands). See the entry
  168. for 'XH0:' in 'Devs/Mountlist.custom' for an example.
  169.  
  170. For a larger number of options, option files should be used. XFH has
  171. the concept of primary and secondary option files.  The primary option
  172. file is used by putting a line of the form
  173.  
  174.     Startup = xfhdir:optionfiles/.xfhrc_1
  175.  
  176. into the mountlist entry (distinguised from the other use of this
  177. keyword by the fact that no '!' appears). The filename can be anything
  178. you like, of course. The secondary option file is named '.xfhrc' and
  179. is placed in the root directory of the XFH unit (uncompressed!).  The
  180. settings in the secondary option file overrides any settings in the
  181. primary option file, but there are some restrictions on the options
  182. that can be used in the secondary option file, see below.  Both files
  183. are optional, the handler will pick default values for any options
  184. that are not set by the user.
  185.  
  186. In the option files, options are given each on a line of its own. Some
  187. examples are given in the directory 'Optionfiles'. Be careful when
  188. using the secondary option file; this is also used by XFH itself to
  189. store information that must be preserved across reboots (notably the
  190. volume name for Relabel).
  191.  
  192. When the handler is mounted, most options can be changed by sending an
  193. approproate AREXX command to the handler. The name of the port is the
  194. same as the name of the device, though this can be changed (see
  195. below). Note that XFH will refuce to mount if it cannot open the AREXX
  196. port because of a naming conflict. To set an option, send a command
  197.  
  198.     SETOPTION <optstring>
  199.  
  200. to the port, where <optstring> should be in the same format as that
  201. used in option files. The directory 'Arexx/' contains example AREXX
  202. scripts that may be usefull. For example the command
  203.  
  204.     rx SetAutocompress XDH1 ON
  205.  
  206. will enable automatic compression on XDH1:.
  207.  
  208.  
  209.    Boolean options can be specified with "NO" / "OFF" or. "YES" / "ON". 
  210. String options are specified by simply putting the string after the 
  211. 'OPTION=' bit, no quotes are needed.
  212.  
  213. The available options are detailed below:
  214.  
  215.    ROOTDIR
  216.    VOLUMENAME
  217.    AUTOCOMPRESS
  218.    PACKMODE
  219.    STEPDOWN
  220.    PASSWORD
  221.    XPKPRIORITY
  222.    TRUNCATEONPACK
  223.    FAILONEXNEXT
  224.    KILLSTARTUP
  225.    COMPRESSREADWRITE
  226.    ALLOWAPPEND
  227.    PORTNAME
  228.  
  229. Option ROOTDIR:
  230.  
  231.    This option is used to set the name of the directory that XFH: is
  232. to reside in. For example 'ROOTDIR=Work:xfh' would cause XFH: to use
  233. that directory as root. Note that this option can only be used in the
  234. primary option file or directly in the mountlist. When used elsewhere
  235. it will simply be ignored. The default is to use the name of the XFH
  236. device itself with the first character removed (so XDH1: becomes
  237. DH1:). [Note that this is different from XFH v1.12 and earlier.]
  238.  
  239. Option VOLUMENAME:
  240.  
  241.    This option is used to set the name of the XFH: volume. This is the
  242. name that will be used in absolute path specifications, as well as the
  243. one returned by Info(). Ie. if you go 'VOLUMENAME=Manuals', access can
  244. be by 'Manuals:' as well as by 'XHn:' (or whatever). If this option is
  245. not specified, the default is to use the name of the directory in the
  246. underlying file system, or (if this is itself the root of a volume) to
  247. use the name with 'XFH_' prepended. Again, this is mainly for
  248. compatibility with early versions of XFH:. An alternative to using
  249. this option is to use the normal Relabel (from shell or WB); this will
  250. automatically create an entry for this option in the secondary option
  251. file (replacing any existing entry).
  252.  
  253. Option AUTOCOMPRESS:
  254.  
  255.    This options tells whether XFH: should attempt to compress the
  256. files written through it. When this option is set, everytime a file
  257. written to the XFH: is closed, an attempt will be made to compress the
  258. file to a temporary file using Xpk. If this is succesfull, the
  259. temporary file will be renamed to the original name and the
  260. uncompressed file will be deleted. If the compression fails for any
  261. reason, the uncompressed file will simply remain intact. This also
  262. means that if anything should go wrong during compression (like a disk
  263. full error), it is unlikely that any data will be lost since at least
  264. one of the two files should be intact (though possibly with a wierd
  265. name). This option is OFF by default.
  266.  
  267. Option PACKMODE:
  268.  
  269.    This option selects the mode that Xpk should use when compressing
  270. files. It is specified in the usual way when using Xpk. For example,
  271. to use 12-bit BLZW compression, 'PACKMODE=BLZW.12' would be used. The
  272. default is to use the NUKE compression ('PACKMODE=NUKE'). Of course,
  273. to use a specific compression method, the nessesary sublibrary must be
  274. available in LIBS:.
  275.  
  276. Option STEPDOWN:
  277.  
  278.    This option controls the Xpk flag 'XPK_StepDown' during packing. If
  279. set, it means that Xpk is allowed to reduce packing efficiency if
  280. nessesary to save memory. Refer to the Xpk documentation for details.
  281. Default is OFF.
  282.  
  283. Option PASSWORD:
  284.  
  285.    This option is used to set the password that XFH: should pass on to
  286. Xpk when compressing or uncompressing. It should be noted that there
  287. is no attempt to keep this password safe from 'memory peekers'. Of
  288. course, storing the password in the option file isn't a good idea. A
  289. better idea is to use AREXX; the AREXX script 'SetPassword.rexx' in
  290. the directory 'Arexx/' may be helpful here. Note that if AUTOCOMPRESS
  291. is requested, files may still be saved unencrypted in low-memory or
  292. low-diskspace situations, and (depending on the underlying file system
  293. / disk device) part of the unencrypted data may still be physically
  294. stored on the disk after the deletion of the unencrypted file.
  295.  
  296.    If an attempt to open a file is made when XFH has been given the
  297. wrong password, the open will fail with error code 212 (Object wrong
  298. type).
  299.  
  300. Option XPKPRIORITY:
  301.  
  302.    This option is used to set the task priority that should be used
  303. when doing Xpk operations (compress/uncompress etc). Setting this to
  304. zero or less will prevent XFH from stealing all CPU-time from tasks
  305. running at a 'normal' priority. Note that it is possible to set the
  306. priority of the handler itself in the mountlist. If this option is not
  307. used, the handler will keep whatever priority it is running at when
  308. calling the Xpk library.
  309.  
  310. Option TRUNCATEONPACK:
  311.  
  312.    This option is somewhat technical in nature and can be safely
  313. ignored.  It is only used in case of an error occuring during the
  314. compression of a file. In this case, the compressed file has to be
  315. deleted, and if this option is set, the handler will try to call
  316. SetFileSize() first to truncate the file to 0 bytes (perhaps saving
  317. the flushing of a few buffers).  However, due to sparse documentation
  318. I'm uncertain whether this feature is stable, and hence it is OFF by
  319. default. Again, unless you are curious and don't mind risking
  320. crashes/data losses, forget about this option.
  321.  
  322. Option FAILONEXNEXT:
  323.  
  324. This option was included to solve a problem with some (or more likely
  325. most) programs that perform directory scanning.  The problem appears
  326. when listing a directory containing a file that is opened with an
  327. exclusive lock (for example, MODE_NEWFILE). In this case, XFH cannot
  328. determine the correct size of the file and thus fails with an
  329. appropriate error code. However, many programs just assume that the
  330. end of the directory has been reached. Setting this option to OFF will
  331. prevent XFH from reporting failure, returning a fileinfoblock with the
  332. wrong file size instead. Since this could result in data loss because
  333. programs will se the wrong file sizes, this option is ON by default.
  334.  
  335. Option KILLSTARTUP:
  336.  
  337. This option has been included to fix some problems with programs like
  338. 'Info' that examine data about file system handlers. It seems that
  339. these programs assume that the 'Startup' entry in the device node of
  340. any handler that supports volumes will be a FileSystemStartupMsg.
  341. However, in the case of XFH, it is a string. This behaviour seems to
  342. me to be completely unresonable, and thus a bug in these programs. The
  343. only way I could find to fix this was to have XFH manually erase the
  344. Startup field in the device node. This is not likely to be an
  345. officially supported way of poking the device node. Nevertheless, I
  346. had to agree that the problem is intolerable, and thus this option is
  347. on by default. However, it can be turned off if you have a mount
  348. command that does not like handlers that modify their device node.
  349.  
  350. Option COMPRESSREADWRITE:
  351.  
  352. This option controls whether new files opened with MODE_READWRITE will
  353. be compressed upon Close(). It is ON by default.
  354.  
  355. Option ALLOWAPPEND:
  356.  
  357. This option must be set to allow the writing to existing files (using
  358. MODE_READWRITE or MODE_OLDFILE). It is my personal opinion that
  359. compressed files shouldn't really be updated in place, since it
  360. requires first uncompressing the file on disk, then doing the Write(),
  361. then compressing the file again. However, some programs need this
  362. ability. This option is ON by default.
  363.  
  364. Option PORTNAME:
  365.  
  366. This option can be used to set the name of the AREXX port. This option
  367. can only be set in the option file or directly in the mountlist (no,
  368. you cannot set it using AREXX...). The default name is the same as the
  369. name of the XFH device.
  370.  
  371.  
  372. In case of an error during the scanning of the option files the handler
  373. will fail its initialisation and hence refuse to load with error code 114
  374. (Bad Template). Sorry, but there are currently no real error messages
  375. implented (this will hopefully be fixed in a later version). If the handler
  376. refuses to work for no apparent reason, be sure to tripple-check your
  377. option files for errors.
  378.  
  379.  
  380.  
  381.  
  382.                               --- O ---
  383.  
  384.  
  385. Limitations and known bugs.
  386.  
  387.    The error detection code in the initialisation part of the handler is 
  388. somewhat flaky - I've tried to make it resonably safe, but documentation 
  389. on the right way to start a handler is hard to find. What it means is 
  390. that it is a good idea to make sure that the handler is placed in L: and
  391. that the nessesary Xpk libraries are placed in libs: before starting the 
  392. handler (remember, XFH won't be able to tell you the reason if it was 
  393. unable to initialise for some reason). Another subtle problem is that due 
  394. to a quirk of the device list locking, it is vital (using XFH v1.32) that 
  395. the handler for the directory that XFH is to sit in is already loaded. 
  396. Usually this will not be a problem; however, if you are using 3rd party 
  397. filesystem handlers that are mounted after boot-up, you can avoid 
  398. problems by accessing them before mounting XFH (for example by creating 
  399. an assign (not late-binding) to them).
  400.  
  401.    It should be noted that the way the XFH makes the same files
  402. available by two different routes is not without its problems. One
  403. problem is connected to the volume name - XFH tries to be smart about
  404. it, but it will sometimes create a duplicate volume name which is a
  405. bad idea. To solve this problem the VOLUMENAME option should be used
  406. in an option file, or the XFH volume should be changed with Relabel.
  407. Another problem when mounting XFH in the root dir appears when using
  408. the 'Leave Out' feature of the 2.0 Workbench. Here, the '.backdrop' is
  409. duplicated in both volumes, making the left-out icons appear twice.
  410. I'm working on a decent solution to this problem. Meanwhile, I would
  411. recommend that XFH is mounted only on top of subdirectories.
  412.  
  413. To provide maximum transparency for application programs, both of the
  414. options AUTOCOMPRESS and ALLOWAPPEND should be set. This will make XFH
  415. compress files that are written to it 'on the fly', even for programs
  416. that update existing files (ie MODE_READWRITE, 'append mode', shell
  417. '>>' redirection etc). However, a bit of care is advised when using
  418. the ALLOWAPPEND option. For example, it is obviously not a good idea
  419. to have two programs writing to the same compressed file at the same
  420. time. Even worse, if one program is accessing a file on the underlying
  421. file system at the same time that another program is writing to the
  422. same file using XFH, XFH is unable to guard completely against data
  423. loss. Bevare of this situation. Another thing is that writing to a
  424. compressed file opened with MODE_OLDFILE (like Lha does) relies on the
  425. ACTION_CHANGE_MODE packet (to partially solve the problems just
  426. mentioned), and thus won't work using KS1.3 file systems or some file
  427. systems written before the apperance of KS2.0.
  428.  
  429.    Needless to say (but I'll say it anyway), you should not assign libs: 
  430. to a XFH unit unless you are absolutely sure of what you are doing. A 
  431. nice trap is to have the XFH call (and wait for) Xpk, which will then wait
  432. for XFH to load a particular library for it.
  433.  
  434.    It should be noted that any given unit of the XFH binds to a directory, 
  435. not to a DOS device. This means that, currently, it is not possible to 
  436. have a XFH unit working like DFx: - any access will refer to the disk that 
  437. was in the drive when the handler was started, not to the disk currently 
  438. in the drive.
  439.  
  440.    The figures reported by the shell 'Info' command are somewhat strange.
  441. The problem is that it isn't really possible to give sensible figures for
  442. 'NumBlocks' and 'NumBlocksUsed'. Currently, their values are the same as
  443. those for the underlying file system.
  444.  
  445.    XFH has problems with exclusive locks (for example trying to obtain an 
  446. exclusive lock on "/" or "foo//" will always fail).
  447.  
  448.    Some people have experienced problems when using XFH with the 
  449. arp.library. This is because a bug/feature in the apr.library function 
  450. CompareLock() (it declares two locks equal only if the lock->fl_Key 
  451. fields are equal, which is illegal according to the 2.0 DOS manual). 
  452. Under 2.0, the program in the directory 'patcharp' can be used to patch 
  453. arp to use the correct 2.0 SameLock() call. Also, I know of a program 
  454. that remaps the arp calls to the corresponding 2.0 dos.library calls 
  455. (though I haven't tried it), it might help too.
  456.  
  457.  
  458.  
  459.                               --- O ---
  460.  
  461.  
  462. Theory of operation.
  463.  
  464.    XFH works by installing itself in the system as a file system handler 
  465. like DF0: or RAM:. However, unlike most file system handlers, which sit on 
  466. top of a device (or rest in themselves like RAM:), XFH sits on top of an 
  467. underlying file system handler (abbrevated to UFS) containing a mixture 
  468. of normal and compressed files. After initialising itself, XFH sits in a 
  469. loop receiving packets from AmigaDOS and other applications. Each packet 
  470. is examined and the appropriate action taken. For example, an open request 
  471. will cause XFH to open the given file, check whether it is compressed, and 
  472. if so unpack it to memory for later read requests.
  473.  
  474.    XFH is currently single-threaded, unlike the Commodore file systems 
  475. (this means that it is not possible for the XFH to service other requests 
  476. while waiting for the UFS). I'm hoping to fix this in some later version.
  477.  
  478.  
  479.  
  480.                               --- O ---
  481.  
  482.  
  483. Acknowledgments.
  484.  
  485.    The author wishes to thank all the people that have participated in 
  486. the development of Xpk without which the XFH would not have been the 
  487. same. I am especially grateful to Urban D. Müller for helping me start
  488. the whole concept of the XFH back in the summer of 1991 - without his 
  489. help the XFH is not likely to have been realised. Thanks also to the many 
  490. beta testers who helped me iron out as many bugs as possible before 
  491. release; your help work has been very valuable to me. And thanks must 
  492. go, of course, to the guys at Commodore for bringing to us the wonderful 
  493. Amiga.
  494.  
  495.  
  496. [Local variables for Emacs:]
  497. Local Variables:
  498. mode: text
  499. End:
  500.