mc/lib/vfs
Egmont Koblinger 7866bf7342 Ticket #3093: keep symlinks in cwd at startup.
If you navigate in your shell to a directory containing symlinks and
then start mc, mc will show the canonical path instead. It would be nice
to make it show the directory with the symlinks.

Example: in your shell execute these:

user:~$ mkdir -p /tmp/a/b /tmp/x ; ln -s /tmp/a/b /tmp/x/y
user:~$ cd /tmp/x/y
user:/tmp/x/y$ mc

In mc you'll find yourself in /tmp/a/b, though it'd be nicer to see
/tmp/x/y at the top, and correspondingly navigating to the parent would
take you to /tmp/x.

If you start bash or zsh from /tmp/x/y, the new instance will start
displaying the working directory as such. They do this via the PWD env
variable. On one hand, they set and maintain PWD to point to the current
directory, using the path as specified by the user (possibly containing
symbolic links). On the other hand, they check its value at startup. If
$PWD points to the same physical directory as the actual working
directory then they use this value. If $PWD points somewhere else then
it's simply ignored (so it's a hint only as to which symlinks to use to
get to the working directory, but never alters the actual cwd).

Now mc also does the same at startup (with respect of "Cd follows
links" option). Relative directories specified in the command line  are
applied after possibly replacing the canonical cwd with $PWD. This way
for example

user:/tmp/x/y$ mc . ..

opens two panels in /tmp/x/y and /tmp/x instead of /tmp/a/b and /tmp/a
(whereas /tmp/x is actually a different directory than /tmp/a).

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2013-12-27 19:07:58 +04:00
..
direntry.c Reduce cppcheck warnings (style) in lib subdirectory. 2013-11-25 13:47:39 +04:00
gc.c Code reorganization and fixes around the vfs_path_as_str() function 2013-06-28 09:21:16 +04:00
gc.h Following prototypes of functions was changed in VFS-module API: 2011-06-23 14:44:58 +03:00
HACKING VFS structure changes: 2011-03-21 11:48:26 +02:00
interface.c Reduce cppcheck warnings (style) in lib subdirectory. 2013-11-25 13:47:39 +04:00
Makefile.am Clarify usage of AM_CPPFLAGS. 2012-12-18 16:27:49 +04:00
netutil.c Fix use of uninitialized memory in sigaction structure. 2013-11-25 13:47:40 +04:00
netutil.h Clarify of sig_atomic_t usage (got from Mutt). 2012-11-09 10:05:13 +04:00
parse_ls_vga.c Reduce cppcheck warnings (style) in lib subdirectory. 2013-11-25 13:47:39 +04:00
path.c Reduce cppcheck warnings (style) in lib subdirectory. 2013-11-25 13:47:39 +04:00
path.h Fix panel recoding 2013-07-23 14:15:24 +04:00
README VFS structure changes: 2011-03-21 11:48:26 +02:00
utilvfs.c Reduce cppcheck warnings (style) in lib subdirectory. 2013-11-25 13:47:39 +04:00
utilvfs.h Changed input parameters of mc_mkstemp() and mc_tempdir() functions 2012-03-06 11:41:26 +03:00
vfs.c Ticket #3093: keep symlinks in cwd at startup. 2013-12-27 19:07:58 +04:00
vfs.h (vfs_translate_path): return const char *. 2013-10-04 09:14:08 +04:00
xdirentry.h Indentation. 2012-12-20 16:22:23 +04:00

NOTE: Although vfs has been meant to be implemented as a separate
entity redistributable under the LGPL in its current implementation it
uses GPLed code from src/. So there are two possibilities if you want
to use vfs:

1. Distribute your copy of vfs under the GPL. Then you can freely
include the GPLed functions from the rest of the mc source code.

2. Distribute your copy of vfs under the LGPL. Then you cannot include
the functions outside the vfs subdirectory. You must then either
rewrite them or work around them in other ways.

========================================================================

Hi!

I'm midnight commander's vfs layer. Before you start hacking me,
please read this file. I'm integral part of midnight commander, but I
try to go out and live my life myself as a shared library, too. That
means that I should try to use as little functions from midnight as
possible (so I'm tiny, nice and people like me), that I should not
pollute name space by unnecessary symbols (so I do not crash fellow
programs) and that I should have a clean interface between myself and
midnight.

Because I'm rather close to midnight, try to:

* Keep the indentation as the rest of the code. Following could help
you with your friend emacs:

(defun mc-c-mode ()
	"C mode with adjusted defaults for use with the Midnight commander."
	(interactive)
	(c-mode)
	(c-set-style "K&R")
	(setq	c-indent-level 4
		c-continued-statement-offset 4
		c-brace-offset 0
		c-argdecl-indent 4
		c-label-offset -4
		c-brace-imaginary-offset 0
		c-continued-brace-offset 0
		c-tab-always-indent nil
		c-basic-offset 4
		tab-width 8
		comment-column 60))

(setq auto-mode-alist (cons '(".*/mc/.*\\.[ch]$" . mc-c-mode)
                       auto-mode-alist))

And because I'm trying to live life on my own as libvfs.so, try to:

* Make sure all exported symbols are defined in vfs.h and begin with
'vfs_'.

* Do not make any references from midnight into modules like tar. It
would probably pollute name space and midnight would depend on concrete
configuration of libvfs. mc_setctl() and mc_ctl() are your
friends. (And mine too :-).

							 Pavel Machek
							 pavel@ucw.cz

PS: If you'd like to use my features in whole operating system, you
might want to link me to rpc.nfsd. On
http://atrey.karlin.mff.cuni.cz/~pavel/podfuk/podfuk.html you'll find
how to do it.

PPS: I have a friend, shared library called avfs, which is LD_PRELOAD
capable. You can reach her at http://www.inf.bme.hu/~mszeredi/avfs.