/* _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ Funtion :fstat64 Input :int fd < open file descriptor > struct stat64_i386 *buf < stat structure > Output :struct stat64_i386 *buf < stat structure > Return :int < result > Description :get file status _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ */ SYSCALL int fstat64(int fd, struct stat64_i386 *buf) { struct file *filp; struct vnode *vnode; int err; //printf("fstat64:fd=%d\n", fd); err = vm_check_access((void*)buf, sizeof(struct stat64_i386), PROT_WRITE); if (UNLIKELY(err)) { return(-EFAULT); } if (UNLIKELY(get_soft_limit(RLIMIT_NOFILE) < fd)) { return(-EBADF); } filp = get_open_file(fd); if (UNLIKELY(!filp)) { return(-EBADF); } vnode = filp->f_vnode; return(vfs_stat64(vnode, buf)); }
/* ================================================================================== Funtion :xfcntl Input :int fd < opne file descriptor > int cmd < command > unsigned long arg < argument > Output :void Return :int < result > Description :manipulate file descriptor ================================================================================== */ LOCAL int xfcntl(int fd, int cmd, unsigned long arg) { struct file *filp; int err; err = is_open_file(fd); if (UNLIKELY(err)) { return(-EBADF); } filp = get_open_file(fd); if (UNLIKELY(!filp)) { return(-EBADF); } switch (cmd) { case F_DUPFD: printf("fcntl:not implemented F_DUPFD\n"); for(;;); break; case F_GETFD: printf("fcntl:not implemented F_GETFD\n"); for(;;); break; case F_SETFD: printf("fcntl:not implemented F_SETFD\n"); for(;;); break; case F_GETFL: return(filp->f_flags); case F_SETFL: filp->f_flags = (unsigned int)arg; break; case F_GETLK: case F_SETLK: case F_SETLKW: case F_SETOWN: case F_GETOWN: case F_SETSIG: case F_GETSIG: case F_GETLK64: case F_SETLK64: case F_SETLKW64: case F_SETOWN_EX: case F_GETOWN_EX: case F_GETOWNER_UIDS: default: printf("fcntl:not implemented cmd[%d]\n", cmd); for(;;); break; } return(err); }
node_t * add_file(list_t *list, char *path, int rev){ if (list->head == NULL){ list->head = list->tail = single(node_t); gstrcpy(&list->head->path, path); return list->head; } node_t *node = get_open_file(path); if (node) return node; node = single(node_t); list->tail->next = node; node->prev = list->tail; list->tail = node; gstrcpy(&node->path, path); node->rev = rev; return node; };
int __release_simple(struct stats *stats, int index){ #define __release_simple_finish(value){ \ unlock(file_mutex[index][stats->rev]); \ return value; \ } lock(file_mutex[index][stats->rev]); node_t *node = get_open_file(stats->path); if (!node) return -1; node->count--; if (node->count == 0){ unlink(node->tmp_path); delete_open_file(node); }; __release_simple_finish(0); };