Skip to contentSkip to conversation

symlink_prefix

DISCUSSION [email protected] 4 participants 4 messages Jun 2, 2001 – Jun 3, 2001

lore
Share & tools
lore
#0 lore raw

This evening I needed to work on a filesystem of a non-Linux OS, full of absolute symlinks. After mounting the fs on /mnt, each symlink pointing to /foo/bar in that filesystem should be regarded as pointing to /mnt/foo/bar.

Since doing ls -ld on every component of every pathname was far too slow, I made a small kernel wart, where a mount option -o symlink_prefix=/pathname would cause /pathname to be prepended in front of every absolute symlink in the given filesystem (when the symlink is followed). That works satisfactorily.

Remain the questions:
(i) is there already a mechanism that would achieve this? (ii) if not, do we want something like this in the kernel?

There is already a vaguely similar (and much uglier) wart, namely that of "altroot". It is really ugly - requires a path set at kernel compile time. And the scope is different. Instead of all processes and a single filesystem and symlinks only, altroot affects a single process and all filesystems and all paths.

I do not immediately see a common generalization of these two.

Andries

#1 lore raw
Quoted 10 lines · On 03 Jun 2001 01:54:43 +0200, [email protected] wrote:

This evening I needed to work on a filesystem of a non-Linux OS, full of absolute symlinks. After mounting the fs on /mnt, each symlink pointing to /foo/bar in that filesystem should be regarded as pointing to /mnt/foo/bar.

Since doing ls -ld on every component of every pathname was far too slow, I made a small kernel wart, where a mount option -o symlink_prefix=/pathname would cause /pathname to be prepended in front of every absolute symlink in the given filesystem (when the symlink is followed). That works satisfactorily.<snip>

unfortunately i cant speak for whether or not this patch is reengineering the work of altroot (i have no experience with it) or whether there are other similar approaches.

what i can say is that this is an excellent idea -- i have often cursed having absolute symlinsk v. relative ones and this option would provide a wonderful fix to that.

plus, i bet this is a rather simple and clean option.

i would like to see this in the kernel if it does not tread on any other similar feature.

Quoted 1 line

(i) is there already a mechanism that would achieve this?

cant answer

Quoted 1 line

(ii) if not, do we want something like this in the kernel?

for sure.

Signature · 3 lines
Robert M. Love
[email protected]
[email protected]
#2 lore raw
In reply to [email protected]
Quoted 15 lines · On Sun, 3 Jun 2001 [email protected] wrote:

This evening I needed to work on a filesystem of a non-Linux OS, full of absolute symlinks. After mounting the fs on /mnt, each symlink pointing to /foo/bar in that filesystem should be regarded as pointing to /mnt/foo/bar.

Since doing ls -ld on every component of every pathname was far too slow, I made a small kernel wart, where a mount option -o symlink_prefix=/pathname would cause /pathname to be prepended in front of every absolute symlink in the given filesystem (when the symlink is followed). That works satisfactorily.

Remain the questions:
(i) is there already a mechanism that would achieve this? (ii) if not, do we want something like this in the kernel?

Quoted 7 lines

There is already a vaguely similar (and much uglier) wart, namely that of "altroot". It is really ugly - requires a path set at kernel compile time. And the scope is different. Instead of all processes and a single filesystem and symlinks only, altroot affects a single process and all filesystems and all paths.

I do not immediately see a common generalization of these two.

altroot should be buried, not generalized. It was a mistake and we will be better off forgetting about that nightmare instead of trying to design something around it.

Absolute symlinks... Dunno. _If_ we want that at all, we probably want it on per-mountpoint basis. However, that opens a door to _really_ ugly feature requests. E.g. "if symlink starts with /foo - replace it with /mnt/bar, but if it starts with /foo/baz - replace with /mnt/splat instead".

I can see how to implement per-mountpoint variant. However, I'm less than enthusiastic about the API side of that and about the ugliness it will lead to. It smells like a wrong approach. And no, I don't see a good one right now.

As for the API... How would you pass that option? Yet another mount(2) argument?

#3 lore raw
In reply to [email protected]
Quoted 4 lines · Alexander Viro

I can see how to implement per-mountpoint variant. However, I'm less than enthusiastic about the API side of that and about the ugliness it will lead to. It smells like a wrong approach. And no, I don't see a good one right now.

Aren't we one day going to have stackable filesystems? This looks like an idea for a trivial translation filesystem to me.

-Mitch