static int zcp_children_list(lua_State *state) { const char *fsname = lua_tostring(state, 1); dsl_pool_t *dp = zcp_run_info(state)->zri_pool; boolean_t issnap; uint64_t dsobj; dsl_dataset_t *ds = zcp_dataset_hold(state, dp, fsname, FTAG); if (ds == NULL) return (1); /* not reached; zcp_dataset_hold() longjmp'd */ issnap = ds->ds_is_snapshot; dsobj = ds->ds_object; dsl_dataset_rele(ds, FTAG); if (issnap) { return (zcp_argerror(state, 1, "argument %s cannot be a snapshot", fsname)); } lua_pushnumber(state, dsobj); lua_pushnumber(state, 0); lua_pushcclosure(state, &zcp_children_iter, 2); return (1); }
static int zcp_clones_list(lua_State *state) { const char *snapname = lua_tostring(state, 1); dsl_pool_t *dp = zcp_run_info(state)->zri_pool; boolean_t issnap; uint64_t dsobj, cursor; /* * zcp_dataset_hold will either successfully return the requested * dataset or throw a lua error and longjmp out of the zfs.list.clones * call without returning. */ dsl_dataset_t *ds = zcp_dataset_hold(state, dp, snapname, FTAG); if (ds == NULL) return (1); /* not reached; zcp_dataset_hold() longjmp'd */ cursor = 0; issnap = ds->ds_is_snapshot; dsobj = ds->ds_object; dsl_dataset_rele(ds, FTAG); if (!issnap) { return (zcp_argerror(state, 1, "%s is not a snapshot", snapname)); } lua_pushnumber(state, dsobj); lua_pushnumber(state, cursor); lua_pushcclosure(state, &zcp_clones_iter, 2); return (1); }
int zcp_dataset_hold_error(lua_State *state, dsl_pool_t *dp, const char *dsname, int error) { if (error == ENOENT) { (void) zcp_argerror(state, 1, "no such dataset '%s'", dsname); return (0); /* not reached; zcp_argerror will longjmp */ } else if (error == EXDEV) { (void) zcp_argerror(state, 1, "dataset '%s' is not in the target pool '%s'", dsname, spa_name(dp->dp_spa)); return (0); /* not reached; zcp_argerror will longjmp */ } else if (error == EIO) { (void) luaL_error(state, "I/O error while accessing dataset '%s'", dsname); return (0); /* not reached; luaL_error will longjmp */ } else if (error != 0) { (void) luaL_error(state, "unexpected error %d while accessing dataset '%s'", error, dsname); return (0); /* not reached; luaL_error will longjmp */ } return (0); }