| Store | Cart

Re: [TCLCORE] TIP #431: Add 'tempdir' Subcommand to 'file'

From: Kevin Pasko <kevi...@gmail.com>
Mon, 15 Sep 2014 23:22:00 -0400
>> Every Tcl_Filesystem has to define a Tcl_FSCreateDirectoryProc for> Tcl to call to create directories in that virtual filesystem.  In the> native> filesystems, this is the routine TclpObjCreateDirectory().  To my knowledge> there's never been a call for this routine to provide atomic operations,> so if we now demand such a feature, this implies adding a new driver> routine to carry the new requirement, and making this part of the> next revision of the struct, now labeled as>

I think temporary directory creation could look like this:

   1. Generate string of random characters.
   2. Create directory path from native filesystem's temporary directory
   (or provided template) and randomly generated string.
   3. Attempt to create the directory with restrictive (0700) permissions,
   if attempt fails repeat beginning back at 1. If there have been > TMP_MAX
   number of attempts, return error.
   4. Return path of directory.

The questions lie in step 3:

Does Tcl_FSCreateDirectoryProc guarantee an error if the directory was not
created? Also, can we guarantee that the directory was created with strict
permissions (0700), preventing other processes from messing with the
directory and its contents?

The man page for Tcl_FSCreateDirectoryProc would lead me to believe that it
may be adequate for, at least, the directory creation task (permissions?):
"The return value is a standard Tcl result indicating whether an error
occurred in the process. If successful, a new directory should have been
added to the filesystem in the location specified by *pathPtr*."

-Kevin

On Sun, Sep 14, 2014 at 3:06 PM, Porter, Don <dona...@nist.gov> wrote:

> >> Any word on what changes, if any, this implies for the> >> Tcl_Filesystem driver interface ?>> > The existing API function Tcl_FSCreateDirectory would likely be either> > adequate or nearly so; it should produce a POSIX error of EEXIST when> > the directory it is told to create already exists.>> Ok, but my interest is in the driver interface.>> Every Tcl_Filesystem has to define a Tcl_FSCreateDirectoryProc for> Tcl to call to create directories in that virtual filesystem.  In the> native> filesystems, this is the routine TclpObjCreateDirectory().  To my knowledge> there's never been a call for this routine to provide atomic operations,> so if we now demand such a feature, this implies adding a new driver> routine to carry the new requirement, and making this part of the> next revision of the struct, now labeled as>> TCL_FILESYSTEM_VERSION_3>> Any virtual filesystems not upgraded to the new Tcl_Filesystem> version would fail to perform the new command.>> DGP>

------------------------------------------------------------------------------
Want excitement?
Manually upgrade your production database.
When you want reliability, choose Perforce.
Perforce version control. Predictably reliable.
http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
_______________________________________________
Tcl-Core mailing list
Tcl-...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tcl-core

Recent Messages in this Thread
Kevin Pasko Sep 12, 2014 02:45 pm
Don Porter Sep 12, 2014 08:20 pm
Donal K. Fellows Sep 13, 2014 05:28 pm
Alexandre Ferrieux Sep 14, 2014 09:19 pm
Kevin Pasko Sep 16, 2014 03:22 am
Porter, Don Sep 14, 2014 07:06 pm
Brian Griffin Sep 14, 2014 08:25 pm
Messages in this thread