Live data from Hacker News

In Unix Everything Is a File

ph7spot.com

11–20 of 57 posts

Re: In Unix Everything Is a File

#11
post #6

Is the sendfile system call still the fastest way to transfer data locally on Linux systems? For communicating between processes running locally on system. Or, for example, a server running locally on an android device. Unix domain sockets typically beat TCP connections for most large file transfers. But is there anything faster? And what about transfers over the public net from machine to machine? I usually just use…

Consider trying rsync instead of scp - I've found it to be faster for multiple small files.

Re: In Unix Everything Is a File

#12
post #4

Which was the last Unix release/flavor where you could still read(2) a directory? All manpages that I've found say that you get EISDIR if you try it.

That depends on the file system (and, possibly, the OS, but I think the OS should just forward the call to the relevant driver and return its result)

FreeBSD’s man page says (https://www.freebsd.org/cgi/man.cgi?sektion=2&query=read):

  [EISDIR] The file descriptor is associated with a directory
           residing on a file system that does not allow 
           regular read operations on directories (e.g. NFS)
NetBSD says something similar, adding ”The readdir() function should be used instead.”

I also am not convinced that, for example, the Linux man page (http://man7.org/linux/man-pages/man2/read.2.html) guarantees you get EISDIR when reading from a directory. It says that if you get EISDIR, fd refers to a directory, but isn’t explicit about the converse.

Re: In Unix Everything Is a File

#13
post #9

"Everything is a file" is a nice idea not taken far enough. The execution is full of frustrating omissions and holes at the edges, e.g.: - unless you are using Plan 9 or gpm, reading mouse events is almost certainly going to be a lot more involved than opening /dev/mouse - you can't portably use select() to wait on pthread conditions - lots of useful things (like POSIX shared memory objects) are file descriptors, but…

That is easy, microservices über all.

I never had such appreciation for Plan 9, as I consider Inferno the best design of what they were trying to achieve.

The only caveat was that they never came around to add an ahead of time compilation support to DisVM.

Re: In Unix Everything Is a File

#14
post #6

Is the sendfile system call still the fastest way to transfer data locally on Linux systems? For communicating between processes running locally on system. Or, for example, a server running locally on an android device. Unix domain sockets typically beat TCP connections for most large file transfers. But is there anything faster? And what about transfers over the public net from machine to machine? I usually just use…

Shared memory is faster than sockets

Re: In Unix Everything Is a File

#17
post #12
post #4

Which was the last Unix release/flavor where you could still read(2) a directory? All manpages that I've found say that you get EISDIR if you try it.

That depends on the file system (and, possibly, the OS, but I think the OS should just forward the call to the relevant driver and return its result) FreeBSD’s man page says ( https://www.freebsd.org/cgi/man.cgi?sektion=2&query=read ): [EISDIR] The file descriptor is associated with a directory residing on a file system that does not allow regular read operations on directories (e.g. NFS) NetBSD says something simila…

You are right. The default implementation in Linux returns -EISDIR, but filesystems are free to change it to something else:

https://github.com/torvalds/linux/blob/2a56bb596b2c1fb612f99...

https://github.com/torvalds/linux/search?p=1&q=generic_read_...

Re: In Unix Everything Is a File

#18
post #11
post #6

Is the sendfile system call still the fastest way to transfer data locally on Linux systems? For communicating between processes running locally on system. Or, for example, a server running locally on an android device. Unix domain sockets typically beat TCP connections for most large file transfers. But is there anything faster? And what about transfers over the public net from machine to machine? I usually just use…

Consider trying rsync instead of scp - I've found it to be faster for multiple small files.

Piping tar works much faster too. It also allows preserving metadata.

Re: In Unix Everything Is a File

#19
And if you use XML, all you need to do, is to add another forward slash after the filename. And now, the network, the host and the data have become one: Everything is a node (or an atomic value).

But hey, that's stupid. Let's not do that...!

Re: In Unix Everything Is a File

#20
post #3

Wordpress strikes again. Page is from 2014. Archive link: https://web.archive.org/web/20091119184152/https://ph7spot.c... Edit: archive of 6 years ago with some styling: http://archive.is/B9He (The page actually loaded for me on the second try, and the design looks a lot more modern now.)

Your link says the page is from 2009, not 2014 (2009-11-19 to be exact).
Post reply on HN