1215 }
1216
1217 /* ARGSUSED */
1218 static int
1219 restore_freeobjects(struct restorearg *ra, objset_t *os,
1220 struct drr_freeobjects *drrfo)
1221 {
1222 uint64_t obj;
1223
1224 if (drrfo->drr_firstobj + drrfo->drr_numobjs < drrfo->drr_firstobj)
1225 return (SET_ERROR(EINVAL));
1226
1227 for (obj = drrfo->drr_firstobj;
1228 obj < drrfo->drr_firstobj + drrfo->drr_numobjs;
1229 (void) dmu_object_next(os, &obj, FALSE, 0)) {
1230 int err;
1231
1232 if (dmu_object_info(os, obj, NULL) != 0)
1233 continue;
1234
1235 err = dmu_free_object(os, obj);
1236 if (err != 0)
1237 return (err);
1238 }
1239 return (0);
1240 }
1241
1242 static int
1243 restore_write(struct restorearg *ra, objset_t *os,
1244 struct drr_write *drrw)
1245 {
1246 dmu_tx_t *tx;
1247 void *data;
1248 int err;
1249
1250 if (drrw->drr_offset + drrw->drr_length < drrw->drr_offset ||
1251 !DMU_OT_IS_VALID(drrw->drr_type))
1252 return (SET_ERROR(EINVAL));
1253
1254 data = restore_read(ra, drrw->drr_length);
1255 if (data == NULL)
|
1215 }
1216
1217 /* ARGSUSED */
1218 static int
1219 restore_freeobjects(struct restorearg *ra, objset_t *os,
1220 struct drr_freeobjects *drrfo)
1221 {
1222 uint64_t obj;
1223
1224 if (drrfo->drr_firstobj + drrfo->drr_numobjs < drrfo->drr_firstobj)
1225 return (SET_ERROR(EINVAL));
1226
1227 for (obj = drrfo->drr_firstobj;
1228 obj < drrfo->drr_firstobj + drrfo->drr_numobjs;
1229 (void) dmu_object_next(os, &obj, FALSE, 0)) {
1230 int err;
1231
1232 if (dmu_object_info(os, obj, NULL) != 0)
1233 continue;
1234
1235 err = dmu_free_long_object(os, obj);
1236 if (err != 0)
1237 return (err);
1238 }
1239 return (0);
1240 }
1241
1242 static int
1243 restore_write(struct restorearg *ra, objset_t *os,
1244 struct drr_write *drrw)
1245 {
1246 dmu_tx_t *tx;
1247 void *data;
1248 int err;
1249
1250 if (drrw->drr_offset + drrw->drr_length < drrw->drr_offset ||
1251 !DMU_OT_IS_VALID(drrw->drr_type))
1252 return (SET_ERROR(EINVAL));
1253
1254 data = restore_read(ra, drrw->drr_length);
1255 if (data == NULL)
|