.
D 2004-04-25T17:40:46
J assignee andreas_kupries
J cmimetype text/plain
J comment \nTcl's\spath\smanagement\scode\shas\sa\nfundamental\sfeature\sthat\seach\spath\nbelongs\sto\sexactly\sone\sfilesystem.\n\nThe\sway\sthis\sis\simplemented\sis\sthat\nTcl\siterates\sover\sall\sregistered\sfilesystems\nin\sreverse\sorder\sof\stheir\sregistration\sand\nasks\seach\sone\s"does\sthis\sfile\sbelong\sto\syou?"\n(via\sa\scall\sto\sthe\sFS's\spathInFilesystemProc).\nEach\sfilesystem\sis\sallowed\sto\sanswer\sYES\nor\sNO,\sand\sthe\sfirst\sone\sthat\sanswers\sYES\nis\sdeclared\sthe\sunique\sowner\sof\sthat\spath.\nThe\snative\sfilesystem\sis\sregistered\sfirst,\sso\nit\sis\squeried\slast,\sand\salways\sanswers\sYES,\nso\sthe\sfallback\sfilesystem\sfor\sunclaimed\spath\nvalues\sis\sthe\snative\sfilesystem.\n\nAll\soperations\son\sa\spath\swill\sbe\spassed\nto\sits\sowning\sfilesystem,\sand\safter\sany\nshimmering,\sthat\sowning\sfilesystem\swill\nbe\sthe\sone\sthat\sgets\sto\screate\sthe\srefreshed\ninternal\srep,\ssuitable\sonly\sfor\sthat\sfilesystem.\n\nThis\sfeature\sis\swhat\smakes\sthe\spublic\nroutine\sTcl_FSGetFileSystemForPath(pathPtr)\nmake\ssense.\s\sYou\spass\sin\sa\spath,\sand\sget\sback\nthe\sunique\sfilesystem\sthat\sowns\sthat\spath.\n\nThere\sare\sseveral\slimitations\sthat\sthis\sfeature\nimposes\sthat\sare\sunattractive.\n\n1)\sImpossible\sto\simplement\s"stacked"\sfilesystems.\n\nOne\scould\simagine\sa\sfilesystem\sthat\sclaimed\sall\npaths,\sdid\ssome\skind\sof\slogging,\sor\sother\sfiltering\non\sthe\soperations,\sand\sthen\spassed\salong\sto\san\nappropriate\s"real"\sfilesystem\sto\sdo\sthe\sactual\swork.\n\nIt's\ssimple\senough\sto\screate\sa\snew\sfilesystem\sthat\nclaims\sall\spaths\sand\sdoes\sthe\sfiltering\swork,\sbut\nthings\swould\sbreak\sas\ssoon\sas\sit\sattempted\sto\spass\nthe\spath\salong\sto\sthe\sreal\sfilesystem.\s\sWhen\sthe\nreal\sfilesystem\stried\sto\sdo\soperations\son\sthe\spath,\nthe\spath\swould\sbe\srecognized\sas\sbelonging\sto\sthe\nstacked\sfilesystem,\sso\soperations\swould\sget\spassed\nback\sup\sto\sthe\sfiltering\slayer\sagain.\s\sThe\sreal\sfilesystem\nwould\snot\sbe\sable\sto\screate/fetch\sits\sown\sinternal\srep\nfor\sthe\spath,\sbecause\sthe\sfiltering\sfilesystem's\sclaim\non\sthe\spath\swould\skeep\sproducing\sthe\sfiltering\nfilesystem's\sinteral\srep\sinstead.\n\nOne\smight\simagine\sthe\sfiltering\sfilesystem\sreleasing\nits\sclaim\son\sthe\spath\sbefore\sit\spasses\sit\sdown\sto\sthe\nreal\sfilesystem\s(change\sinternal\sstate,\sso\sthe\sfiltering\nfilesystem\sno\slonger\ssays\sYES\sto\sthis\sparticular\spath),\nbut\sthere\sdoesn't\sseem\sto\sbe\sany\sway\sto\sdo\sthat\sin\na\sthread\ssafe\smanner.\s\sWhile\sthe\sfiltering\sfilesystem\nin\sThread\sA\sabandons\sits\sclaim\son\sa\spath\sto\spass\sit\non\sto\sthe\sreal\sfilesystem,\sthen\soperations\son\sthe\ssame\npath\sin\sThread\sB\sbypass\sthe\sfiltering\soperation.\n\nAnother\sdifficulty\sis\sthat\sa\sfiltering\sfilesystem\scould\nonly\swork\sif\sit\swere\sregistered\safter\sthe\sfilesystem(s)\nit\sis\sfiltering.\s\sFor\sfiltering\sthe\snative\sfilesystem,\sthis\nmight\swork,\sas\slong\sas\sthe\snative\sfilesystem\sregistered\nfirst\srule\spersists,\sbut\sfiltering\sof\sother\sfilesystems\nwould\snot\sbe\srobust,\sas\sorder\sof\sfilesystem\sregistration\nis\sessentially\simpossible\sto\scontrol\s(multi-threads).\n\n2)\sImpossible\sto\simplement\smountable\sarchive\sfile.\n\nImagine\san\sarchive\sfile\sin\ssome\sfilesystem:\n\n/path/to/archive.ar\n\n[file\ssystem\s/path/to/archive.ar]\swill\sreturn\sthe\nfilesystem\sin\swhich\sthat\sarchive\sfile\sis\sstored\sand\n[file\stype\s/path/to/archive.ar]\swill\sreturn\s"file".\s\sThen\nimagine\smounting\sthat\sarchive\swith\sthe\smount\scommand\nappropriate\sfor\sthe\sfilesystem\sin\sthat\sarchive:\n\nfs::mount\s/path/to/archive.ar\n\nThe\sdesire\sis\sthat\s[file\ssystem\s/path/to/archive.ar]\swill\nreturn\s"fs"\sand\s[file\stype\s/path/to/archive.ar]\swill\sreturn\n"directory"\sand\sit\swill\snow\sbe\spossible\sto\saccess\sthe\ncontents\nof\sthe\sarchive\sas\svirtual\sfiles,\sas\sin:\n\nopen\s/path/to/archive.ar/internal/foo.bar\n\nAs\sin\sthe\sfirst\scase,\sthis\swill\sfounder\sbecause\sit\ndepends\son\sthe\ssingle\spath\s/path/to/archive.ar\nbeing\sable\sto\sbelong\sto\stwo\sfilesystems\sat\sonce.\nThe\sinternal\soperations\sof\sfilesystem\s"fs"\swill\nneed\sto\sbe\sdefined\sas\soperations\sof\sthe\soriginal\nfilesystem\son\sthe\sarchive\sfile,\sbut\sTcl\swill\skeep\ninsisting\sthat\s"fs"\sis\sthe\sonly\sfilesystem\sthat\scan\noperate\son\sthat\spath.\n\n"But\swait!"\syou\ssay.\s\sDoesn't\sTclkit/Starkit/mkfs\sdo\nthis?\s\sWell,\syes\sit\sdoes,\sbut\sit\smanages\sto\sdo\sit\nby\shaving\sits\saccess\sto\sthe\sunderlying\sfilesystem\snot\npass\sback\sthrough\sTcl.\s\s(Correct\sme\sif\sI'm\swrong)\nBy\snot\sgoing\sback\sto\sTcl\sto\sdo\sthe\slower\slevel\noperations,\sit\scan\savoid\sTcl's\sinsistent\s\sassignment\nof\sthe\sarchive\spath\sto\sthe\svfs\slater.\s\sHowever,\sthis\nalso\smeans\sthat\sonly\snative\sfiles\sthat\sare\saccessible\nwithout\sgoing\sback\sthrough\sTcl\sare\sable\sto\sbe\sarchive\nfiles.\s\sThis\smeans\sno\snesting\sof\sarchives,\sand\sit\smeans\nthat\sthe\sillusion\sthat\svirtual\sfiles\sand\snative\sfiles\sare\nequivalent\sis\sincomplete.\s\sI'm\spretty\ssure\s(again,\nsomeone\sexplain\sif\sI'm\smistaken)\sthat\sthis\smeans\nit's\snot\spossible\sto\smount\ssuch\san\sarchive\sremotely\n(within\san\sHTTP\sor\sFTP\svirtual\sfilesystem).\n\n3)\sImpossible\sto\smount\sone\sFS\swithin\sanother.\n\nI\sthink\sthis\sis\sprobably\sthe\smost\ssignificant\slimitation.\n\nEach\sfilesystem\sgets\sone\schance\sto\ssay\sYES\sor\sNO\nto\sowning\sa\spath.\s\sIf\sthe\spath\spoints\sto\san\sexisting\nfile\sin\sthe\sfilesystem,\sthen\sYES\sis\sthe\seasy\sanswer.\nIf\sthe\s(normalized)\spath\sis\scompletely\soutside\sa\nfilesystem's\smount\spoints,\sthen\sNO\sis\san\sequally\neasy\sanswer.\s\sThe\sremaining\scases\sare\stricky.\n\nSay\sthat\sthe\spath\n\n/foo/bar/soom/example\n\nis\sto\sbe\stested,\sand\smy\sfilesystem\sholds\sthe\nmountpoint\s/foo/bar\s.\s\sShould\smy\sfilesystem\ssay\sYES?\nSeveral\scases:\n\n/foo/bar/soom/example\sexists\sin\smy\sFS\s->\sYES\n(modulo\sthe\smountable\sarchive\sproblem\salready\snoted)\n\n/foo/bar/soom\sis\snot\sa\sdirectory\sin\smy\sFS\s->\sNO\n\nOtherwise\s->\s????\n\nIn\sthe\sfinal\scase\s/foo/bar/soom\sis\smy\sdirectory,\sbut\n/foo/bar/soom/example\sdoes\snot\s(yet)\sexist\sin\smy\nFS.\s\sIt\sseems\smy\sFS\sshould\sanswer\sYES,\sbecause\nif\sthat\sfile\swere\sto\sbe\screated,\sit\swould\sinvolve\nwriting\sto\sa\sdirectory\swhich\sis\smine.\n\nHowever,\sit's\salso\spossible\sthat\n/foo/bar/soom/example\sis\sa\smountpoint\sfor\nanother\sfilesystem.\s\sIf\sI\sanswer\sYES,\sthen\sthat\nfilesystem\swill\snever\sget\sits\schance\sto\sclaim\sits\nmountpoint.\s\sOn\sthe\sother\shand,\sif\sI\sanswer\sNO,\nand\sthere\sis\sno\ssuch\sother\sfilesystem\sthat\sclaims\nthat\smountpoint,\sthen\sattempts\sto\screate\sthat\npath\swill\sbe\srouted\sto\sthe\snative\sFS,\swhen\sthey\nought\sto\sbe\srouted\sto\sme.\s\sThe\sonly\sway\sto\savoid\nthis\sdilemma\sis\sto\snot\sallow\snested\sFS\smounting.\n\nAs\snoted\sbefore\sfilesystem\sregistration\sorder\nis\snot\sreally\savailable\sto\scontrol\sto\savoid\sthis\sissue.\nThe\sexception\sis\sthe\snative\sfilesystem,\swhich\sis\nalways\slast.\s\sThis\smeans\sthe\smost\scommon\scase,\nadding\smounts\swithin\sthe\snative\sfilesystem\sworks,\neven\sthough\sas\sa\sgeneral\soperation\sit's\sfundamentally\nbroken.\s\sAnother\scommon\scase,\sadding\smount\spoints\noutside\sof\sany\sexisting\sfilesystem,\slike\shttp://\s-rooted\npaths,\salso\sworks\sfine.\n\nI'm\sassigning\sthis\sreport\sfirst\sto\sAndreas\ssince\nhe\sexpressed\sinterest\sin\sthese\sissues.\s\sIt\sshould\nget\spassed\salong\sto\sVince\sDarley\sas\swell.\s\sI'm\nregistering\sthis\sas\sa\sbug,\seven\sthough\sit's\sarguably\na\sfeature\srequest,\sbecause\sif\sthese\slimitations\sare\nto\scontinue,\sthey\sshould\sbe\smore\sclearly\sspelled\nout\sin\sthe\sdocumentation.\n\nJust\sto\srecord\sa\sfew\shalf-thoughts\son\san\salternative,\nit\sseems\sthat\smountpoints\sare\sthe\sspecial\scases\sthat\nget\sin\sthe\sway\sof\sthe\scurrent\sscheme.\s\sPerhaps\sif\nthe\s(pathInFilesystemProc)s\shad\sa\sricher\sset\sof\nanswers,\sthings\scould\sbe\simproved.\s\sRather\sthan\sa\nsimple\sYES\s(return\sTCL_OK)\sor\sNO\s(return\s-1),\nsome\sother\sanswers\smight\sbe\s"THAT'S\sMY\sMOUNT"\nor\s"I\sCOULD\sTAKE\sTHAT\sIF\sNO\sONE\sELSE\sDOES".\nThe\scurrent\sdocs\sclearly\sleave\sother\sreturn\svalues\nundefined,\sso\sthey\scould\sbe\sused\sfor\ssuch\san\nexpansion.\s\sThe\sstacked\sfilesystems\sproblem\sseems\nto\sbe\smore\sdifficult.\n\n
J foundin obsolete:\s8.5a2
J priority 5\sMedium
J resolution None
J status Open
J submitter dgp
J subsystem 37.\sFile\sSystem
J title path<->FS\sfunction\slimitations
J type Bug
K 941872ffffffffffffffffffffffffffffffffff
U dgp
Z 6c8783951bb97684a396204738260165