A testcase for the umount bug.

H.J. Lu (hjl@lucon.org)
Fri, 11 Dec 1998 21:58:23 -0800 (PST)


Here is a testcase for the floppy umount bug:

# su
# gcc foo.c
# a.out
umount: Device or resource busy

Thanks.

-- 
H.J. Lu (hjl@gnu.org)
---
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/mount.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>

main () { const char *dirname = "foo"; const char *devname = "/dev/fd0"; char *cp;

rmdir (dirname);

if (mkdir (dirname, 0777)) { perror ("mkdir"); return 1; }

if (mount (devname, dirname, "ext2", MS_MGC_VAL, 0)) { perror ("mount"); return 1; } cp = (char *)malloc((size_t)(strlen(dirname) + sizeof("/fill.tmpX")));

if (cp != NULL) { (void) strcat(strcpy(cp, dirname), "/fill.tmp1"); (void) unlink(cp); (void) strcat(strcpy(cp, dirname), "/fill.tmp2"); (void) unlink(cp); (void) strcat(strcpy(cp, dirname), "/fill.tmp3"); (void) unlink(cp); (void) strcat(strcpy(cp, dirname), "/fill.dir"); (void) rmdir(cp); free((void *)cp); }

if (umount (devname)) { perror ("umount"); return 1; }

return 0; }

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/