Re: New option for ln, firmlinks!
On Sat, Jan 24, 2004 at 06:51:53PM +0100, Alfred M. Szmidt wrote: > The following hack implements the --firm/-m option for ln so that it > will create firm links. Now, most GNU/Linux people won't be familiar > with the concept, and I'm not really sure how to explain it either. > The best example I can think of that explains the difference between > symlinks and firmlinks is the following: I am not sure we really want to standardize the existence of this translator, and hardcode it into ln. At least not before we implemented the security precautions (limit the users which translators you follow by default). Thanks, Marcus -- `Rhubarb is no Egyptian god.' GNU http://www.gnu.org[EMAIL PROTECTED] Marcus Brinkmann The Hurd http://www.gnu.org/software/hurd/ [EMAIL PROTECTED] http://www.marcus-brinkmann.de/ ___ Bug-hurd mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/bug-hurd
Re: New option for ln, firmlinks!
> Well, can you do the something along the following with > bind-mountpoints (using settrans to be clear): > > $ settrans -ac /new-root/etc /hurd/firmlink /etc > $ chroot /new-root > $ cat /etc/passwd > > And get the content of REAL-ROOT/etc/passwd for example? Yes. The binding is evaluated at mount-time. Corking, maybe something like this could be added to libc when/if firmlink() moves there and then make --firm work with that too. Cheers! ___ Bug-hurd mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/bug-hurd
Re: New option for ln, firmlinks!
"Alfred M. Szmidt" <[EMAIL PROTECTED]> writes: > Well, can you do the something along the following with > bind-mountpoints (using settrans to be clear): > > $ settrans -ac /new-root/etc /hurd/firmlink /etc > $ chroot /new-root > $ cat /etc/passwd > > And get the content of REAL-ROOT/etc/passwd for example? Yes. The binding is evaluated at mount-time. Andreas. -- Andreas Schwab, SuSE Labs, [EMAIL PROTECTED] SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." ___ Bug-hurd mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/bug-hurd
Re: New option for ln, firmlinks!
> Was it possible to jump out of a chroot with bind's? Not sure what you mean. A bind-mountpoint behaves like any other mountpoint. Well, can you do the something along the following with bind-mountpoints (using settrans to be clear): $ settrans -ac /new-root/etc /hurd/firmlink /etc $ chroot /new-root $ cat /etc/passwd And get the content of REAL-ROOT/etc/passwd for example? Cheers. ___ Bug-hurd mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/bug-hurd
Re: New option for ln, firmlinks!
"Alfred M. Szmidt" <[EMAIL PROTECTED]> writes: >You can also bind-mount a regular file (and probably other types, I >didn't try yet). The only difference to firmlinks is, at it seems, >that the destination must already exist and it must be of the same >type as the source. > > Not entirerly true, the source and destination aren't the same in any > way, The last sentence above was attributed to bind mounts, not to firmlinks. > Was it possible to jump out of a chroot with bind's? Not sure what you mean. A bind-mountpoint behaves like any other mountpoint. Andreas. -- Andreas Schwab, SuSE Labs, [EMAIL PROTECTED] SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." ___ Bug-hurd mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/bug-hurd
Re: New option for ln, firmlinks!
You can also bind-mount a regular file (and probably other types, I didn't try yet). The only difference to firmlinks is, at it seems, that the destination must already exist and it must be of the same type as the source. Not entirerly true, the source and destination aren't the same in any way, the source just has a translator attached to it that transmits all file-system calls to the destination. But other than that, it does seem that they are quite the same. Was it possible to jump out of a chroot with bind's? I might note that `ln --firm TARGET LINK_NAME' is sugar for `settrans -cp TARGET /hurd/firmlink LINK_NAME`. The same really goes when using --symbolic; but with s/firm/sym/. But symbolic links are optimised a bit in the file-system, i.e. they aren't treated as "real" translators. Cheers. ___ Bug-hurd mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/bug-hurd
Re: New option for ln, firmlinks!
"Alfred M. Szmidt" <[EMAIL PROTECTED]> writes: >I don't know much about union file-systems, but AFAIK they are >different from bind mounts. A bind mount is created by "mount -o >bind /foo /bar" and causes the tree under /foo to be overlayed over >/bar, with the former contents of /bar being hidden. It's like a >regular mount, except that the source is not (a filesystem on) a >block device, but a directory. > > It does sound a bit similar to firmlinks. But firmlinks work on any > kind of type of file (directories, symlinks, ...). I don't know if > this bind file-system can be used across chroots, but firmlinks can. You can also bind-mount a regular file (and probably other types, I didn't try yet). The only difference to firmlinks is, at it seems, that the destination must already exist and it must be of the same type as the source. Andreas. -- Andreas Schwab, SuSE Labs, [EMAIL PROTECTED] SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." ___ Bug-hurd mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/bug-hurd
Re: New option for ln, firmlinks!
I don't know much about union file-systems, but AFAIK they are different from bind mounts. A bind mount is created by "mount -o bind /foo /bar" and causes the tree under /foo to be overlayed over /bar, with the former contents of /bar being hidden. It's like a regular mount, except that the source is not (a filesystem on) a block device, but a directory. It does sound a bit similar to firmlinks. But firmlinks work on any kind of type of file (directories, symlinks, ...). I don't know if this bind file-system can be used across chroots, but firmlinks can. Cheers. ___ Bug-hurd mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/bug-hurd
Re: New option for ln, firmlinks!
"Alfred M. Szmidt" <[EMAIL PROTECTED]> writes: >> hurd:/home/ams/coreutils/coreutils/src# ./ln -s /ams/foo symlink >> hurd:/home/ams/coreutils/coreutils/src# ./ln -m /ams/foo firmlink >> hurd:/home/ams/coreutils/coreutils/src# cd symlink >> hurd:/home/ams/coreutils/coreutils/src/symlink# ls .. >> foo hurd.obj lost+found oskit.obj sub-hurd >> hurd:/home/ams/coreutils/coreutils/src/symlink# cd ../firmlink >> hurd:/home/ams/coreutils/coreutils/src/firmlink# ls .. >> CVS >> Makefile >> Makefile.am >> [..snip...] > >This looks similar to bind mounts in Linux. > > Are those the same thing as union file-systems I don't know much about union file-systems, but AFAIK they are different from bind mounts. A bind mount is created by "mount -o bind /foo /bar" and causes the tree under /foo to be overlayed over /bar, with the former contents of /bar being hidden. It's like a regular mount, except that the source is not (a filesystem on) a block device, but a directory. Andreas. -- Andreas Schwab, SuSE Labs, [EMAIL PROTECTED] SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." ___ Bug-hurd mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/bug-hurd
Re: New option for ln, firmlinks!
> hurd:/home/ams/coreutils/coreutils/src# ./ln -s /ams/foo symlink > hurd:/home/ams/coreutils/coreutils/src# ./ln -m /ams/foo firmlink > hurd:/home/ams/coreutils/coreutils/src# cd symlink > hurd:/home/ams/coreutils/coreutils/src/symlink# ls .. > foo hurd.obj lost+found oskit.obj sub-hurd > hurd:/home/ams/coreutils/coreutils/src/symlink# cd ../firmlink > hurd:/home/ams/coreutils/coreutils/src/firmlink# ls .. > CVS > Makefile > Makefile.am > [..snip...] This looks similar to bind mounts in Linux. Are those the same thing as union file-systems (BSD has them, and the Hurd has a alpha translator for it written by Moritz Schulte; it was called shadow file-systems before)? Cheers. ___ Bug-hurd mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/bug-hurd
Re: New option for ln, firmlinks!
"Alfred M. Szmidt" <[EMAIL PROTECTED]> writes: > Howdy, > > The following hack implements the --firm/-m option for ln so that it > will create firm links. Now, most GNU/Linux people won't be familiar > with the concept, and I'm not really sure how to explain it either. > The best example I can think of that explains the difference between > symlinks and firmlinks is the following: > > hurd:/home/ams/coreutils/coreutils/src# ./ln -s /ams/foo symlink > hurd:/home/ams/coreutils/coreutils/src# ./ln -m /ams/foo firmlink > hurd:/home/ams/coreutils/coreutils/src# cd symlink > hurd:/home/ams/coreutils/coreutils/src/symlink# ls .. > foo hurd.obj lost+found oskit.obj sub-hurd > hurd:/home/ams/coreutils/coreutils/src/symlink# cd ../firmlink > hurd:/home/ams/coreutils/coreutils/src/firmlink# ls .. > CVS > Makefile > Makefile.am > [..snip...] This looks similar to bind mounts in Linux. Andreas. -- Andreas Schwab, SuSE Labs, [EMAIL PROTECTED] SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." ___ Bug-hurd mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/bug-hurd
New option for ln, firmlinks!
Howdy, The following hack implements the --firm/-m option for ln so that it will create firm links. Now, most GNU/Linux people won't be familiar with the concept, and I'm not really sure how to explain it either. The best example I can think of that explains the difference between symlinks and firmlinks is the following: hurd:/home/ams/coreutils/coreutils/src# ./ln -s /ams/foo symlink hurd:/home/ams/coreutils/coreutils/src# ./ln -m /ams/foo firmlink hurd:/home/ams/coreutils/coreutils/src# cd symlink hurd:/home/ams/coreutils/coreutils/src/symlink# ls .. foo hurd.obj lost+found oskit.obj sub-hurd hurd:/home/ams/coreutils/coreutils/src/symlink# cd ../firmlink hurd:/home/ams/coreutils/coreutils/src/firmlink# ls .. CVS Makefile Makefile.am [..snip...] hurd:/home/ams/coreutils/coreutils/src/firmlink# ls hurd:/home/ams/coreutils/coreutils/src/firmlink# ls /ams/foo hurd:/home/ams/coreutils/coreutils/src/firmlink# touch foo hurd:/home/ams/coreutils/coreutils/src/firmlink# ls -l total 0 -rw-r--r--1 root root0 Jan 25 02:48 foo hurd:/home/ams/coreutils/coreutils/src/firmlink# ls -l /ams/foo total 0 -rw-r--r--1 root root0 Jan 25 02:48 foo hurd:/home/ams/coreutils/coreutils/src/firmlink# As you see, a firmlink is more or less a "real" link, and doesn't exhibit the sometimes awkward behaviour of symbolic links (`ls ..' is one such example). Note that I didn't bother in creating a NEWS entry, or updating the manual. This is mostly a hack that I just wanted to share and get some comments about. For example, firmlink() should be moved into libc, _HURD_FIRMLINK should be defined in , propor autoconf checks should be created so that ln will compile on system that don't support firmlinks, etc. 2004-01-24 Alfred M. Szmidt <[EMAIL PROTECTED]> Added new option for `ln', --firm. * src/ln.c (firm_link): New variable. (long_options): Support new option `--firm'. (_HURD_FIRMLINK): New macro. (hurd_fail, firmlink): New functions. (do_link, usage, main): Support new option `--firm'. (do_link): Allow the creation of firmlinks for directories. *** src/ln.c.~1.132.~ Sat Oct 18 03:05:47 2003 --- src/ln.cSun Jan 25 02:32:05 2004 *** *** 96,107 enum backup_type backup_type; /* A pointer to the function used to make links. This will point to either !`link' or `symlink'. */ static int (*linkfunc) (); /* If nonzero, make symbolic links; otherwise, make hard links. */ static int symbolic_link; /* If nonzero, ask the user before removing existing files. */ static int interactive; --- 96,110 enum backup_type backup_type; /* A pointer to the function used to make links. This will point to either !`link', `symlink' or `firmlink'. */ static int (*linkfunc) (); /* If nonzero, make symbolic links; otherwise, make hard links. */ static int symbolic_link; + /* If nonzero, make firm links; otherwise make hard links. */ + static int firm_link; + /* If nonzero, ask the user before removing existing files. */ static int interactive; *** *** 133,138 --- 136,142 {"suffix", required_argument, NULL, 'S'}, {"target-directory", required_argument, NULL, TARGET_DIRECTORY_OPTION}, {"symbolic", no_argument, NULL, 's'}, + {"firm", no_argument, NULL, 'm'}, {"verbose", no_argument, NULL, 'v'}, {"version-control", required_argument, NULL, 'V'}, /* Deprecated. FIXME. */ {GETOPT_HELP_OPTION_DECL}, *** *** 140,145 --- 144,234 {NULL, 0, NULL, 0} }; + /* Snatched from glibc; and modified for firm links and some sort of +stand-aloneness. Should really be moved back into libc as a real +call. */ + + #include + #include + #include + #include + #include + + #define _HURD_FIRMLINK _HURD "firmlink" + + int + hurd_fail (error_t err) + { + switch (err) + { + case EMACH_SEND_INVALID_DEST: + case EMIG_SERVER_DIED: + /* The server has disappeared! */ + err = EIEIO; + break; + + case KERN_NO_SPACE: + err = ENOMEM; + break; + + case KERN_INVALID_ARGUMENT: + err = EINVAL; + break; + + case 0: + return 0; + + default: + break; + } + + errno = err; + return -1; + } + + int + firmlink (const char *from, const char *to) + { + error_t err; + file_t dir, node; + char *name; + const size_t len = strlen (from) + 1; + char buf[sizeof (_HURD_FIRMLINK) + len]; + mode_t umask = getumask (); + + /* A firmlink is a file whose translator is "/hurd/firmlink\0target\0". */ + + memcpy (buf, _HURD_FIRMLINK, sizeof (_HURD_FIRMLINK)); + memcpy (&buf[sizeof (_HURD_FIRMLINK)], from, len); + + dir = file_name_split (to, &name); + if (dir == MACH_PORT_NULL) + return -1; + + /* Create a new, unlinked node in the target directory. */ + err = d