READ_ONLY_FLAG.isSet() ? true : READ_WRITE_FLAG.isSet() ? false
: (uid == -1 && gid == -1);
// Now do the work of mounting the file system, taking care to undo as much as
// we can in the event of a failure.
final DeviceManager dm = DeviceUtils.getDeviceManager();
final NFS2Device dev = new NFS2Device(host, remoteDirectory, protocol, uid, gid);
dev.setDriver(new NFS2Driver());
dm.register(dev);
boolean ok = false;
try {
final FileSystemService fss = InitialNaming.lookup(FileSystemService.NAME);
NFS2FileSystemType type = fss.getFileSystemType(NFS2FileSystemType.ID);
final NFS2FileSystem fs = type.create(dev, readOnly);
fss.registerFileSystem(fs);
try {
fss.mount(mountPoint.getAbsolutePath(), fs, null);
ok = true;
} finally {
if (!ok) {
fss.unregisterFileSystem(dev);
}
}
} finally {
if (!ok) {
dm.unregister(dev);
}
}
}