Current-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
WAPBL: unallocated file ?
Hi,
While still playing with my favourite testcase (native rename race
code, attached) on WAPBL, i noticed that i now get some bogus created
files when the program exits.
Here follow a sample session that illustrate it :
njoly@lanfeust [rump/native]> ls -al
total 52
drwxr-xr-x 2 njoly users 512 Oct 23 18:40 .
drwxr-xr-x 11 njoly users 512 Oct 23 18:43 ..
-rw-r--r-- 1 njoly users 442 Oct 23 17:19 Makefile
-rwxr-xr-x 1 njoly users 18392 Oct 23 17:19 rename
-rw-r--r-- 1 njoly users 963 Oct 23 17:17 rename.c
njoly@lanfeust [rump/native]> ./rename
njoly@lanfeust [rump/native]> echo $?
0
njoly@lanfeust [rump/native]> ls -al
ls: rename2.test: Bad file descriptor
total 52
drwxr-xr-x 2 njoly users 512 Oct 23 19:08 .
drwxr-xr-x 11 njoly users 512 Oct 23 18:43 ..
-rw-r--r-- 1 njoly users 442 Oct 23 17:19 Makefile
-rwxr-xr-x 1 njoly users 18392 Oct 23 17:19 rename
-rw-r--r-- 1 njoly users 963 Oct 23 17:17 rename.c
At that time, i cannot do anything with rename2.test; and clear it by
unmounting the file system and `fsck -f'.
root@lanfeust[~]# fsck -f /home
** /dev/rwd1a
** File system is already clean
** Last Mounted on /home
** Phase 1 - Check Blocks and Sizes
** Phase 2 - Check Pathnames
UNALLOCATED I=18429320 OWNER=1000 MODE=0
SIZE=0 MTIME=Oct 23 19:08 2009
NAME=/njoly/emul/netbsd/rump/native/rename2.test
REMOVE? yes
** Phase 3 - Check Connectivity
** Phase 4 - Check Reference Counts
** Phase 5 - Check Cyl groups
260244 files, 3029370 used, 100191349 free (24173 frags, 12520897 blocks, 0.0%
fragmentation)
***** FILE SYSTEM WAS MODIFIED *****
Any idea ?
Thanks.
--
Nicolas Joly
Biological Software and Databanks.
Institut Pasteur, Paris.
#include <err.h>
#include <fcntl.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#define FILE1 "rename1.test"
#define FILE2 "rename2.test"
static int quit = 0;
static void *func1(void *arg) {
int fd;
while (quit != 1) {
fd = open(FILE1, O_WRONLY|O_CREAT|O_TRUNC, 0666);
unlink(FILE1);
close(fd); }
return NULL; }
static void *func2(void *arg) {
while (quit != 1) {
rename(FILE1, FILE2); }
return NULL; }
int main() {
int res;
pthread_t th1, th2;
res = pthread_create(&th1, NULL, func1, NULL);
if (res != 0)
errx(1, "pthread_create failed");
res = pthread_create(&th2, NULL, func2, NULL);
if (res != 0)
errx(1, "pthread_create failed");
sleep(10);
quit = 1;
res = pthread_join(th2, NULL);
if (res != 0)
errx(1, "pthread_join failed");
res = pthread_join(th1, NULL);
if (res != 0)
errx(1, "pthread_join failed");
return 0; }
Home |
Main Index |
Thread Index |
Old Index