links: hard vs soft
Aggelos Economopoulos
aoiko at cc.ece.ntua.gr
Fri Jul 11 18:59:03 EEST 2003
On Friday 11 July 2003 15:21, Yannis Kotsinos wrote:
> On Friday 11 July 2003 07:29, Alexandros Papadopoulos wrote:
> > On Thursday 10 July 2003 12:15, Yannis Kotsinos wrote:
> > > On Thursday 10 July 2003 04:43, Alexandros Papadopoulos wrote:
> > > > Απ'ότι έχω καταλάβει είναι πιο expensive (από άποψη disk I/O και
> > > > χώρου) τα symbolic links...
> >
> > To geniko 8ema einai to idio me ekeino to post (links), alla to eidiko
> > 8ema einai teleiws diaforetiko.
>
> Kai anarwtiomoyn an hsoyn o op! Exeis kati me ta links e??? :)
>
> > Tote milousame gia enan periorismo twn hard links oson afora
> > directories, enw h twrinh aporia mou einai giati xrhsimopoiountai toso
> > poly gia arxeia (/etc/rcX.d, /lib, /dev ktl), otan einai pio expensive
> > (kai to file reference count den blepw ti sxesh exei me ta head seeks)
>
> Ypo8etw to kyrio (i-node) drawback twn hard links? Mallon einai proion twn
> teleytaiwn xronwn na einai ola mounted sto idio filesystem wste na mhn
> apotelei ayto problhma, alla kai ayto pali den einai kanonas.
Ase pou ta hard links einai transparent (ektos an kaneis einai dia8etimenos na
diabasei ola ta inode numbers enos fs kai meta na psa3ei gia hard links se
O(n)). Auto dhmiourgei profanh problhmata sta backups.
>
> > Epishs prokyptei endiaferousa erwthsh sxetika me ta directory loops.
> > Tote eixe pei to gnwsto mwb zwaki oti den ginetai na exeis, enw twra
> > leei o aoiko oti ginetai.
O aggelos einai malakas pou ekane 'lman ln' anti na kanei 'gview
~/src/linux/svn/linux-2.5-bkbits/fs/namei.c'. Ekei opoiosdhpote mporei na dei
sthn vfs_link() to test:
if (S_ISDIR(old_dentry->d_inode->i_mode))
return -EPERM;
pou mallon den afhnei kamia amfibolia gia to ti isxuei katw apo linux.
>
> Gratitious implementation specifics (exw mpoyxtisei apo ayta twra poy
> diabazw to Unix Network Programming). Se ena slackware poy exw prosbash ta
> "-d, -F, --directory" briskontai katw apo thn kathogria GNU OPTIONS. An kai
> den mporw na katalabw giati mporei na einai xrhsimos 'enas kyklikos grafos'
> opws wraia to e8ese o rikoudis se ena file system...
giati, opws einai hliou faeinotero, DEN se upoxrewnei kaneis na ftia3eis
kateu8unomeno kukliko grafo sto filesystem. mporeis na to xrhsimopoihseis gia
kaneis kati XRHSIMO.
apo thn allh bebaia, an mporouse na to kanei auto enas xrhsths, tipota den 8a
ton empodize na ftia3ei to loop kai na axrhstepsei opoia programata kanoun
traverse to directory tree, meta3u twn opoiwn kai to fsck (me alla logia o
admin ton hpie).
> Malista diabazw sto man page:
>
> On existing implementations, if it is at all possible to make a hard
> link to a directory, this may be done by the superuser only.
mpa, mporei na ginei apo opoiondhpote xrhsth me 'appropriate privileges' kai
autos mporei na mhn einai o root. entw meta3u, h monh existing implementation
pou 8umomoun oti epitrepei to link() se directory gia ton root einai h
44bsd[0] kai epsa3a na brw poia unix to epitrepoun auto shmera. Einai ta
e3hs:
to hpux, tou opoiou h link(2) man page anaferei:
[EPERM]
The file named by path1 is a directory and the effective user ID is not a user
who has appropriate privileges. Some file systems return this error whenever
path1 names a directory, regardless of the user ID.
Omws, h man page DEN dieukrinizei an _mporei_ na uparxei tetoio uid kai
upopsiazomai pws kai ekei isxuei o, ti sta upoloipa (*bsd, solaris, irix,
linux, unixware kai oute mporw oute 8elw na ma8w ti isxuei sto aix).
> POSIX forbids
> the system call link(2) and the utility ln to make hard links to
> directories (but does not forbid hard links to cross filesystem boundaries)
>
> H teleytaia paren8esh einai akoma pio f at cked up!
pesto auto stous tupous pou ftia3ane ta 'historical implementations'.
apo to rationale tou link() sth susv3:
Some historical implementations allow linking of files on different file
systems. Wording was added to explicitly allow this optional behavior.
The exception for cross-file system links is intended to apply only to links
that are programmatically indistinguishable from "hard" links.
>
> > Opote akoma sto skotadi briskomaste... :-P
>
> POSIX, sus3, OUF!
*sunh8ws* sou arkei h susv3.
> Den 3erw gia sas egw paw gia mpanio :)
Me ton Stevens gia na exeis na diabazeis kati sthn paralia? den nomizw oti 8a
kaneis filous etsi :-)
[0] pragmati, to freebsd epapse na uposthrizei links se directory to 1996:
(apo to revision 1.48 tou kern/vfs_syscalls.c)
Dont allow directories to be link()ed or unlink()ed, even for root
(returns EPERM always, the errno is specified by POSIX).
If you really have a desperate need to link or unlink a directory, you
can use fsdb. :-)
This should stop any chance of ftpd, rdist, "rm -rf", etc from
bugging out and damaging the filesystem structure or loosing races
with malicious users.
Reviewed by: davidg, bde
http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/kern/vfs_syscalls.c.diff?r1=1.47&r2=1.48
More information about the Linux-greek-users
mailing list