Documentation
¶
Overview ¶
Package regfile opens files that are REGULAR files, and nothing else.
⚠⚠ Why this exists (issue #38). A directory on disk can hold things that are not files at all: a named pipe (FIFO), a Unix socket, a block or character device. Docker's overlay directories are full of them. Opening a named pipe for reading BLOCKS until something opens its other end — which, for a pipe nobody writes to, is forever. The local storage driver treated every entry that was not a folder or a symlink as a file and opened it to sniff its type, so one `mkfifo` anywhere under a local storage root hung the storage scan in `running` with nothing processed, and every scan after it queued behind the hung one. A socket or a device is no better: a socket cannot be opened at all, and opening a device can have side effects (a tape rewinds).
filex serves regular files and folders. Everything else is skipped by the walks (Special says which) and refused by every open that goes through here — and the open refuses WITHOUT blocking: an entry that turns into a pipe between the check and the open is opened non-blocking, looked at, and closed.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotRegular = errors.New("not a regular file")
ErrNotRegular is what an open of anything but a regular file answers. It is wrapped in an *fs.PathError, so errors.Is(err, ErrNotRegular) finds it.
Functions ¶
func OpenFile ¶
OpenFile is os.OpenFile for regular files only. A path that already exists as anything else — a folder included — is refused before it is opened: an open of a device node is itself an action. What is left is the race where a pipe appears between that look and the open; the open is therefore made non-blocking where the platform has pipes (see nonBlock), and the opened descriptor is checked again before it is handed out.
⚠ The flag stays on the returned file. On a regular file O_NONBLOCK changes nothing — disk reads and writes block the way they always do — so there is no second syscall to clear it.
Types ¶
type Skipped ¶
type Skipped struct {
// contains filtered or unexported fields
}
Skipped says, once per path, that a walk turned a special entry away.
⚠ Once per path per process, not once per walk: a storage is rescanned every few minutes, and the same named pipe reported on every pass buries everything else in the log. The zero value is ready to use; keep one per driver so a second storage with its own pipes still gets its own lines.