[Prev][Next][Index][Thread]
Re: Bug with the fsnamespace cache ???
On Fri, 28 Apr 2000, Leigh Stoller wrote :
> I forget what version of the oskit are you running, cause the current impl
> uses a COM wrapper around oskit_dir_t, implemented by the fsnamespace
> cache. The posix unlink chains to this. This is in
> oskit/fsnamespace/src/dir_wrapper.c.
>
...
> If you do have this version of the code, then something is indeed wrong.
> Perhaps a reference count error.
>
I am running version 20000202 of OSKit. The wrapper is present. But...
I have debugged a short code more carefully :
/* This name because it is plugged where there should be a command prompt. */
void read_command( void ) {
int r ;
r = open( "toto", O_CREAT|O_WRONLY ) ;
fprintf( stdout, "open1 %d\n", r ) ;
r = unlink( "toto" ) ;
fprintf( stdout, "unlink %d\n", r ) ;
r = open( "toto", O_RDONLY ) ;
fprintf( stdout, "open2 %d", r ) ;
return ;
}
The output produced is (if toto exist before the execution of this code) :
open1 3
unlink 0
open2 4
The awaited result is (and it is the case if toto does not exist before
the execution of the code) :
open1 3
unlink 0
open2 -1
While the debug, I saw that the wrapper was not installed on the directory
(file fsnamespace/src/fsnamespace.c) :
static OSKIT_COMDECL
fsnamespace_lookup(oskit_fsnamespace_t *f, const char *filename,
int flags, struct oskit_file **out_file)
{
struct fsobj *fs = (struct fsobj *) f;
oskit_file_t *file;
oskit_error_t rc;
int isdir;
assert(fs->count);
/*
* Do a pathname lookup using the current root and cwd.
*/
rc = fsn_lookup(fs, filename, flags, &isdir, &file);
if (rc)
return rc;
#if defined(FSCACHE) && defined(THREAD_SAFE)
/*
* In the multithreaded model, must wrap up directories so that
* cache consistency can be maintained. See the dir_wrapper code.
* Fortunately, most operations are on files, not directories.
*/
if (isdir) {
oskit_dir_t *dir;
rc = fsn_wrap_dir(fs->fsnimpl, (oskit_dir_t *) file, &dir);
/*
* Release reference since the wrapper took a ref.
*/
oskit_file_release(file);
if (rc)
return rc;
file = (oskit_file_t *) dir;
}
#endif
*out_file = file;
return 0;
}
I think there are at least two errors :
- Our code is not multithreaded. The wrapper MUST be installed even if the
code is not multithreaded. I think the test defined(THREAD_SAFE) should
not be done there.
- Only directory looked up with the namespace are wrapped up. Is the home
directory wrapped up ?
Simon.
References: