Fixed all warnings and one small bug in kernel.c::new_vnode() - it didn't

unlock the vnode if the same cookie already existed.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4907 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2003-10-01 02:22:14 +00:00
parent b50ffaa707
commit 6c1c51bf87
6 changed files with 33 additions and 34 deletions
@@ -28,7 +28,6 @@ char **
build_argv(char *str, int *argc) build_argv(char *str, int *argc)
{ {
int table_size = 16, _argc; int table_size = 16, _argc;
char *ptr=str;
char **argv; char **argv;
if (argc == NULL) if (argc == NULL)
@@ -187,7 +187,7 @@ static void dec_vnode(vnode *vn, char r);
static int compare_vnode(vnode *vna, vnode *vnb); static int compare_vnode(vnode *vna, vnode *vnb);
static nspace * nsidtons(nspace_id nsid); static nspace * nsidtons(nspace_id nsid);
static int alloc_wd_fd(bool kernel, vnode *vn, bool coe, int *fdp); //static int alloc_wd_fd(bool kernel, vnode *vn, bool coe, int *fdp);
static int is_root(vnode *root, vnode **mount); static int is_root(vnode *root, vnode **mount);
static int is_mount_vnode(vnode *mount, vnode **root); static int is_mount_vnode(vnode *mount, vnode **root);
@@ -197,14 +197,14 @@ static ofile * get_fd(bool kernel, int fd, int type);
static int put_fd(ofile *f); static int put_fd(ofile *f);
static int new_fd(bool kernel, int nfd, ofile *f, int fd, bool coe); static int new_fd(bool kernel, int nfd, ofile *f, int fd, bool coe);
static int remove_fd(bool kernel, int fd, int type); static int remove_fd(bool kernel, int fd, int type);
static int get_coe(bool kernel, int fd, int type, bool *coe); //static int get_coe(bool kernel, int fd, int type, bool *coe);
static int set_coe(bool kernel, int fd, int type, bool coe); //static int set_coe(bool kernel, int fd, int type, bool coe);
static int get_omode(bool kernel, int fd, int type, int *omode); //static int get_omode(bool kernel, int fd, int type, int *omode);
static int invoke_close(ofile *f); static int invoke_close(ofile *f);
static int invoke_free(ofile *f); static int invoke_free(ofile *f);
static fdarray * new_fds(int num); static fdarray * new_fds(int num);
static int free_fds(fdarray *fds); //static int free_fds(fdarray *fds);
#define BITSZ(n) (((n) + 31) & ~31) #define BITSZ(n) (((n) + 31) & ~31)
@@ -461,7 +461,6 @@ init_vnode_layer(void)
fsystem *fs; fsystem *fs;
nspace *ns; nspace *ns;
void *data; void *data;
size_t sz;
extern vnode_ops rootfs; /* XXXdbg */ extern vnode_ops rootfs; /* XXXdbg */
/* /*
@@ -970,7 +969,6 @@ sys_open(bool kernel, int fd, const char *path, int omode, int perms,
void *cookie; void *cookie;
ofile *f; ofile *f;
int nfd; int nfd;
fdarray *fds;
op_create *opc; op_create *opc;
op_open *opo; op_open *opo;
op_free_cookie *opf; op_free_cookie *opf;
@@ -1066,12 +1064,9 @@ sys_open_entry_ref(bool kernel, nspace_id device, vnode_id parent, const char *n
{ {
int err; int err;
vnode *vn; vnode *vn;
vnode_id vnid;
void *cookie; void *cookie;
ofile *f; ofile *f;
int nfd; int nfd;
fdarray *fds;
op_create *opc;
op_open *opo; op_open *opo;
op_free_cookie *opf; op_free_cookie *opf;
@@ -1901,7 +1896,7 @@ sys_open_query(bool kernel, int fd, const char *path, const char *query, ulong f
int err; int err;
nspace *ns; nspace *ns;
fsystem *fs; fsystem *fs;
vnode *root, *vn, *mount; vnode *root;
printf("sys_open_query() -- start\n"); printf("sys_open_query() -- start\n");
err = get_file_fd(TRUE, fd, path, TRUE, &root); err = get_file_fd(TRUE, fd, path, TRUE, &root);
@@ -1931,7 +1926,7 @@ sys_close_query(bool kernel, int fd, const char *path, void *cookie)
int err; int err;
nspace *ns; nspace *ns;
fsystem *fs; fsystem *fs;
vnode *root, *vn, *mount; vnode *root;
err = get_file_fd(TRUE, fd, path, TRUE, &root); err = get_file_fd(TRUE, fd, path, TRUE, &root);
if (err) if (err)
@@ -1962,7 +1957,7 @@ sys_read_query(bool kernel, int fd, const char *path, void *cookie,struct dirent
int err; int err;
nspace *ns; nspace *ns;
fsystem *fs; fsystem *fs;
vnode *root, *vn, *mount; vnode *root;
long num; long num;
err = get_file_fd(TRUE, fd, path, TRUE, &root); err = get_file_fd(TRUE, fd, path, TRUE, &root);
@@ -2122,12 +2117,9 @@ parse_path_vn(nspace_id nsid, vnode_id vnid, char **pstart, int eatsymlink,
return err; return err;
} }
return parse_path(bvn, pstart, path, eatsymlink, vnp); return parse_path(bvn, pstart, path, eatsymlink, vnp);
error1:
dec_vnode(bvn, FALSE);
return err;
} }
static int static int
parse_path(vnode *bvn, char **pstart, char *path, int eatsymlink, vnode **vnp) parse_path(vnode *bvn, char **pstart, char *path, int eatsymlink, vnode **vnp)
{ {
@@ -2336,8 +2328,8 @@ restart:
else { else {
printf("new_vnode(): vnode already exists with the same data (vnode id = %Ld)\n", vnid); printf("new_vnode(): vnode already exists with the same data (vnode id = %Ld)\n", vnid);
vn->rcnt++; vn->rcnt++;
return;
UNLOCK(vnlock); UNLOCK(vnlock);
return 0;
} }
} }
@@ -2446,7 +2438,7 @@ dec_vnode(vnode *vn, char r)
LOCK(vnlock); LOCK(vnlock);
vn->rcnt--; vn->rcnt--;
if (vn->rcnt == 0) if (vn->rcnt == 0) {
if (vn->remove) { if (vn->remove) {
vn->busy = TRUE; vn->busy = TRUE;
move_vnode(vn, LOCKED_LIST); move_vnode(vn, LOCKED_LIST);
@@ -2463,6 +2455,7 @@ dec_vnode(vnode *vn, char r)
move_vnode(ovn, FREE_LIST); move_vnode(ovn, FREE_LIST);
} }
} }
}
UNLOCK(vnlock); UNLOCK(vnlock);
return; return;
@@ -2514,12 +2507,12 @@ move_vnode(vnode *vn, int list)
if (vn->list.prev) if (vn->list.prev)
vn->list.prev->list.next = vn->list.next; vn->list.prev->list.next = vn->list.next;
else else
lists[vn->inlist].head = vn->list.next; lists[(int)vn->inlist].head = vn->list.next;
if (vn->list.next) if (vn->list.next)
vn->list.next->list.prev = vn->list.prev; vn->list.next->list.prev = vn->list.prev;
else else
lists[vn->inlist].tail = vn->list.prev; lists[(int)vn->inlist].tail = vn->list.prev;
lists[vn->inlist].num--; lists[(int)vn->inlist].num--;
vn->inlist = list; vn->inlist = list;
vn->list.next = NULL; vn->list.next = NULL;
vn->list.prev = lists[list].tail; vn->list.prev = lists[list].tail;
@@ -2579,7 +2572,7 @@ load_vnode(nspace_id nsid, vnode_id vnid, char r, vnode **vnp)
LOCK(vnlock); LOCK(vnlock);
while (TRUE) { while (TRUE) {
vn = lookup_vnode(nsid, vnid); vn = lookup_vnode(nsid, vnid);
if (vn) if (vn) {
if (vn->busy) { if (vn->busy) {
UNLOCK(vnlock); UNLOCK(vnlock);
snooze(SLEEP_TIME); snooze(SLEEP_TIME);
@@ -2587,6 +2580,7 @@ load_vnode(nspace_id nsid, vnode_id vnid, char r, vnode **vnp)
continue; continue;
} else } else
break; break;
}
vn = steal_vnode(FREE_LIST); vn = steal_vnode(FREE_LIST);
if (!vn) { if (!vn) {
@@ -2933,6 +2927,7 @@ remove_fd(bool kernel, int fd, int type)
return err; return err;
} }
#if 0
static int static int
get_coe(bool kernel, int fd, int type, bool *coe) get_coe(bool kernel, int fd, int type, bool *coe)
{ {
@@ -3004,6 +2999,7 @@ get_omode(bool kernel, int fd, int type, int *omode)
UNLOCK(fds->lock); UNLOCK(fds->lock);
return EBADF; return EBADF;
} }
#endif
static int static int
invoke_close(ofile *f) invoke_close(ofile *f)
@@ -3068,6 +3064,7 @@ nsidtons(nspace_id nsid)
return ns; return ns;
} }
#if 0
static int static int
alloc_wd_fd(bool kernel, vnode *vn, bool coe, int *fdp) alloc_wd_fd(bool kernel, vnode *vn, bool coe, int *fdp)
{ {
@@ -3104,7 +3101,7 @@ error2:
error1: error1:
return err; return err;
} }
#endif
/* /*
@@ -3217,6 +3214,7 @@ new_fds(int num)
return fds; return fds;
} }
#if 0
static int static int
free_fds(fdarray *fds) free_fds(fdarray *fds)
{ {
@@ -3238,7 +3236,7 @@ free_fds(fdarray *fds)
free(fds); free(fds);
return 0; return 0;
} }
#endif
// dummies // dummies
@@ -651,7 +651,7 @@ rootfs_readdir(void *_ns, void *_node, void *_cookie, long *num,
nspace *ns; nspace *ns;
vnode *node; vnode *node;
dirpos *cookie; dirpos *cookie;
char *e, *q; char *e;
struct my_dirent *p; struct my_dirent *p;
long i; long i;
vnode *vn; vnode *vn;
@@ -699,8 +699,9 @@ rootfs_readdir(void *_ns, void *_node, void *_cookie, long *num,
} }
if ((cookie->pos > 2) && (i > 0)) if ((cookie->pos > 2) && (i > 0))
strcpy(cookie->name, last); strcpy(cookie->name, last);
*num = i; *num = i;
exit:
UNLOCK(cookie->lock); UNLOCK(cookie->lock);
UNLOCK(ns->lock); UNLOCK(ns->lock);
return 0; return 0;
@@ -282,8 +282,8 @@ void *SearchSL(SkipList l, void *key)
void DoForSL(SkipList l, int (*function)(), void *arg) void DoForSL(SkipList l, int (*function)(), void *arg)
{ {
register SLNode p,q, fix; register SLNode p, q, fix;
register int k,m, ret; register int k, ret;
SLNode save[MaxNumberOfLevels], who[MaxNumberOfLevels]; SLNode save[MaxNumberOfLevels], who[MaxNumberOfLevels];
void (*freeitem)() = l->freeitem; void (*freeitem)() = l->freeitem;
@@ -347,7 +347,7 @@ void DoForSL(SkipList l, int (*function)(), void *arg)
void DoForRangeSL(SkipList l, void *key, int (*compare)(), int (*func)(), void DoForRangeSL(SkipList l, void *key, int (*compare)(), int (*func)(),
void *arg) void *arg)
{ {
register int k,m; register int k;
SLNode update[MaxNumberOfLevels]; SLNode update[MaxNumberOfLevels];
register SLNode p,q; register SLNode p,q;
void (*freeitem)() = l->freeitem; void (*freeitem)() = l->freeitem;
@@ -93,7 +93,6 @@ device_is_removeable(int fd)
#ifdef unix #ifdef unix
return 0; /* XXXdbg should do an ioctl or something */ return 0; /* XXXdbg should do an ioctl or something */
#else #else
struct stat st;
device_geometry dg; device_geometry dg;
if (ioctl(fd, B_GET_GEOMETRY, &dg) < 0) { if (ioctl(fd, B_GET_GEOMETRY, &dg) < 0) {
@@ -335,6 +334,7 @@ system_time(void)
#endif /* unix */ #endif /* unix */
#ifdef __BEOS__ #ifdef __BEOS__
#include <KernelExport.h>
void void
dprintf(const char *format, ...) dprintf(const char *format, ...)
@@ -35,12 +35,12 @@ tracker_query_file(dev_t device, ino_t parent, char *name)
sys_close(true, fd); sys_close(true, fd);
} }
#if 0
static void static void
tracker_scan_files(void) tracker_scan_files(void)
{ {
} }
#endif
extern "C" int32 extern "C" int32
tracker_loop(void *data) tracker_loop(void *data)
@@ -74,4 +74,5 @@ tracker_loop(void *data)
} }
delete_port(gTrackerPort); delete_port(gTrackerPort);
return B_OK;
} }