コード例 #1
0
ファイル: fs.c プロジェクト: champo/ArqvengerOS
int fs_symlink(struct fs_Inode* path, const char* entry, const char* to) {

    if (fs_mknod(path, entry, INODE_LINK) != 0) {
        return -1;
    }

    struct fs_DirectoryEntry direntry = fs_findentry(path, entry);

    if (direntry.inode == 0) {
        //TODO should the new node be unlinked?
        return -1;
    }

    struct fs_Inode* file = fs_inode_open(direntry.inode);

    fs_set_permission(file, 00666);

    int length = strlen(to);

    if (length != ext2_write_inode_content(file, 0, length, to)) {
        //TODO hay que hacerle unlink al mknod?
        fs_inode_close(file);
        return -1;
    }
    fs_inode_close(file);
    return 0;
}
コード例 #2
0
int SmbFs::fs_truncate(const char *path, off_t size)
{
	if(size == 0)
	{
		return(fs_mknod(path,0666,0));
	}
	else
	{
		struct stat *buf = new struct stat();
		int ret=0;
		if((ret = fs_getattr(path,buf)) != 0) return(ret);
		if(size == buf->st_size) return(0);
	}
	
	return(-ENOSYS);
}