コード例 #1
0
ファイル: stat.c プロジェクト: Ninals-GitHub/TRON
/*
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
 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));
}
コード例 #2
0
ファイル: fcntl.c プロジェクト: Ninals-GitHub/TRON
/*
==================================================================================
 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);
}
コード例 #3
0
ファイル: support.c プロジェクト: tnt/rdiff-backup-fs
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;
};
コード例 #4
0
ファイル: simple.c プロジェクト: tnt/rdiff-backup-fs
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);

};