tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Issues with lseek(2) on a block device



On Mon, 26 Feb 2024 09:20:21 -0500
Thor Lancelot Simon <tls%panix.com@localhost> wrote:

> On Sun, Feb 25, 2024 at 04:41:37PM +0000, Sad Clouds wrote:
> > 
> > The whole idea of Unix was "everything is a file" and the sooner people
> > get rid of magic ioctls the better.
> 
> But everything is *not*, actually, a file, and forcing things that
> are not files into file-like shapes is not always the right design
> choice.

It is not about forcing things into file-like shapes. For example
sockets are represented by file descriptors, but also have their own
UDP, TCP, SCTP, etc protocol options and API extensions. There is a
small set of core system calls which should work uniformly across all
objects represented by file descriptors - open, close, read, write,
stat, lseek, etc. The fact that you can use most of such system calls
with files, pipes, sockets, block devices, character devices, etc. is a
pretty good design in my humble opinion. For example System V shared
memory API is just horrid, compared to Posix file-like shm_open,
shm_close and mmap.

Thanks.


Home | Main Index | Thread Index | Old Index