From Bill Birrell · 1996-04-13 17:15 · #75298 in R25C
In reply to Low Level File Access by Matthew Probert
Hey, Matthew Probert
I have honest difficulties with this article, Matthew, and I'm not sure how to address them. Head on may be best.
> By definition file access defines accessing a disk
> through an operating system.
No ... sorry ... it does nothing of the kind. So far in this article a 'file' is undefined. Let us define it as a retrievable organised collection of related information. Alternatively give your own which would have to be at least as accurate. A file does not have to be a computer file. A computer
file does not have to live on a peripheral storage device. A peripheral storage device does not have to be a block storage device (magnetic tapes, offline registers, printers, PTRs & PTPs). A Block Storage device does not have to be a disk (drums ... DCRs. DCDDs &c). A file can be stored in core memory, or even a filing cabinet. :-) A program or person does not have to go through an operating system to access a device, and thence to retrieve a file ... how
about low-level hard disk format programs, or the direct CD drivers?
This is wrong, Matthew, embarassingly so at every level, and it gives me no pleasure to say it, because misinforming newbies is one of my pet hates.
> The disk itself is simply a magnetic
> (or other)
> medium divided into areas sometimes called sectors or
> clusters.
Hard disks and their organisation is a hardware thing, Matthew. The programmer does not need to know or care about sectors unless he is writing an operating system. OTOH it is quite useful to know about logical I/O devices, (e.g. numbered LUNs in Fortran, major and minor devices in unix, device handles or symbolic names in Dos) because then one is in a position to know about buffering, for example, and thence to have a feeling for whether low level or high level routines are appropriate for controlling access to a storage device, be it block or character.
> The
> BIOS in a PC provides a means to access individual
> sectors, but this
> is not file access.
BIOS is hardware dependent by definition. It is the Digital Research (TM) acronym for the BASIC INPUT OUTPUT SYSTEM, and was originally that machine dependent portion of CP/M which interfaced the machine independent high level language elements of the operating system ( the BDOS, the CCP [and transient programs and later the NDOS]) written in PL/1 to the machine language ROM monitor if present or the underlying hardware if no ROM routines were available. It has *NOTHING* to do with the C language, certainly no more than the BDOS (BASIC Disk Operating System) has.
> With the C programming language two types of file
> access are
> supported; buffered and unbuffered. The first applies
> to file streams,
> the second, unbuffered access, refers to file handles.
> The difference
> in practical terms occurs when reading or writing to a
> file.
The C programming language specifies NO I/O at all. The standard libraries do. I know it's MsDos specific, but the article or the topic title does not say so ... That has to be said - otherwise:-
You did not mention access by owner, group and others ...
open() for MSDOS has a sibling _sopen() which allows file-sharing, and therefore, file locking ...
I broke off here, Matthew, because it is beginning to look as if I am carping. That is not my intent. The gulf is just a bit too wide for me to bridge on my own. I'm going to ask George and Mike and Ian ...
Hey guys ... help! This message of mine is distressingly discouraging, and I don't want to discourage anybody - the reverse is true, but it is wrong to sacrifice truth or accuracy to this much oversimplification, isn't it? Help me out, please. I know it's difficult, but that must be an argument in favour of going slowly and carefully, mustn't it?
Regards,
Bill.
---
* Origin: bill@escan.demon.co.uk (2:2504/200)