diff --git a/servers/vfs/proto.h b/servers/vfs/proto.h index 735624472..74b4b8ab8 100644 --- a/servers/vfs/proto.h +++ b/servers/vfs/proto.h @@ -78,10 +78,6 @@ void write_elf_core_file(struct filp *f, int csig, char *exe_name); /* exec.c */ int pm_exec(endpoint_t proc_e, vir_bytes path, size_t path_len, vir_bytes frame, size_t frame_len, vir_bytes *pc, vir_bytes *newsp, int flags); -#define check_bsf_lock() do { \ - assert(mutex_trylock(&bsf_lock) == 0); \ - unlock_bsf(); \ - } while(0) /* filedes.c */ void *do_filp_gc(void *arg); @@ -213,6 +209,7 @@ int do_read(void); int do_getdents(void); void lock_bsf(void); void unlock_bsf(void); +void check_bsf_lock(void); int do_read_write(int rw_flag); int read_write(int rw_flag, struct filp *f, char *buffer, size_t nbytes, endpoint_t for_e); diff --git a/servers/vfs/read.c b/servers/vfs/read.c index 4b7715017..db6a65558 100644 --- a/servers/vfs/read.c +++ b/servers/vfs/read.c @@ -65,6 +65,22 @@ void unlock_bsf(void) panic("failed to unlock block special file lock"); } +/*===========================================================================* + * check_bsf * + *===========================================================================*/ +void check_bsf_lock(void) +{ + int r = mutex_trylock(&bsf_lock); + + if (r == -EBUSY) + panic("bsf_lock locked"); + else if (r != 0) + panic("bsf_lock weird state"); + + /* r == 0 */ + unlock_bsf(); +} + /*===========================================================================* * do_read_write * *===========================================================================*/