X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=module%2Fzfs%2Fdmu_objset.c;h=1d0b4619fd0f20e612bf529cf8160bcbeae2825c;hb=1c5de20ae2511124613926e4f780572634818218;hp=0703a946687f399f455c0d48c702c929e93b6820;hpb=5d0265c0dd54d798a35babe587ad5138392fe807;p=zfs.git diff --git a/module/zfs/dmu_objset.c b/module/zfs/dmu_objset.c index 0703a94..1d0b461 100644 --- a/module/zfs/dmu_objset.c +++ b/module/zfs/dmu_objset.c @@ -1584,6 +1584,41 @@ dmu_snapshot_list_next(objset_t *os, int namelen, char *name, return (0); } +/* + * Determine the objset id for a given snapshot name. + */ +int +dmu_snapshot_id(objset_t *os, const char *snapname, uint64_t *idp) +{ + dsl_dataset_t *ds = os->os_dsl_dataset; + zap_cursor_t cursor; + zap_attribute_t attr; + int error; + + if (ds->ds_phys->ds_snapnames_zapobj == 0) + return (ENOENT); + + zap_cursor_init(&cursor, ds->ds_dir->dd_pool->dp_meta_objset, + ds->ds_phys->ds_snapnames_zapobj); + + error = zap_cursor_move_to_key(&cursor, snapname, MT_EXACT); + if (error) { + zap_cursor_fini(&cursor); + return (error); + } + + error = zap_cursor_retrieve(&cursor, &attr); + if (error) { + zap_cursor_fini(&cursor); + return (error); + } + + *idp = attr.za_first_integer; + zap_cursor_fini(&cursor); + + return (0); +} + int dmu_dir_list_next(objset_t *os, int namelen, char *name, uint64_t *idp, uint64_t *offp)