=================================================================== RCS file: /cvs/prex-old/usr/server/fs/vfs/vfs_task.c,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.2.1 diff -u -r1.1.1.1 -r1.1.1.1.2.1 --- prex-old/usr/server/fs/vfs/vfs_task.c 2008/06/03 10:38:51 1.1.1.1 +++ prex-old/usr/server/fs/vfs/vfs_task.c 2008/08/13 17:12:45 1.1.1.1.2.1 @@ -63,7 +63,7 @@ #endif /* - * Lookup task by task id. + * Convert task ID to a task structure. * Returns locked task. Caller must unlock it after using it. */ struct task * @@ -134,7 +134,7 @@ } /* - * Update task id of specified task. + * Update task id of the specified task. */ void task_update(struct task *t, task_t task) @@ -168,6 +168,25 @@ } /* + * Get new file descriptor in the task. + * Find the smallest empty slot in the fd array. + * Returns -1 if there is no empty slot. + */ +int +task_newfd(struct task *t) +{ + int fd; + + for (fd = 0; fd < OPEN_MAX; fd++) + if (t->file[fd] == NULL) + break; + if (fd == OPEN_MAX) + return -1; /* slot full */ + + return fd; +} + +/* * Convert to full path from the cwd of task and path. * @t: task structure * @path: target path @@ -250,17 +269,18 @@ int i; TASK_LOCK(); - printf("Dump file data\n"); - printf(" task nr_open cwd\n"); - printf(" -------- ------- ------------------------------\n"); + dprintf("Dump file data\n"); + dprintf(" task opens cwd\n"); + dprintf(" -------- ------- ------------------------------\n"); for (i = 0; i < TASK_MAXBUCKETS; i++) { head = &task_table[i]; for (n = list_first(head); n != head; n = list_next(n)) { t = list_entry(n, struct task, link); - printf(" %08x %7x %s\n", t->task, t->nr_open, t->cwd); + dprintf(" %08x %7x %s\n", (int)t->task, t->nopens, + t->cwd); } } - printf("\n"); + dprintf("\n"); TASK_UNLOCK(); #endif } @@ -275,6 +295,7 @@ list_init(&task_table[i]); } +#ifdef DEBUG_VFS void task_debug(void) { @@ -283,9 +304,10 @@ for (i = 0; i < TASK_MAXBUCKETS; i++) { head = &task_table[i]; - syslog(LOG_DEBUG, "head=%x head->next=%x head->prev=%x\n", - head, head->next, head->prev); + dprintf("head=%x head->next=%x head->prev=%x\n", head, + head->next, head->prev); ASSERT(head->next); ASSERT(head->prev); } } +#endif