Exemple #1
0
        void listDataSetName(long objectId, string nameBase, List <DatasetDirectory> ret)
        {
            var dsd = new DatasetDirectory(mMos, objectId, nameBase, mZio);

            ret.Add(dsd);

            foreach (var kvp in dsd.GetChildIds())
            {
                listDataSetName(kvp.Value, nameBase + "/" + kvp.Key, ret);
            }
        }
Exemple #2
0
        internal Zpl(ObjectSet mos, long objectid, Zio zio)
        {
            this.mZio = zio;

            var rootDataSetObj = mos.ReadEntry(objectid);

            if (!DatasetDirectory.IsDataSet(rootDataSetObj))
            {
                throw new Exception("Not a DSL_DIR.");
            }
            mDataset = rootDataSetObj.GetBonus <dsl_dataset_phys_t>();

            if (rootDataSetObj.IsNewType && rootDataSetObj.NewType == dmu_object_byteswap.DMU_BSWAP_ZAP)
            {
                var dataSetExtensions = Zap.Parse(rootDataSetObj);
            }

            if (mDataset.prev_snap_obj != 0)
            {
                var dn     = mos.ReadEntry(mDataset.prev_snap_obj);
                var moreDs = dn.GetBonus <dsl_dataset_phys_t>();
            }

            if (mDataset.props_obj != 0)
            {
                var someProps = Zap.Parse(mos, mDataset.props_obj);
            }

            mZfsObjset = new ObjectSet(mZio, zio.Get <objset_phys_t>(mDataset.bp));
            if (mZfsObjset.Type != dmu_objset_type_t.DMU_OST_ZFS)
            {
                throw new NotSupportedException();
            }
            mZfsObjDir = Zap.GetDirectoryEntries(mZfsObjset, 1);
            if (mZfsObjDir["VERSION"] != 5)
            {
                throw new NotSupportedException();
            }

            var saAttrs    = Zap.GetDirectoryEntries(mZfsObjset, mZfsObjDir["SA_ATTRS"]);
            var saLayouts  = Zap.Parse(mZfsObjset.ReadEntry(saAttrs["LAYOUTS"]));
            var saRegistry = Zap.GetDirectoryEntries(mZfsObjset, saAttrs["REGISTRY"]);

            mAttrSize = new Dictionary <zpl_attr_t, int>();
            foreach (var kvp in saRegistry)
            {
                var attrName = (zpl_attr_t)(kvp.Value & 0xffff);
                var size     = (int)(kvp.Value >> 24 & 0xffff);
                if (kvp.Key != attrName.ToString())
                {
                    throw new Exception();
                }
                mAttrSize.Add(attrName, size);
            }

            foreach (var layoutName in saLayouts.Keys)
            {
                var layoutNumber = int.Parse(layoutName);
                var types        = ((short[])saLayouts[layoutName]).Select(a => (zpl_attr_t)a).ToArray();
                mAttrLayouts.Add(layoutNumber, new SaLayout(mAttrSize, types));
            }
        }
Exemple #3
0
        public DatasetDirectory GetRootDataset()
        {
            var dsd = new DatasetDirectory(mMos, mObjDir[ROOT_DATASET], mConfig.Get <string>("name"), mZio);

            return(dsd);
        }