Example #1
0
ReturnValue SmbFs::map(QString src, QStringList args)
{
	//make sure the path has / and \, and that it doesn't end with a /
	src = src.replace("\\","/");
	if(src.endsWith("/")) src.mid(0,src.length()-1);
	
	_path=src;
	
	if(args.size() == 2)
	{
		_user = args[0];
		_pass = args[1];
	}
	
	struct stat *buf = new struct stat();
	
	int ret=0;
	
	if((ret = fs_getattr("/",buf)) == 0)
	{
		qDebug() << "Success!";
		return(true);
	}
	else
	{
		qDebug() << "Failure!" << strerror(errno);
		return(ReturnValue(1,QString("Failed to map: ") + strerror(errno)));
	}
	
	return(false);
}
Example #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);
}
Example #3
0
/*
 * Check file access permissions.  For now, just return 0 (success!)
 * Later, actually check permissions (don't bother initially).
 */
int fs_access(const char *path, int mask) {
    fprintf(stderr, "fs_access(path=\"%s\", mask=0%o)\n", path, mask);
    s3context_t *ctx = GET_PRIVATE_DATA;
    
    struct stat * stat_buf = (struct stat *)malloc(sizeof(struct stat));
        
    int ret_val = fs_getattr(path, stat_buf);
    
    if (0 != ret_val) {
	free(stat_buf);
	return ret_val;
    }
    
    // I realize this might not be the correct and full implementation
    ret_val = (mask & stat_buf->st_mode);
    free(stat_buf);
    return ret_val;
}