Merge tag 'upstream/2.17'
authorBdale Garbee <bdale@gag.com>
Sun, 9 Mar 2014 20:24:12 +0000 (14:24 -0600)
committerBdale Garbee <bdale@gag.com>
Sun, 9 Mar 2014 20:24:12 +0000 (14:24 -0600)
Upstream version 2.17

Conflicts:
Makefile.in
cpm.5.in

1  2 
cpm.5.in
cpmls.c
fsck.cpm.1.in
fsed.cpm.1.in

diff --combined cpm.5.in
index 5e559c71e234d13ae205df7b13028ca195e54dd6,ce7779df200f4a350e28e769c027edcf1795bbdc..e73663b799620310ab1eefc8868c4e94dd3086a2
+++ b/cpm.5.in
@@@ -22,7 -22,9 +22,9 @@@ Number of directory entrie
  .br
  Logical sector skew
  .br
- Number of reserved system tracks
+ Number of reserved system tracks (optional)
+ .br
+ Offset to start of volume (optional)
  .sp
  .RE
  A block is the smallest allocatable storage unit.  CP/M supports block
@@@ -35,6 -37,8 +37,8 @@@ are stored with the given software skew
  A CP/M disk contains three areas:
  .RS
  .sp
+ Volume offset (optional)
+ .br
  System tracks (optional)
  .br
  Directory
@@@ -47,6 -51,18 +51,18 @@@ disk space, there are non-bootable form
  The term \fIdisk capacity\fP always excludes the space for system tracks.
  Note that there is no bitmap or list for free blocks.  When accessing a
  drive for the first time, CP/M builds this bitmap in core from the directory.
+ .LP
+ A hard disk can have the additional notion of a \fIvolume offset\fP to
+ locate the start of the drive image (which may or may not have system
+ tracks associated with it). The base unit for volume offset is byte
+ count from the beginning of the physical disk, but specifiers of
+ \fIK\fP, \fIM\fP, \fIT\fP or \fIS\fP may be appended to denote
+ kilobytes, megabytes, tracks or sectors.  If provided, a specifier
+ must immediately follow the numeric value with no whitespace.  For
+ convenience upper and lower case are both accepted and only the first
+ letter is significant, thus 2KB, 8MB, 1000trk and 16sec are valid
+ values. Offset must appear subsequent to track, sector and sector
+ length values.
  .\"}}}
  .SS "Directory entries" \"{{{
  The directory is a sequence of directory entries (also called extents),
@@@ -88,7 -104,7 +104,7 @@@ meaning
  .sp
  F0: requires set wheel byte (Backgrounder II)
  .br
 -F1: public file (P2DOS, ZSDOS), forground-only command (Backgrounder II)
 +F1: public file (P2DOS, ZSDOS), foreground-only command (Backgrounder II)
  .br
  F2: date stamp (ZSDOS), background-only commands (Backgrounder II)
  .br
@@@ -131,21 -147,25 +147,25 @@@ blocksize of 1024 byte with two-byte bl
  Rc stores the number of 128 byte records of the last used logical extent.
  Bc stores the number of bytes in the last used record.  The value 0 means
  128 for backward compatibility with CP/M 2.2, which did not support Bc.
+ ISX records the number of unused instead of used bytes in Bc.
  .\"}}}
  .LP
  .\"{{{ Al     = allocated blocks
- \fBAl\fP stores block pointers.  If the disk capacity is less than 256 blocks,
- Al is interpreted as 16 byte-values, otherwise as 8 double-byte-values.
- A block pointer of 0 marks a hole in the file.  If a hole
- covers the range of a full extent, the extent will not be allocated.  In particular,
- the first extent of a file does not necessarily have extent number 0.
- A file may not share blocks with other files, as its blocks would be freed
- if the other files is erased without a following disk system reset.  CP/M returns
- EOF when it reaches a hole, whereas UNIX returns zero-value bytes, which makes
- holes invisible.
+ \fBAl\fP stores block pointers.  If the disk capacity minus boot
+ tracks but including the directory area is less than 256 blocks, Al
+ is interpreted as 16 byte-values, otherwise as 8 double-byte-values.
+ Since the directory area is not subtracted, the directory area starts
+ with block 0 and files can never allocate block 0, which is why this
+ value can be given a new meaning: A block pointer of 0 marks a hole in
+ the file.  If a hole covers the range of a full extent, the extent will
+ not be allocated.  In particular, the first extent of a file does not
+ neccessarily have extent number 0.  A file may not share blocks with other
+ files, as its blocks would be freed if the other files is erased without
+ a following disk system reset.  CP/M returns EOF when it reaches a hole,
+ whereas UNIX returns zero-value bytes, which makes holes invisible.
  .\"}}}
  .\"}}}
