return existing.getName(); hudson.setMountPoint(dir); hudson.mount(); if(LIBC.chown(dir.getPath(),uid,gid)!=0) throw new IOException("Failed to chown "+dir); hudson.unmount(); hudson.setProperty("hudson:managed-by","hudson"); // mark this file system as "managed by Hudson" hudson.allow(acl); } catch (ZFSException e) { hudson.destory(); } catch (Exception ignored) { return hudson.getName();
hudson.setMountPoint(tmpDir); hudson.setProperty("hudson:managed-by","hudson"); // mark this file system as "managed by Hudson" hudson.mount(); hudson.unmount(MountFlags.MS_FORCE); hudson.setMountPoint(home); hudson.mount(); hudson.setProperty("sharesmb","on"); hudson.setProperty("sharenfs","on"); hudson.share(); } catch (ZFSException e) { listener.error("Failed to share the file systems: "+e.getCode());
@Override public Void invoke(File f, VirtualChannel channel) throws IOException { ZFSFileSystem fs = libzfs.getFileSystemByMountPoint(f); if(fs!=null) return null; // already on ZFS // nope. create a file system String fullName = rootDataset + '/' + name; listener.getLogger().println("Creating a ZFS file system "+fullName+" at "+f); fs = libzfs.create(fullName, ZFSFileSystem.class); fs.setMountPoint(f); fs.mount(); return null; } }
/** * Creates a clone from this snapshot. * * This method fails if this {@link ZFSObject} is not a snapshot. */ public ZFSFileSystem clone(String fullDestinationName) { if (LIBZFS.zfs_clone(handle, fullDestinationName, null) != 0) throw new ZFSException(library); ZFSFileSystem target = (ZFSFileSystem) library.open(fullDestinationName); // this behavior mimics "zfs clone" target.mount(); target.share(); return target; }
/** * Unmounts this file system. */ public void unmount() { unmount(0); }
/** * Mounts this file system. */ public void mount() { mount(0); }
public void setProperty(String key, String value) { zfsFileSystem.setProperty(key, value); }
@Override public Void invoke(File f, VirtualChannel channel) throws IOException { ZFSFileSystem fs = libzfs.getFileSystemByMountPoint(f); if(fs!=null) fs.destory(true); return null; } }
public void share() { zfsFileSystem.share(); }
public void setMountPoint(File dir) { zfsFileSystem.setMountPoint(dir); }
public int callback(zfs_handle_t handle, Pointer arg) { r.add(new ZFSFileSystem(LibZFS.this, handle)); return 0; } }, null);
public void allow(String userName) { ACLBuilder acl = new ACLBuilder(); acl.user(userName).withEverything(); zfsFileSystem.allow(acl); }
public <T extends ZFSObject> List<T> descendants(Class<T> type) { ArrayList<T> r = new ArrayList<T>(); r.addAll(children(type)); for (ZFSFileSystem p : roots()) r.addAll(p.descendants(type)); return r; }
@Override public String invoke(File f, VirtualChannel channel) throws IOException { ZFSFileSystem fs = libzfs.getFileSystemByMountPoint(f); if(fs!=null) return fs.getName(); // TODO: for now, only support agents that are already on ZFS. throw new IOException("Not on ZFS"); } }
public Void invoke(File f, VirtualChannel channel) throws IOException { ZFSFileSystem fs = libzfs.getFileSystemByMountPoint(f); if(fs!=null) return null; // already on ZFS // nope. create a file system String fullName = rootDataset + '/' + name; listener.getLogger().println("Creating a ZFS file system "+fullName+" at "+f); fs = libzfs.create(fullName, ZFSFileSystem.class); fs.setMountPoint(f); fs.mount(); return null; } });
/** * Creates a clone from this snapshot. * * This method fails if this {@link ZFSObject} is not a snapshot. */ public ZFSFileSystem clone(String fullDestinationName) { if (LIBZFS.zfs_clone(handle, fullDestinationName, null) != 0) throw new ZFSException(library); ZFSFileSystem target = (ZFSFileSystem) library.open(fullDestinationName); // this behavior mimics "zfs clone" target.mount(); target.share(); return target; }
/** * Unmounts this file system. */ public void unmount() { unmount(0); }
/** * Mounts this file system. */ public void mount() { mount(0); }