Hacker News new | ask | show | jobs
by amelius 3990 days ago
Can it also make immutable copies (snapshots) of the filesystem?
1 comments

Doubt it. That's something done by the filesystem itself and doesn't really belong in the shell. You can do it with btrfs or zfs though. LVM too.
Since I couldn't find your contact, I had to track you down here. Sorry :-)

It's OT; regarding attic. Could I shoot some basic questions, here or on an email?

But immutability is something I'd expect from a functional language/shell.
It's not something I'd expect. A shell deals with plumbing together programs and files, which are an abstraction over the actual raw filesystem (which is exposed by the kernel). For a shell to do true snapshots, it'd have to talk to the underlying filesystem. In theory this is possible I guess, but then your "shell" needs to be the compatible with the filesystem you're in, which is a very weird situation.

IMO a much better way to go about it would be to encode filesystem operations inside a monad. Then you could chain together filesystem operations to make up some sort of transformation, then after it's built up apply the operations to the real filesystem. It achieves something similar, but doesn't require any sort of filesystem support.

You can manually get filesystem snapshots with say `btrfs subvolume snapshot`, but the shell doesn't care about that. It doesn't ever deal with the filesystem directly, it either asks the kernel to do something or calls a program that asks the kernel to do something. To draw an analogy to databases (which are usually essentially based on immutable data structures in the sense that they're transactional), this would be like asking the postgresql command line client to handle making sure that the actual database manipulations are done transactionally. It doesn't quite make sense, that sort of business belongs in the postgresql server (which would be the OS kernel in our analogy here).