- .SS "Time stamps" \"{{{
+ .SS "Native time stamps" \"{{{
  P2DOS and CP/M Plus support time stamps, which are stored in each fourth
  directory entry.  This entry contains the time stamps for
  the extents using the previous three directory entries.  Note that you
@@@ -180,6 -200,42 +200,42 @@@ time stamp
  .sp
  .RE
  .\"}}}
+ .SS "DateStamper time stamps" \"{{{
+ The DateStamper software added functions to the BDOS to manage
+ time stamps by allocating a read only file with the name "!!!TIME&.DAT"
+ in the very first directory entry, covering the very first data
+ blocks.  It contains one entry per directory entry with the
+ following structure of 16 bytes:
+ .RS
+ .sp
+ 5 bytes create datefield
+ .br
+ 5 bytes access datefield
+ .br
+ 5 bytes modify datefield
+ .br
+ 1 byte checksum
+ .sp
+ .RE
+ The checksum is only used on every 8th entry (last entry in 128-byte
+ record) and is the sum of the first 127 bytes of the record.
+ Each datefield has this structure:
+ .RS
+ .sp
+ 1 byte BCD coded year (no century, so it is sane assuming any year < 70
+ means 21st century)
+ .br
+ 1 byte BCD coded month
+ .br
+ 1 byte BCD coded day
+ .br
+ 1 byte BCD coded hour or, if the high bit is set, the high byte of a
+ counter for systems without real time clock
+ .br
+ 1 byte BCD coded minute, or the low byte of the counter
+ .sp
+ .DE
+ .\"}}}
  .SS "Disc labels" \"{{{
  CP/M Plus support disc labels, which are stored in an arbitrary directory
  entry.
