/** * Returns {@link #getName() the name}. */ @Override public String toString() { return getName(); } }
/** * Returns {@link #getName() the name}. */ @Override public String toString() { return getName(); }
/** * Creates a nested file system. * * @param props * ZFS properties to be attached to the new file system. Can be null. */ public ZFSFileSystem createFileSystem(final String name, final Map<String, String> props) { return (ZFSFileSystem) library.create(getName()+'/'+name, ZFSType.FILESYSTEM,props); }
/** * Opens a nested file system. */ public ZFSFileSystem openFileSystem(String name) { return library.open(getName()+'/'+name,ZFSFileSystem.class); }
/** * Creates a nested file system. * * @param props * ZFS properties to be attached to the new file system. Can be null. */ public ZFSFileSystem createFileSystem(final String name, final Map<String, String> props) { return (ZFSFileSystem) library.create(getName()+'/'+name, ZFSType.FILESYSTEM,props); }
/** * Opens a nested file system. */ public ZFSFileSystem openFileSystem(String name) { return library.open(getName()+'/'+name,ZFSFileSystem.class); }
private <T extends ZFSObject> List<T> children(Class<T> type, List<T> list, boolean recursive) { for (ZFSObject snap : snapshots()) { if(type.isInstance(snap)) list.add(type.cast(snap)); } for (ZFSObject child : getChildren()) { if (!child.getName().contains("@")) { if(type.isInstance(child)) list.add(type.cast(child)); if(recursive) child.children(type,list,recursive); } } return list; }
private <T extends ZFSObject> List<T> children(Class<T> type, List<T> list, boolean recursive) { for (ZFSObject snap : snapshots()) { if(type.isInstance(snap)) list.add(type.cast(snap)); } for (ZFSObject child : getChildren()) { if (!child.getName().contains("@")) { if(type.isInstance(child)) list.add(type.cast(child)); if(recursive) child.children(type,list,recursive); } } return list; }
/** * Sets a user-defined property. */ public void setProperty(String key, String value) { if (LIBZFS.zfs_prop_set(handle, key, value) != 0) throw new ZFSException(library,"Failed to set property "+key+" on "+getName()); }
/** * Sets a user-defined property. */ public void setProperty(String key, String value) { if (LIBZFS.zfs_prop_set(handle, key, value) != 0) throw new ZFSException(library,"Failed to set property "+key+" on "+getName()); }
/** * Wipes out the dataset and all its data. Very dangerous. * * <p> * If this dataset contains nested datasets, this method fails with * {@link ErrorCode#EZFS_EXISTS}. */ public void destory() { if (LIBZFS.zfs_destroy(handle) != 0) throw new ZFSException(library,"Failed to destroy "+getName()); }
/** * Destroy a named snapshot of this dataset. */ public void destroySnapshot(String name) { String abi = library.getFeature("LIBZFS4J_ABI_zfs_destroy_snaps"); if (abi.equals("openzfs")) { if (LIBZFS.zfs_destroy_snaps(handle, name, false/*?*/) != 0) throw new ZFSException(library,"Failed to destroy "+getName()); } else { if (LIBZFS.zfs_destroy_snaps(handle, name) != 0) throw new ZFSException(library,"Failed to destroy "+getName()); } }
public ZFSObject rollback(boolean recursive) { String filesystem = name.substring(0, getName().indexOf("@")); ZFSObject fs = library.open(filesystem); if (recursive) { /* first pass - check for clones */ List<ZFSObject> list = fs.getChildren(); for (ZFSObject child : list) { if (!child.getName().startsWith(filesystem + "@")) { return child; } } /* second pass - find snapshot index, destroy later snapshots */ boolean found = false; for (ZFSObject snap : fs.snapshots()) { String name = snap.getName(); if (name.equals(getName())) { found = true; continue; } if (found) { snap.destory(); } } } if (LIBZFS.zfs_rollback(fs.handle, handle, recursive) != 0) throw new ZFSException(library); return library.open(filesystem); }
public ZFSObject rollback(boolean recursive) { String filesystem = name.substring(0, getName().indexOf("@")); ZFSObject fs = library.open(filesystem); if (recursive) { /* first pass - check for clones */ List<ZFSObject> list = fs.getChildren(); for (ZFSObject child : list) { if (!child.getName().startsWith(filesystem + "@")) { return child; } } /* second pass - find snapshot index, destroy later snapshots */ boolean found = false; for (ZFSObject snap : fs.snapshots()) { String name = snap.getName(); if (name.equals(getName())) { found = true; continue; } if (found) { snap.destory(); } } } if (LIBZFS.zfs_rollback(fs.handle, handle, recursive) != 0) throw new ZFSException(library); return library.open(filesystem); }
/** * Wipes out the dataset and all its data. Very dangerous. * * <p> * If this dataset contains nested datasets, this method fails with * {@link ErrorCode#EZFS_EXISTS}. */ public void destroy() { String abi = library.getFeature("LIBZFS4J_ABI_zfs_destroy"); if (abi.equals("openzfs")) { if (LIBZFS.zfs_destroy(handle,false/*?*/) != 0) throw new ZFSException(library,"Failed to destroy "+getName()); } else { if (LIBZFS.zfs_destroy(handle) != 0) throw new ZFSException(library,"Failed to destroy "+getName()); } }