• BDOS 40

    From dxforth@21:1/5 to All on Thu Dec 30 12:34:30 2021
    I'm contemplating using this in my compiler instead of BDOS 34.
    AFAIK BDOS 40 avoids the problem of 'sparse files' which most
    file utilities can't handle anyway.

    My question - what's wrong with BDOS 40 given almost nobody
    appears to use it?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From dxforth@21:1/5 to Martin on Thu Dec 30 15:49:57 2021
    On 30/12/2021 15:29, Martin wrote:
    Am 12/30/2021 02:34 AM, dxforth schrieb:
    I'm contemplating using this in my compiler instead of BDOS 34.
    AFAIK BDOS 40 avoids the problem of 'sparse files' which most
    file utilities can't handle anyway.

    My question - what's wrong with BDOS 40 given almost nobody
    appears to use it?




    You zero fill the remainder of only one block.
    The rest of the extent and all other extents before and after
    remain sparse the same as for BDOS 34.
    So this does not help in any way.

    I don't want to first find out the block size of the drive in
    the program I write just in order to use that BDOS call.

    To add this BDOS call IMHO was a bad idea, and I would acknowledge and respect past experience to better NOT use it.

    Ok, so not much use. When you say "one block" you mean disk block
    e.g. 2K, 4K etc. ? That would wipe out other records in the block?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Martin@21:1/5 to dxforth on Thu Dec 30 05:29:55 2021
    Am 12/30/2021 02:34 AM, dxforth schrieb:
    I'm contemplating using this in my compiler instead of BDOS 34.
    AFAIK BDOS 40 avoids the problem of 'sparse files' which most
    file utilities can't handle anyway.

    My question - what's wrong with BDOS 40 given almost nobody
    appears to use it?




    You zero fill the remainder of only one block.
    The rest of the extent and all other extents before and after
    remain sparse the same as for BDOS 34.
    So this does not help in any way.

    I don't want to first find out the block size of the drive in
    the program I write just in order to use that BDOS call.

    To add this BDOS call IMHO was a bad idea, and I would acknowledge and
    respect past experience to better NOT use it.


    HTH
    Martin

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From dxforth@21:1/5 to dxforth on Thu Dec 30 16:04:11 2021
    On 30/12/2021 15:49, dxforth wrote:
    On 30/12/2021 15:29, Martin wrote:
    Am 12/30/2021 02:34 AM, dxforth schrieb:
    I'm contemplating using this in my compiler instead of BDOS 34.
    AFAIK BDOS 40 avoids the problem of 'sparse files' which most
    file utilities can't handle anyway.

    My question - what's wrong with BDOS 40 given almost nobody
    appears to use it?




    You zero fill the remainder of only one block.
    The rest of the extent and all other extents before and after
    remain sparse the same as for BDOS 34.
    So this does not help in any way.

    I don't want to first find out the block size of the drive in
    the program I write just in order to use that BDOS call.

    To add this BDOS call IMHO was a bad idea, and I would acknowledge and
    respect past experience to better NOT use it.

    Ok, so not much use. When you say "one block" you mean disk block
    e.g. 2K, 4K etc. ? That would wipe out other records in the block?

    Not to worry. I read the spec again and it says "previously unallocated block".

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Martin@21:1/5 to dxforth on Thu Dec 30 07:10:38 2021
    Am 12/30/2021 05:49 AM, dxforth schrieb:
    On 30/12/2021 15:29, Martin wrote:
    Am 12/30/2021 02:34 AM, dxforth schrieb:
    I'm contemplating using this in my compiler instead of BDOS 34.
    AFAIK BDOS 40 avoids the problem of 'sparse files' which most
    file utilities can't handle anyway.

    My question - what's wrong with BDOS 40 given almost nobody
    appears to use it?




    You zero fill the remainder of only one block.
    The rest of the extent and all other extents before and after
    remain sparse the same as for BDOS 34.
    So this does not help in any way.

    I don't want to first find out the block size of the drive in
    the program I write just in order to use that BDOS call.

    To add this BDOS call IMHO was a bad idea, and I would acknowledge and
    respect past experience to better NOT use it.

    Ok, so not much use. When you say "one block" you mean disk block
    e.g. 2K, 4K etc. ? That would wipe out other records in the block?

    Here is a nice introduction into BDOS expecially using and comparing
    the differences between BDOS 34 and DBOS 40 (Part III):

    <https://hc-ddr.hucki.net/wiki/doku.php/cpm/sliding_into_bdos>

    After you previously used that function there is no way to find out
    if that "Zero's" were part of the unused part of your file.


    I just tried out the example on a real CP/M 2.2 system.
    To check what was really written I used ZAP.COM, a file/disk editor.
    You have to configure it for your terminal once,
    but then it has a very nice full screen interface.

    This is the directory entry on my drive, it is the same in
    both cases:

    :fRANDFILE.TST
    40 0052414E 4446494C 45545354 0100000D *.RANDFILETST....*
    50 41000000 00000000 42000000 00000000 *A.......B.......*
    G=00:00, T=3, S=1, PS=0


    The first example using WRITE RANDOM:
    Record 0 is written with 'A'
    Record 1-15 contain garbage (the first block of the first extent)
    Record 128-142 contain garbage (the second allocation block
    of the second extent)
    Record 143 is written with 'B'

    The program modified to youe WRITE RANDOM the second time
    (modified as in the article):
    Record 0 is written with 'A'
    Record 1-15 contain garbage (the first block of the first extent)
    Record 128-142 contain *00s* (the first allocation block
    of the second extent)
    Record 143 is written with 'B'

    On my drive the block size just happens to be 16 records so record
    16-128 are not allocated and record 143 is the last record of the
    block.


    In the "Programmer's CP/M Handbook" by Andy Johnson-Laird there is a
    hint why this function exists at all:

    [Purpose
    This function is an extension to the Write Random function described pre- viously. In addition to performing the Write Random, it will also fill each new allocation block with OOH's. Digital Research added this function to assist Micro-
    soft with the production of its COBOL compiler-it makes the logic of the file handling code easier. It also is an economical way to completely fill a random file
    with OOH's. You need only write one record *per allocation block*; the BOOS will
    clear the rest of the block for you.]

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Martin@21:1/5 to Martin on Thu Dec 30 07:25:55 2021
    Am 12/30/2021 07:10 AM, Martin schrieb:
    I just tried out the example on a real CP/M 2.2 system.
    To check what was really written I used ZAP.COM, a file/disk editor.
    You have to configure it for your terminal once,
    but then it has a very nice full screen interface.


    Ooops:
    Before posting I also tried out to modify the example, to see what
    happens if I write record 140 instead:

    I used the directory record after running my modified example,
    so the last used record field does not match the example, sorry.
    Byte 4fh below really is 10h after having written record 143!


    RANDFILE.34 was created with BDOS 34.
    RANDFILE.40 was created with BDOS 40.
    RANDFILE.TST was created with BDOS 40 to record 140.

    a:stat *.*

    Recs Bytes Ext Acc
    144 4k 1 R/W B:RANDFILE.34
    144 4k 1 R/W B:RANDFILE.40
    141 4k 1 R/W B:RANDFILE.TST

    So, I should have used one of RANDFILE.34 or RANDFILE.40 below.


    This is the directory entry on my drive, it is the same in
    both cases:

    :fRANDFILE.TST
    40 0052414E 4446494C 45545354 0100000D *.RANDFILETST....*
    50 41000000 00000000 42000000 00000000 *A.......B.......*
    G=00:00, T=3, S=1, PS=0



    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Martin@21:1/5 to dxforth on Thu Dec 30 08:13:35 2021
    Am 12/30/2021 02:34 AM, dxforth schrieb:
    I'm contemplating using this in my compiler instead of BDOS 34.
    AFAIK BDOS 40 avoids the problem of 'sparse files' which most
    file utilities can't handle anyway.

    My question - what's wrong with BDOS 40 given almost nobody
    appears to use it?



    The situation seen from another perspective,
    how to emulate it.

    1) On a real system:

    It could work out nicely...
    Any unallocated block gives you an error on read,
    and any allocated block has zeroes in all unwritten
    records and also in all written records, where it
    just happens that the binary content is all zero's.

    But after having written one record with zero fill,
    the number of records returning zero data without
    error vs. returning an Error Code 01, 03, 04, 05, 06. is
    different on every distribution / drive.


    2) On an emulator:

    I just use seek/write whenever BDOS 34 or BDOS 40 is called.
    All data before the written record is then allocated (under
    Linux as sparse file).

    So seen from the CP/M system, every allocation block before
    the write is always allocated and returns an allocated zero record
    on read without error.

    I have not seen any problems in the past using this simplified
    BDOS implementation.


    Martin

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From dxforth@21:1/5 to Martin on Thu Dec 30 22:50:48 2021
    On 30/12/2021 17:10, Martin wrote:

    ...
    In the "Programmer's CP/M Handbook" by Andy Johnson-Laird there is a
    hint why this function exists at all:

    [Purpose
    This function is an extension to the Write Random function described pre- viously. In addition to performing the Write Random, it will also fill each new
    allocation block with OOH's. Digital Research added this function to assist Micro-
    soft with the production of its COBOL compiler-it makes the logic of the file handling code easier. It also is an economical way to completely fill a random file
    with OOH's. You need only write one record *per allocation block*; the BOOS will
    clear the rest of the block for you.]

    It could also be used to convert a sparse file to a regular file but the risk is it may no longer fit the disk. (Copying the file to empty disk should be ok however). Wonder if such a utility already exists? The zero-fill would result in good compression by SQ etc.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Martin@21:1/5 to dxforth on Thu Dec 30 13:58:00 2021
    Am 12/30/2021 12:50 PM, dxforth schrieb:

    It could also be used to convert a sparse file to a regular file but the
    risk
    is it may no longer fit the disk. (Copying the file to empty disk
    should be ok
    however). Wonder if such a utility already exists? The zero-fill would result
    in good compression by SQ etc.


    I also don't know such an utility. Tried NSWEEP and PIP, both stop at
    record 16 (after the first extent).

    Such an utility would probably use BDOS 35 to get the amount of used
    records of the file.

    It loops over every record with BDOS 33, and does BDOS 34 on success,
    skips 1 record on error 1, skips 128 records on error 4. The utility
    however doesn't need to use BDOS 40 itself.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)