0001 .. SPDX-License-Identifier: GPL-2.0
0002
0003 ====================
0004 Read/Write HPFS 2.09
0005 ====================
0006
0007 1998-2004, Mikulas Patocka
0008
0009 :email: mikulas@artax.karlin.mff.cuni.cz
0010 :homepage: https://artax.karlin.mff.cuni.cz/~mikulas/vyplody/hpfs/index-e.cgi
0011
0012 Credits
0013 =======
0014 Chris Smith, 1993, original read-only HPFS, some code and hpfs structures file
0015 is taken from it
0016
0017 Jacques Gelinas, MSDos mmap, Inspired by fs/nfs/mmap.c (Jon Tombs 15 Aug 1993)
0018
0019 Werner Almesberger, 1992, 1993, MSDos option parser & CR/LF conversion
0020
0021 Mount options
0022
0023 uid=xxx,gid=xxx,umask=xxx (default uid=gid=0 umask=default_system_umask)
0024 Set owner/group/mode for files that do not have it specified in extended
0025 attributes. Mode is inverted umask - for example umask 027 gives owner
0026 all permission, group read permission and anybody else no access. Note
0027 that for files mode is anded with 0666. If you want files to have 'x'
0028 rights, you must use extended attributes.
0029 case=lower,asis (default asis)
0030 File name lowercasing in readdir.
0031 conv=binary,text,auto (default binary)
0032 CR/LF -> LF conversion, if auto, decision is made according to extension
0033 - there is a list of text extensions (I thing it's better to not convert
0034 text file than to damage binary file). If you want to change that list,
0035 change it in the source. Original readonly HPFS contained some strange
0036 heuristic algorithm that I removed. I thing it's danger to let the
0037 computer decide whether file is text or binary. For example, DJGPP
0038 binaries contain small text message at the beginning and they could be
0039 misidentified and damaged under some circumstances.
0040 check=none,normal,strict (default normal)
0041 Check level. Selecting none will cause only little speedup and big
0042 danger. I tried to write it so that it won't crash if check=normal on
0043 corrupted filesystems. check=strict means many superfluous checks -
0044 used for debugging (for example it checks if file is allocated in
0045 bitmaps when accessing it).
0046 errors=continue,remount-ro,panic (default remount-ro)
0047 Behaviour when filesystem errors found.
0048 chkdsk=no,errors,always (default errors)
0049 When to mark filesystem dirty so that OS/2 checks it.
0050 eas=no,ro,rw (default rw)
0051 What to do with extended attributes. 'no' - ignore them and use always
0052 values specified in uid/gid/mode options. 'ro' - read extended
0053 attributes but do not create them. 'rw' - create extended attributes
0054 when you use chmod/chown/chgrp/mknod/ln -s on the filesystem.
0055 timeshift=(-)nnn (default 0)
0056 Shifts the time by nnn seconds. For example, if you see under linux
0057 one hour more, than under os/2, use timeshift=-3600.
0058
0059
0060 File names
0061 ==========
0062
0063 As in OS/2, filenames are case insensitive. However, shell thinks that names
0064 are case sensitive, so for example when you create a file FOO, you can use
0065 'cat FOO', 'cat Foo', 'cat foo' or 'cat F*' but not 'cat f*'. Note, that you
0066 also won't be able to compile linux kernel (and maybe other things) on HPFS
0067 because kernel creates different files with names like bootsect.S and
0068 bootsect.s. When searching for file thats name has characters >= 128, codepages
0069 are used - see below.
0070 OS/2 ignores dots and spaces at the end of file name, so this driver does as
0071 well. If you create 'a. ...', the file 'a' will be created, but you can still
0072 access it under names 'a.', 'a..', 'a . . . ' etc.
0073
0074
0075 Extended attributes
0076 ===================
0077
0078 On HPFS partitions, OS/2 can associate to each file a special information called
0079 extended attributes. Extended attributes are pairs of (key,value) where key is
0080 an ascii string identifying that attribute and value is any string of bytes of
0081 variable length. OS/2 stores window and icon positions and file types there. So
0082 why not use it for unix-specific info like file owner or access rights? This
0083 driver can do it. If you chown/chgrp/chmod on a hpfs partition, extended
0084 attributes with keys "UID", "GID" or "MODE" and 2-byte values are created. Only
0085 that extended attributes those value differs from defaults specified in mount
0086 options are created. Once created, the extended attributes are never deleted,
0087 they're just changed. It means that when your default uid=0 and you type
0088 something like 'chown luser file; chown root file' the file will contain
0089 extended attribute UID=0. And when you umount the fs and mount it again with
0090 uid=luser_uid, the file will be still owned by root! If you chmod file to 444,
0091 extended attribute "MODE" will not be set, this special case is done by setting
0092 read-only flag. When you mknod a block or char device, besides "MODE", the
0093 special 4-byte extended attribute "DEV" will be created containing the device
0094 number. Currently this driver cannot resize extended attributes - it means
0095 that if somebody (I don't know who?) has set "UID", "GID", "MODE" or "DEV"
0096 attributes with different sizes, they won't be rewritten and changing these
0097 values doesn't work.
0098
0099
0100 Symlinks
0101 ========
0102
0103 You can do symlinks on HPFS partition, symlinks are achieved by setting extended
0104 attribute named "SYMLINK" with symlink value. Like on ext2, you can chown and
0105 chgrp symlinks but I don't know what is it good for. chmoding symlink results
0106 in chmoding file where symlink points. These symlinks are just for Linux use and
0107 incompatible with OS/2. OS/2 PmShell symlinks are not supported because they are
0108 stored in very crazy way. They tried to do it so that link changes when file is
0109 moved ... sometimes it works. But the link is partly stored in directory
0110 extended attributes and partly in OS2SYS.INI. I don't want (and don't know how)
0111 to analyze or change OS2SYS.INI.
0112
0113
0114 Codepages
0115 =========
0116
0117 HPFS can contain several uppercasing tables for several codepages and each
0118 file has a pointer to codepage its name is in. However OS/2 was created in
0119 America where people don't care much about codepages and so multiple codepages
0120 support is quite buggy. I have Czech OS/2 working in codepage 852 on my disk.
0121 Once I booted English OS/2 working in cp 850 and I created a file on my 852
0122 partition. It marked file name codepage as 850 - good. But when I again booted
0123 Czech OS/2, the file was completely inaccessible under any name. It seems that
0124 OS/2 uppercases the search pattern with its system code page (852) and file
0125 name it's comparing to with its code page (850). These could never match. Is it
0126 really what IBM developers wanted? But problems continued. When I created in
0127 Czech OS/2 another file in that directory, that file was inaccessible too. OS/2
0128 probably uses different uppercasing method when searching where to place a file
0129 (note, that files in HPFS directory must be sorted) and when searching for
0130 a file. Finally when I opened this directory in PmShell, PmShell crashed (the
0131 funny thing was that, when rebooted, PmShell tried to reopen this directory
0132 again :-). chkdsk happily ignores these errors and only low-level disk
0133 modification saved me. Never mix different language versions of OS/2 on one
0134 system although HPFS was designed to allow that.
0135 OK, I could implement complex codepage support to this driver but I think it
0136 would cause more problems than benefit with such buggy implementation in OS/2.
0137 So this driver simply uses first codepage it finds for uppercasing and
0138 lowercasing no matter what's file codepage index. Usually all file names are in
0139 this codepage - if you don't try to do what I described above :-)
0140
0141
0142 Known bugs
0143 ==========
0144
0145 HPFS386 on OS/2 server is not supported. HPFS386 installed on normal OS/2 client
0146 should work. If you have OS/2 server, use only read-only mode. I don't know how
0147 to handle some HPFS386 structures like access control list or extended perm
0148 list, I don't know how to delete them when file is deleted and how to not
0149 overwrite them with extended attributes. Send me some info on these structures
0150 and I'll make it. However, this driver should detect presence of HPFS386
0151 structures, remount read-only and not destroy them (I hope).
0152
0153 When there's not enough space for extended attributes, they will be truncated
0154 and no error is returned.
0155
0156 OS/2 can't access files if the path is longer than about 256 chars but this
0157 driver allows you to do it. chkdsk ignores such errors.
0158
0159 Sometimes you won't be able to delete some files on a very full filesystem
0160 (returning error ENOSPC). That's because file in non-leaf node in directory tree
0161 (one directory, if it's large, has dirents in tree on HPFS) must be replaced
0162 with another node when deleted. And that new file might have larger name than
0163 the old one so the new name doesn't fit in directory node (dnode). And that
0164 would result in directory tree splitting, that takes disk space. Workaround is
0165 to delete other files that are leaf (probability that the file is non-leaf is
0166 about 1/50) or to truncate file first to make some space.
0167 You encounter this problem only if you have many directories so that
0168 preallocated directory band is full i.e.::
0169
0170 number_of_directories / size_of_filesystem_in_mb > 4.
0171
0172 You can't delete open directories.
0173
0174 You can't rename over directories (what is it good for?).
0175
0176 Renaming files so that only case changes doesn't work. This driver supports it
0177 but vfs doesn't. Something like 'mv file FILE' won't work.
0178
0179 All atimes and directory mtimes are not updated. That's because of performance
0180 reasons. If you extremely wish to update them, let me know, I'll write it (but
0181 it will be slow).
0182
0183 When the system is out of memory and swap, it may slightly corrupt filesystem
0184 (lost files, unbalanced directories). (I guess all filesystem may do it).
0185
0186 When compiled, you get warning: function declaration isn't a prototype. Does
0187 anybody know what does it mean?
0188
0189
0190 What does "unbalanced tree" message mean?
0191 =========================================
0192
0193 Old versions of this driver created sometimes unbalanced dnode trees. OS/2
0194 chkdsk doesn't scream if the tree is unbalanced (and sometimes creates
0195 unbalanced trees too :-) but both HPFS and HPFS386 contain bug that it rarely
0196 crashes when the tree is not balanced. This driver handles unbalanced trees
0197 correctly and writes warning if it finds them. If you see this message, this is
0198 probably because of directories created with old version of this driver.
0199 Workaround is to move all files from that directory to another and then back
0200 again. Do it in Linux, not OS/2! If you see this message in directory that is
0201 whole created by this driver, it is BUG - let me know about it.
0202
0203
0204 Bugs in OS/2
0205 ============
0206
0207 When you have two (or more) lost directories pointing each to other, chkdsk
0208 locks up when repairing filesystem.
0209
0210 Sometimes (I think it's random) when you create a file with one-char name under
0211 OS/2, OS/2 marks it as 'long'. chkdsk then removes this flag saying "Minor fs
0212 error corrected".
0213
0214 File names like "a .b" are marked as 'long' by OS/2 but chkdsk "corrects" it and
0215 marks them as short (and writes "minor fs error corrected"). This bug is not in
0216 HPFS386.
0217
0218 Codepage bugs described above
0219 =============================
0220
0221 If you don't install fixpacks, there are many, many more...
0222
0223
0224 History
0225 =======
0226
0227 ====== =========================================================================
0228 0.90 First public release
0229 0.91 Fixed bug that caused shooting to memory when write_inode was called on
0230 open inode (rarely happened)
0231 0.92 Fixed a little memory leak in freeing directory inodes
0232 0.93 Fixed bug that locked up the machine when there were too many filenames
0233 with first 15 characters same
0234 Fixed write_file to zero file when writing behind file end
0235 0.94 Fixed a little memory leak when trying to delete busy file or directory
0236 0.95 Fixed a bug that i_hpfs_parent_dir was not updated when moving files
0237 1.90 First version for 2.1.1xx kernels
0238 1.91 Fixed a bug that chk_sectors failed when sectors were at the end of disk
0239 Fixed a race-condition when write_inode is called while deleting file
0240 Fixed a bug that could possibly happen (with very low probability) when
0241 using 0xff in filenames.
0242
0243 Rewritten locking to avoid race-conditions
0244
0245 Mount option 'eas' now works
0246
0247 Fsync no longer returns error
0248
0249 Files beginning with '.' are marked hidden
0250
0251 Remount support added
0252
0253 Alloc is not so slow when filesystem becomes full
0254
0255 Atimes are no more updated because it slows down operation
0256
0257 Code cleanup (removed all commented debug prints)
0258 1.92 Corrected a bug when sync was called just before closing file
0259 1.93 Modified, so that it works with kernels >= 2.1.131, I don't know if it
0260 works with previous versions
0261
0262 Fixed a possible problem with disks > 64G (but I don't have one, so I can't
0263 test it)
0264
0265 Fixed a file overflow at 2G
0266
0267 Added new option 'timeshift'
0268
0269 Changed behaviour on HPFS386: It is now possible to operate on HPFS386 in
0270 read-only mode
0271
0272 Fixed a bug that slowed down alloc and prevented allocating 100% space
0273 (this bug was not destructive)
0274 1.94 Added workaround for one bug in Linux
0275
0276 Fixed one buffer leak
0277
0278 Fixed some incompatibilities with large extended attributes (but it's still
0279 not 100% ok, I have no info on it and OS/2 doesn't want to create them)
0280
0281 Rewritten allocation
0282
0283 Fixed a bug with i_blocks (du sometimes didn't display correct values)
0284
0285 Directories have no longer archive attribute set (some programs don't like
0286 it)
0287
0288 Fixed a bug that it set badly one flag in large anode tree (it was not
0289 destructive)
0290 1.95 Fixed one buffer leak, that could happen on corrupted filesystem
0291
0292 Fixed one bug in allocation in 1.94
0293 1.96 Added workaround for one bug in OS/2 (HPFS locked up, HPFS386 reported
0294 error sometimes when opening directories in PMSHELL)
0295
0296 Fixed a possible bitmap race
0297
0298 Fixed possible problem on large disks
0299
0300 You can now delete open files
0301
0302 Fixed a nondestructive race in rename
0303 1.97 Support for HPFS v3 (on large partitions)
0304
0305 ZFixed a bug that it didn't allow creation of files > 128M
0306 (it should be 2G)
0307 1.97.1 Changed names of global symbols
0308
0309 Fixed a bug when chmoding or chowning root directory
0310 1.98 Fixed a deadlock when using old_readdir
0311 Better directory handling; workaround for "unbalanced tree" bug in OS/2
0312 1.99 Corrected a possible problem when there's not enough space while deleting
0313 file
0314
0315 Now it tries to truncate the file if there's not enough space when
0316 deleting
0317
0318 Removed a lot of redundant code
0319 2.00 Fixed a bug in rename (it was there since 1.96)
0320 Better anti-fragmentation strategy
0321 2.01 Fixed problem with directory listing over NFS
0322
0323 Directory lseek now checks for proper parameters
0324
0325 Fixed race-condition in buffer code - it is in all filesystems in Linux;
0326 when reading device (cat /dev/hda) while creating files on it, files
0327 could be damaged
0328 2.02 Workaround for bug in breada in Linux. breada could cause accesses beyond
0329 end of partition
0330 2.03 Char, block devices and pipes are correctly created
0331
0332 Fixed non-crashing race in unlink (Alexander Viro)
0333
0334 Now it works with Japanese version of OS/2
0335 2.04 Fixed error when ftruncate used to extend file
0336 2.05 Fixed crash when got mount parameters without =
0337
0338 Fixed crash when allocation of anode failed due to full disk
0339
0340 Fixed some crashes when block io or inode allocation failed
0341 2.06 Fixed some crash on corrupted disk structures
0342
0343 Better allocation strategy
0344
0345 Reschedule points added so that it doesn't lock CPU long time
0346
0347 It should work in read-only mode on Warp Server
0348 2.07 More fixes for Warp Server. Now it really works
0349 2.08 Creating new files is not so slow on large disks
0350
0351 An attempt to sync deleted file does not generate filesystem error
0352 2.09 Fixed error on extremely fragmented files
0353 ====== =========================================================================