Beispiel #1
0
static void
emit_send(sl_compile_state_t* cs, size_t recv, SLID id, size_t arg_base, size_t arg_size, size_t return_reg)
{
    sl_vm_inline_method_cache_t* imc = sl_alloc(cs->vm->arena, sizeof(sl_vm_inline_method_cache_t));
    imc->argc = arg_size;
    imc->id = id;
    imc->call = NULL;

    op_send(cs, recv, imc, arg_base, return_reg);
}
Beispiel #2
0
static int
cr_symlink(struct cr_rec *l)
{
	static char *sdata = "foobar";

	assert(l->nse->type == NFLNK);

	if (op_barrier(CR_MAX_OUTSTANDING) < 0) {
		report_error(FATAL, "op_barrier error");
		return -1;
	}

	if (l->symlink_done == 0) {
		struct nfsmsg *nm;
		struct symlink_arg *arg;

		if ((nm = op_alloc(NFSPROC_SYMLINK)) == NULL) {
			report_error(FATAL, "op_alloc error");
			return -1;
		}
		arg = &nm->u.symlink_arg;

		arg->where.dir.len = l->parent_nse->fhlen;
		arg->where.dir.data = l->parent_nse->fhdata;
		arg->where.name.len = strlen(l->name);
		arg->where.name.data = l->name;
		arg->symlinkdata.sattr.sa_mode.present = 1;
		arg->symlinkdata.sattr.sa_mode.sa_mode = 00777; /*rwxrwxrwx*/
		arg->symlinkdata.sattr.sa_uid.present = 0;
		arg->symlinkdata.sattr.sa_gid.present = 0;
		arg->symlinkdata.sattr.sa_size.present = 0;
		arg->symlinkdata.sattr.sa_atime.present = 0;
		arg->symlinkdata.sattr.sa_mtime.present = 0;
		arg->symlinkdata.path.len = strlen(sdata);
		arg->symlinkdata.path.data = sdata;

		if (op_send(nm, cr_symlink_callback, l, NULL) < 0) {
			report_error(FATAL, "op_send error");
			return -1;
		}
		return 0; /* resume via callback */
	}

	free(l);
	created++;
	return 0;
}
Beispiel #3
0
static int
cr_file(struct cr_rec *f)
{
	assert(f->nse->type == NFREG);

	if (op_barrier(CR_MAX_OUTSTANDING) < 0) {
		report_error(FATAL, "op_barrier error");
		return -1;
	}

	if (f->create_done == 0) {
		struct nfsmsg *nm;
		struct create_arg *arg;

		if ((nm = op_alloc(NFSPROC_CREATE)) == NULL) {
			report_error(FATAL, "op_alloc error");
			return -1;
		}
		arg = &nm->u.create_arg;

		arg->where.dir.len = f->parent_nse->fhlen;
		arg->where.dir.data = f->parent_nse->fhdata;
		arg->where.name.len = strlen(f->name);
		arg->where.name.data = f->name;
		arg->createmode = NFSV3CREATE_UNCHECKED;
		arg->sattr.sa_mode.present = 1;
		arg->sattr.sa_mode.sa_mode = 00644; /*rw-r--r--*/
		arg->sattr.sa_uid.present = 0;
		arg->sattr.sa_gid.present = 0;
		arg->sattr.sa_size.present = 0;
		arg->sattr.sa_atime.present = 0;
		arg->sattr.sa_mtime.present = 0;

		if (op_send(nm, cr_create_callback, f, NULL) < 0) {
			report_error(FATAL, "op_send error");
			return -1;
		}
		return 0; /* resume via callback */
	}

	if (f->size_done < f->size) {
		struct nfsmsg *nm;
		struct write_arg *write_arg;

		/*
		 * if small payloads skip up to the next 8KB boundary.
		 */
		if (MAX_PAYLOAD_SIZE < 8192 && f->size_done + 8192 < f->size) {
			f->size_done = (f->size_done + 8191) & ~8191;
		}

		if ((nm = op_alloc(NFSPROC_WRITE)) == NULL) {
			report_error(FATAL, "op_alloc error");
			return -1;
		}
		write_arg = &nm->u.write_arg;

		write_arg->fh.len = f->nse->fhlen;
		write_arg->fh.data = f->nse->fhdata;
		write_arg->offset = f->size_done;
		write_arg->count = MIN(MAX_PAYLOAD_SIZE, f->size - f->size_done);
		write_arg->stable = NFSV3WRITE_UNSTABLE;
		write_arg->data.len = write_arg->count;
		write_arg->data.data = filedata;

		if (op_send(nm, cr_write_callback, f, NULL) < 0) {
			report_error(FATAL, "op_send error");
			return -1;
		}
		return 0; /* resume via callback */
	}

	free(f);
	created++;
	return 0;
}
Beispiel #4
0
static int
cr_dir(struct cr_rec *d)
{
	assert(d->nse->type == NFDIR);

	if (op_barrier(CR_MAX_OUTSTANDING) < 0) {
		report_error(FATAL, "op_barrier error");
		return -1;
	}

	if (d->mkdir_done == 0) {
		struct nfsmsg *nm;
		struct mkdir_arg *arg;

		if ((nm = op_alloc(NFSPROC_MKDIR)) == NULL) {
			report_error(FATAL, "op_alloc error");
			return -1;
		}
		arg = &nm->u.mkdir_arg;

		arg->where.dir.len = d->parent_nse->fhlen;
		arg->where.dir.data = d->parent_nse->fhdata;
		arg->where.name.len = strlen(d->name);
		arg->where.name.data = d->name;
		arg->sattr.sa_mode.present = 1;
		arg->sattr.sa_mode.sa_mode = 00755; /*rwxr-xr-x*/
		arg->sattr.sa_uid.present = 0;
		arg->sattr.sa_gid.present = 0;
		arg->sattr.sa_size.present = 0;
		arg->sattr.sa_atime.present = 0;
		arg->sattr.sa_mtime.present = 0;
		
		if (op_send(nm, cr_mkdir_callback, d, NULL) < 0) {
			report_error(FATAL, "op_send error");
			return -1;
		}
		return 0; /* resume via callback */
	}

	while (d->subfiles_done < d->subfiles) {
		cr_newfile(d->nse);
		d->subfiles_done++;
		/* do not return. create in parallel */
	}

	while (d->subsymlinks_done < d->subsymlinks) {
		cr_newsymlink(d->nse);
		d->subsymlinks_done++;
		/* do not return. create in parallel */
	}

	while (d->subdirs_done < d->subdirs) {
		cr_newdir(d->nse, d->maxdepth);
		d->subdirs_done++;
		/* do not return. create in parallel */
	}

	free(d);
	created++;
	return 0;
}