diff --combined cpmls.c
index 1db4fba2748f6207f14e65893366bb326cbff5db,fa100e9d5e80fdfdf81cc29a11ad99c944680141..385b07fa8b17c3beb9f444d396c512bea83f7ef6
+++ b/cpmls.c
@@@ -116,6 -116,10 +116,10 @@@ static void oldddir(char **dirent, int 
            {
              tmp=localtime(&statbuf.mtime);
              printf("  %02d-%s-%04d %02d:%02d",tmp->tm_mday,month[tmp->tm_mon],tmp->tm_year+1900,tmp->tm_hour,tmp->tm_min);
+           }
+           else if (statbuf.ctime) printf("                   ");
+           if (statbuf.ctime)
+           {
              tmp=localtime(&statbuf.ctime);
              printf("  %02d-%s-%04d %02d:%02d",tmp->tm_mday,month[tmp->tm_mon],tmp->tm_year+1900,tmp->tm_hour,tmp->tm_min);
            }
@@@ -189,10 -193,17 +193,17 @@@ static void old3dir(char **dirent, int 
            else if (attrib & CPM_ATTR_PWWRITE) printf("Write  ");
            else if (attrib & CPM_ATTR_PWDEL)   printf("Delete "); 
            else printf("None   ");
-           tmp=localtime(&statbuf.mtime);
-           printf("%02d/%02d/%02d %02d:%02d  ",tmp->tm_mon+1,tmp->tm_mday,tmp->tm_year%100,tmp->tm_hour,tmp->tm_min);
-           tmp=localtime(&statbuf.ctime);
-           printf("%02d/%02d/%02d %02d:%02d",tmp->tm_mon+1,tmp->tm_mday,tmp->tm_year%100,tmp->tm_hour,tmp->tm_min);
+           if (statbuf.mtime)
+           {
+             tmp=localtime(&statbuf.mtime);
+             printf("%02d/%02d/%02d %02d:%02d  ",tmp->tm_mon+1,tmp->tm_mday,tmp->tm_year%100,tmp->tm_hour,tmp->tm_min);
+           }
+           else if (statbuf.ctime) printf("                ");
+           if (statbuf.ctime)
+           {
+             tmp=localtime(&statbuf.ctime);
+             printf("%02d/%02d/%02d %02d:%02d",tmp->tm_mon+1,tmp->tm_mday,tmp->tm_year%100,tmp->tm_hour,tmp->tm_min);
+           }
            putchar('\n');
            ++l;
          }
@@@ -325,7 -336,7 +336,7 @@@ int main(int argc, char *argv[]
    /* variables */ /*{{{*/
    const char *err;
    const char *image;
-   const char *format=FORMAT;
+   const char *format;
    const char *devopts=NULL;
    int c,usage=0;
    struct cpmSuperBlock drive;
    /*}}}*/
  
    /* parse options */ /*{{{*/
+   if (!(format=getenv("CPMTOOLSFMT"))) format=FORMAT;
    while ((c=getopt(argc,argv,"cT:f:ih?dDFlA"))!=EOF) switch(c)
    {
      case 'f': format=optarg; break;
  
    if (usage)
    {
 +#if HAVE_LIBDSK_H
      fprintf(stderr,"Usage: %s [-f format] [-T libdsk-type] [-d|-D|-F|-A|[-l][-c][-i]] image [file ...]\n",cmd);
 +#else
 +    fprintf(stderr,"Usage: %s [-f format] [-d|-D|-F|-A|[-l][-c][-i]] image [file ...]\n",cmd);
 +#endif
      exit(1);
    }
    /*}}}*/
diff --combined fsck.cpm.1.in
index 72930370f2bea58e7e4fb4ea64ba333762cf74fd,929074d95d25ca358d82cf4a23da7ac64748a236..04f861c5a5b8acde9671719130dfb872066dc993
@@@ -1,5 -1,5 +1,5 @@@
  .TH FSCK.CPM 1 "@UPDATED@" "CP/M tools" "User commands"
 -.SH NAME ..\"{{{roff}}}\"{{{
 +.SH NAME \"{{{roff}}}\"{{{
  fsck.cpm \- check a CP/M file system
  .\"}}}
  .SH SYNOPSIS .\"{{{
@@@ -37,12 -37,14 +37,15 @@@ Any errors are indicated by exit code 1
  .SH FILES .\"{{{
  @DATADIR@/diskdefs    CP/M disk format definitions
  .\"}}}
+ .SH ENVIRONMENT \"{{{
+ CPMTOOLSFMT     Default format
+ .\"}}}
  .SH DIAGNOSTICS .\"{{{
 -.IP "\fIimage\fP: \fIused\fP/\fItotal\fP files (\fIn\fP.\fIn\fP% non-contiguos), \fIused\fP/\fItotal\fP blocks"
 +.IP "\fIimage\fP: \fIused\fP/\fItotal\fP files (\fIn\fP.\fIn\fP% 
 +non-contiguous), \fIused\fP/\fItotal\fP blocks"
  No inconsistencies could be found.  The number of used files actually
  is the number of used extents.  Since a file may use more than
 -one extent, this may be greather than the actual number of files, but a
 +one extent, this may be greater than the actual number of files, but a
  correct measure would not reflect how many files could still be created
  at most.  A file is considered fragmented, if sequential data blocks
  pointed to by the same extent do not have sequential block numbers.
@@@ -50,8 -52,8 +53,8 @@@ The number of used blocks includes the 
  and the directory.
  .\"}}}
  .SH AUTHORS .\"{{{
- This program is copyright 1997\(en2010 Michael Haardt
- <michael@moria.de>.  The Windows port is copyright 2000, 2001 John Elliott
+ This program is copyright 1997\(en2012 Michael Haardt
+ <michael@moria.de>.  The Windows port is copyright 2000, 2001, 2011 John Elliott
  <jce@seasip.demon.co.uk>.
  .PP
  This program is free software; you can redistribute it and/or modify
diff --combined fsed.cpm.1.in
index dba7634896d3deb4ac8dbbecc1b325076f5fec46,596dfcf9ea3adc08078cef3ea4c489273942f78c..f0fd76f54f7a2b1679d797d4b7da95f5c2283a2e
@@@ -1,5 -1,5 +1,5 @@@
  .TH FSED.CPM 1 "@UPDATED@" "CP/M tools" "User commands"
 -.SH NAME ..\"{{{roff}}}\"{{{
 +.SH NAME \"{{{roff}}}\"{{{
  fsed.cpm \- edit a CP/M file system
  .\"}}}
  .SH SYNOPSIS .\"{{{
@@@ -26,12 -26,15 +26,15 @@@ Upon successful completion, exit code 
  .SH ERRORS .\"{{{
  Any errors are indicated by exit code 1.
  .\"}}}
+ .SH ENVIRONMENT \"{{{
+ CPMTOOLSFMT     Default format
+ .\"}}}
  .SH FILES .\"{{{
  @DATADIR@/diskdefs    CP/M disk format definitions
  .\"}}}
  .SH AUTHORS \"{{{
- This program is copyright 1997\(en2010 Michael Haardt
- <michael@moria.de>.  The Windows port is copyright 2000, 2001 John Elliott
+ This program is copyright 1997\(en2012 Michael Haardt
+ <michael@moria.de>.  The Windows port is copyright 2000, 2001, 2011 John Elliott
  <jce@seasip.demon.co.uk>.
  .PP
  This program is free software; you can redistribute it and/or modify