NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/41056: "rm -rf" on tmpfs can fail

>Number:         41056
>Category:       kern
>Synopsis:       "rm -rf" on tmpfs can fail
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Mar 22 11:55:00 +0000 2009
>Originator:     Alan Barrett
>Release:        NetBSD 5.99.8
Not much
System: NetBSD 5.99.8 i386
        Attempting to delete a directory using "rm -rf" on tmpfs
        can fail
        Run the following python program.  It works find if the system
        is otherwise idle, but if the system is heavily loaded and /tmp
        is a tmpfs fiel system then it sometimes prints messages of the

        rm: /tmp/ Directory not empty

#!/usr/bin/env python2.4

import os
import sys
import tempfile

def make_temp_dir():
    """Creates a temporary directory and returns its name.
    dirname = tempfile.mkdtemp(".tmp", os.path.basename(sys.argv[0]) + ".")
    return dirname

def delete_temp_dir(dirname):
    """Deletes the temporary directory.
    os.spawnvp(os.P_WAIT, 'rm', ['rm', '-rf', dirname])

def test_in_temp_dir(testfunc):
    """Create a temporary directory, perform a function in that
    directory, then delete the directory.  testfunc is a function taking
    one argument: the name of the temporary directory.
    prev_cwd = os.getcwd()
    tempdir = make_temp_dir()
    result = testfunc(tempdir)
    return result

def some_tests(tempdir):
    """A function intended to be invoked from test_in_temp_dir.
    Create some subdirectories and files inside the temp dir.
    for d in ["foo", "foo/bar"]:
    for f in ["foo/bar/1", "foo/bar/2"]:
        open(f, "w").write("stuff")

if __name__ == "__main__":
    i = 0
    while True:
        i += 1


Home | Main Index | Thread Index | Old Index