new MountCommand().execute(args);
}
public void execute() throws Exception {
// Find the filesystem service
final FileSystemService fss = InitialNaming.lookup(FileSystemService.NAME);
PrintWriter out = getOutput().getPrintWriter();
PrintWriter err = getError().getPrintWriter();
if (!argDevice.isSet()) {
// List all mounted file systems
Map<String, FileSystem<?>> filesystems = fss.getMountPoints();
for (Map.Entry<String, FileSystem<?>> stringFileSystemEntry : filesystems.entrySet()) {
FileSystem<?> fs = stringFileSystemEntry.getValue();
Device device = fs.getDevice();
String mode = fs.isReadOnly() ? "ro" : "rw";
String type = fs.getType().getName();
out.format(fmt_mount, device.getId(), stringFileSystemEntry.getKey(), type, mode);
}
} else {
// Get the parameters
final Device dev = argDevice.getValue();
final File mountPoint = argDir.getValue();
final File fsPath = argFspath.getValue();
// Find the filesystem
final FileSystem<?> fs = fss.getFileSystem(dev);
if (fs == null) {
err.format(fmt_err_nofs, dev.getId());
exit(1);
} else {
// Mount it
fss.mount(mountPoint.toString(), fs, fsPath.toString());
}
}
}