kern/48435: wierd file system behavior

Jin Guojun [NCS] j_guojun at lbl.gov
Sat Oct 11 11:33:56 PDT 2003


Kris Kennaway wrote:

> Synopsis: wierd file system behavior
>
> State-Changed-From-To: open->closed
> State-Changed-By: kris
> State-Changed-When: Fri Oct 10 22:16:01 PDT 2003
> State-Changed-Why:
> It has been determined that this is deliberate behaviour by tar.
>
> http://www.freebsd.org/cgi/query-pr.cgi?pr=48435

 A truss of tar when the directory exists, but has no files:

     mkdir(0x809b070,0x1ed)         ERR#17 'File exists'
     unlink(0x809b070)              ERR#1 'Operation not permitted'
     rmdir(0x809b070)               = 0 (0x0)
     mkdir(0x809b070,0x1ed)         = 0 (0x0)

But when a file exists in the directory:

     mkdir(0x809b070,0x1ed)          ERR#17 'File exists'
     unlink(0x809b070)              ERR#1 'Operation not permitted'
     rmdir(0x809b070)               ERR#66 'Directory not empty'

     So it seems tar is removing then creating the directory if it is empty.

 --

Then the TAR is the bad guy. The entire logic in TAR is either lazy or silly.

Can we change it to something simple

    stat(dir, &sb)
    if (dir exists but a file)    {
        return    error
    }
    if (dir not exist)
        mkdir(dir)


    -Jin





More information about the freebsd-bugs mailing list