commons-cli
diff --git a/src/main/java/hcfsfuse/fuse/OpenFileEntry.java b/src/main/java/alluxio/fuse/OpenFileEntry.java
similarity index 64%
rename from src/main/java/hcfsfuse/fuse/OpenFileEntry.java
rename to src/main/java/alluxio/fuse/OpenFileEntry.java
index df9f42d..af7a46b 100644
--- a/src/main/java/hcfsfuse/fuse/OpenFileEntry.java
+++ b/src/main/java/alluxio/fuse/OpenFileEntry.java
@@ -1,47 +1,56 @@
-package hcfsfuse.fuse;
+/*
+ * The Alluxio Open Foundation licenses this work under the Apache License, version 2.0
+ * (the "License"). You may not use this work except in compliance with the License, which is
+ * available at www.apache.org/licenses/LICENSE-2.0
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied, as more fully set forth in the License.
+ *
+ * See the NOTICE file distributed with this work for information regarding copyright ownership.
+ */
+
+package alluxio.fuse;
import com.google.common.base.Preconditions;
-import org.apache.hadoop.fs.FSDataInputStream;
-import org.apache.hadoop.fs.FSDataOutputStream;
import javax.annotation.Nullable;
import javax.annotation.concurrent.NotThreadSafe;
import java.io.Closeable;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
/**
- * Convenience class to encapsulate input/output streams of open target files.
- *
+ * Convenience class to encapsulate input/output streams of open alluxio files.
+ *
* An open file can be either write-only or read-only, never both. This means that one of getIn or
* getOut will be null, while the other will be non-null. It is up to the user of this class
- * (currently, only {@link HCFSFuseFileSystem}) to check that.
- *
+ * (currently, only {@link AlluxioFuseFileSystem}) to check that.
+ *
* This mechanism is preferred over more complex sub-classing to avoid useless casts or type checks
* for every read/write call, which happen quite often.
*/
@NotThreadSafe
-final class OpenFileEntry implements Closeable {
-
+public final class OpenFileEntry
+ implements Closeable {
private final long mId;
- private final FSDataInputStream mIn;
- private final FSDataOutputStream mOut;
+ private final T1 mIn;
+ private final T2 mOut;
// Path is likely to be changed when fuse rename() is called
private String mPath;
- /**
- * the next write offset.
- */
+ /** the next write offset. */
private long mOffset;
/**
- * Constructs a new {@link OpenFileEntry} for an target file.
+ * Constructs a new {@link OpenFileEntry} for an Alluxio file.
*
* @param id the id of the file
* @param path the path of the file
* @param in the input stream of the file
* @param out the output stream of the file
*/
- OpenFileEntry(long id, String path, FSDataInputStream in, FSDataOutputStream out) {
+ public OpenFileEntry(long id, String path, T1 in, T2 out) {
Preconditions.checkArgument(id != -1 && !path.isEmpty());
Preconditions.checkArgument(in != null || out != null);
mId = id;
@@ -69,10 +78,10 @@ public String getPath() {
* Gets the opened input stream for this open file entry. The value returned can be {@code null}
* if the file is not open for reading.
*
- * @return an opened input stream for the open target file, or null
+ * @return an opened input stream for the open alluxio file, or null
*/
@Nullable
- public FSDataInputStream getIn() {
+ public T1 getIn() {
return mIn;
}
@@ -80,10 +89,10 @@ public FSDataInputStream getIn() {
* Gets the opened output stream for this open file entry. The value returned can be {@code null}
* if the file is not open for writing.
*
- * @return an opened input stream for the open target file, or null
+ * @return an opened input stream for the open alluxio file, or null
*/
@Nullable
- public FSDataOutputStream getOut() {
+ public T2 getOut() {
return mOut;
}
@@ -95,7 +104,8 @@ public long getWriteOffset() {
}
/**
- * Sets the path of the file. The file path can be changed if fuse rename() is called.
+ * Sets the path of the file. The file path can be changed
+ * if fuse rename() is called.
*
* @param path the new path of the file
*/
diff --git a/src/main/java/alluxio/jnifuse/FuseFillDir.java b/src/main/java/alluxio/jnifuse/FuseFillDir.java
deleted file mode 100644
index 218842a..0000000
--- a/src/main/java/alluxio/jnifuse/FuseFillDir.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package alluxio.jnifuse;
-
-import hcfsfuse.jnifuse.struct.FileStat;
-
-import java.nio.ByteBuffer;
-
-public class FuseFillDir {
- long address;
-
- FuseFillDir(long address) {
- this.address = address;
- }
-
- public native int fill(long address, long bufaddr, String name, ByteBuffer stbuf, long off);
-
- public int apply(long bufaddr, String name, FileStat stbuf, long off) {
- if (stbuf != null) {
- return fill(address, bufaddr, name, stbuf.buffer, off);
- } else {
- return fill(address, bufaddr, name, null, off);
- }
- }
-
- static {
- System.loadLibrary("jnifuse");
- }
-}
diff --git a/src/main/java/alluxio/jnifuse/LibFuse.java b/src/main/java/alluxio/jnifuse/LibFuse.java
deleted file mode 100644
index 62ead34..0000000
--- a/src/main/java/alluxio/jnifuse/LibFuse.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package alluxio.jnifuse;
-
-import hcfsfuse.jnifuse.AbstractFuseFileSystem;
-
-public class LibFuse {
-
- public native int fuse_main_real(AbstractFuseFileSystem fs, int argc, String[] argv);
-}
diff --git a/src/main/java/hcfsfuse/fuse/HCFSFuseFileSystem.java b/src/main/java/hcfsfuse/fuse/HCFSFuseFileSystem.java
index 40f0e99..d095b69 100644
--- a/src/main/java/hcfsfuse/fuse/HCFSFuseFileSystem.java
+++ b/src/main/java/hcfsfuse/fuse/HCFSFuseFileSystem.java
@@ -2,6 +2,8 @@
import alluxio.collections.IndexDefinition;
import alluxio.collections.IndexedSet;
+import alluxio.fuse.AlluxioFuseUtils;
+import alluxio.fuse.OpenFileEntry;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.cache.CacheBuilder;
@@ -50,26 +52,28 @@ public class HCFSFuseFileSystem extends FuseStubFS {
*/
@VisibleForTesting
public static final int MAX_NAME_LENGTH = 255;
- private static final long UID = HCFSFuseUtil.getUid(System.getProperty("user.name"));
- private static final long GID = HCFSFuseUtil.getGid(System.getProperty("user.name"));
+ private static final long UID = AlluxioFuseUtils.getUid(System.getProperty("user.name"));
+ private static final long GID = AlluxioFuseUtils.getGid(System.getProperty("user.name"));
private final Path mRootPath;
private final FileSystem mFileSystem;
// Table of open files with corresponding InputStreams and OutputStreams
- private final IndexedSet mOpenFiles;
+ private final IndexedSet> mOpenFiles;
private AtomicLong mNextOpenFileId = new AtomicLong(0);
private final LoadingCache mPathResolverCache;
// Open file managements
- private static final IndexDefinition ID_INDEX =
- new IndexDefinition(true) {
+ private static final IndexDefinition, Long>
+ ID_INDEX =
+ new IndexDefinition, Long>(true) {
@Override
public Long getFieldValue(OpenFileEntry o) {
return o.getId();
}
};
- private static final IndexDefinition PATH_INDEX =
- new IndexDefinition(true) {
+ private static final IndexDefinition, String>
+ PATH_INDEX =
+ new IndexDefinition, String>(true) {
@Override
public String getFieldValue(OpenFileEntry o) {
return o.getPath();
@@ -115,8 +119,8 @@ public int getattr(String path, FileStat stat) {
stat.st_ctim.tv_nsec.set(ctime_nsec);
stat.st_mtim.tv_sec.set(ctime_sec);
stat.st_mtim.tv_nsec.set(ctime_nsec);
- stat.st_uid.set(HCFSFuseUtil.getUid(status.getOwner()));
- stat.st_gid.set(HCFSFuseUtil.getGidFromGroupName(status.getGroup()));
+ stat.st_uid.set(AlluxioFuseUtils.getUid(status.getOwner()));
+ stat.st_gid.set(AlluxioFuseUtils.getGidFromGroupName(status.getGroup()));
stat.st_nlink.set(1);
} catch (IOException e) {
LOG.debug("Failed to get info of {}, path does not exist or is invalid", path);
@@ -182,13 +186,13 @@ public int mkdir(String path, @mode_t long mode) {
long uid = fc.uid.get();
long gid = fc.gid.get();
try {
- String groupName = HCFSFuseUtil.getGroupName(gid);
+ String groupName = AlluxioFuseUtils.getGroupName(gid);
if (groupName.isEmpty()) {
// This should never be reached since input gid is always valid
LOG.error("Failed to get group name from gid {}.", gid);
return -ErrorCodes.EFAULT();
}
- String userName = HCFSFuseUtil.getUserName(uid);
+ String userName = AlluxioFuseUtils.getUserName(uid);
if (userName.isEmpty()) {
// This should never be reached since input uid is always valid
LOG.error("Failed to get user name from uid {}", uid);
@@ -204,7 +208,7 @@ public int mkdir(String path, @mode_t long mode) {
return -ErrorCodes.ENOENT();
} catch (Throwable t) {
LOG.error("Failed to create directory {}", path, t);
- return HCFSFuseUtil.getErrorCode(t);
+ return AlluxioFuseUtils.getErrorCode(t);
}
return 0;
@@ -273,7 +277,8 @@ public int read(String path, Pointer buf, @size_t long size, @off_t long offset,
LOG.trace("read({}, {}, {})", path, size, offset);
final int sz = (int) size;
final long fd = fi.fh.get();
- OpenFileEntry oe = mOpenFiles.getFirstByField(ID_INDEX, fd);
+ OpenFileEntry oe =
+ mOpenFiles.getFirstByField(ID_INDEX, fd);
if (oe == null) {
LOG.error("Cannot find fd for {} in table", path);
return -ErrorCodes.EBADFD();
@@ -305,7 +310,7 @@ public int read(String path, Pointer buf, @size_t long size, @off_t long offset,
}
} catch (Throwable t) {
LOG.error("Failed to read file {}", path, t);
- return HCFSFuseUtil.getErrorCode(t);
+ return AlluxioFuseUtils.getErrorCode(t);
}
return nread;
@@ -343,7 +348,7 @@ public int create(String path, @mode_t long mode, FuseFileInfo fi) {
String gname = "";
String uname = "";
if (gid != GID) {
- String groupName = HCFSFuseUtil.getGroupName(gid);
+ String groupName = AlluxioFuseUtils.getGroupName(gid);
if (groupName.isEmpty()) {
// This should never be reached since input gid is always valid
LOG.error("Failed to get group name from gid {}.", gid);
@@ -352,7 +357,7 @@ public int create(String path, @mode_t long mode, FuseFileInfo fi) {
gname = groupName;
}
if (uid != UID) {
- String userName = HCFSFuseUtil.getUserName(uid);
+ String userName = AlluxioFuseUtils.getUserName(uid);
if (userName.isEmpty()) {
// This should never be reached since input uid is always valid
LOG.error("Failed to get user name from uid {}", uid);
@@ -377,7 +382,7 @@ public int create(String path, @mode_t long mode, FuseFileInfo fi) {
return -ErrorCodes.ENOENT();
} catch (Throwable t) {
LOG.error("Failed to create {}", path, t);
- return HCFSFuseUtil.getErrorCode(t);
+ return AlluxioFuseUtils.getErrorCode(t);
}
return 0;
@@ -475,7 +480,7 @@ public int rename(String oldPath, String newPath) {
return -ErrorCodes.EEXIST();
} catch (Throwable t) {
LOG.error("Failed to rename {} to {}", oldPath, newPath, t);
- return HCFSFuseUtil.getErrorCode(t);
+ return AlluxioFuseUtils.getErrorCode(t);
}
return 0;
@@ -577,7 +582,7 @@ public int chmod(String path, @mode_t long mode) {
mFileSystem.setPermission(turi, new FsPermission((int) mode));
} catch (IOException e) {
LOG.error("Failed to chmod {}", path, e);
- return HCFSFuseUtil.getErrorCode(e);
+ return AlluxioFuseUtils.getErrorCode(e);
}
return 0;
}
@@ -598,7 +603,7 @@ private int rmInternal(String path) {
return -ErrorCodes.ENOENT();
} catch (Throwable t) {
LOG.error("Failed to remove {}", path, t);
- return HCFSFuseUtil.getErrorCode(t);
+ return AlluxioFuseUtils.getErrorCode(t);
}
return 0;
diff --git a/src/main/java/hcfsfuse/fuse/HCFSFuseUtil.java b/src/main/java/hcfsfuse/fuse/HCFSFuseUtil.java
index 774935d..3a0e784 100644
--- a/src/main/java/hcfsfuse/fuse/HCFSFuseUtil.java
+++ b/src/main/java/hcfsfuse/fuse/HCFSFuseUtil.java
@@ -1,13 +1,8 @@
package hcfsfuse.fuse;
-import alluxio.util.OSUtils;
-import alluxio.util.ShellUtils;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import ru.serce.jnrfuse.ErrorCodes;
-import java.io.IOException;
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
@@ -17,182 +12,6 @@
public class HCFSFuseUtil {
public static final Logger LOG =
LoggerFactory.getLogger(HCFSFuseUtil.class);
- private static final long THRESHOLD = 10_000L;
-
- /**
- * Retrieves the uid of the given user.
- *
- * @param userName the user name
- * @return uid
- */
- public static long getUid(String userName) {
- return getIdInfo("-u", userName);
- }
-
- /**
- * Retrieves the primary gid of the given user.
- *
- * @param userName the user name
- * @return gid
- */
- public static long getGid(String userName) {
- return getIdInfo("-g", userName);
- }
-
- /**
- * Retrieves the gid of the given group.
- *
- * @param groupName the group name
- * @return gid
- */
- public static long getGidFromGroupName(String groupName) {
- String result = "";
- try {
- if (OSUtils.isLinux()) {
- String script = "getent group " + groupName + " | cut -d: -f3";
- result = ShellUtils.execCommand("bash", "-c", script).trim();
- } else if (OSUtils.isMacOS()) {
- String script = "dscl . -read /Groups/" + groupName
- + " | awk '($1 == \"PrimaryGroupID:\") { print $2 }'";
- result = ShellUtils.execCommand("bash", "-c", script).trim();
- }
- return Long.parseLong(result);
- } catch (NumberFormatException | IOException e) {
- LOG.error("Failed to get gid from group name {}.", groupName);
- return -1;
- }
- }
-
- /**
- * Runs the "id" command with the given options on the passed username.
- *
- * @param option option to pass to id (either -u or -g)
- * @param username the username on which to run the command
- * @return the uid (-u) or gid (-g) of username
- */
- private static long getIdInfo(String option, String username) {
- String output;
- try {
- output = ShellUtils.execCommand("id", option, username).trim();
- } catch (IOException e) {
- LOG.error("Failed to get id from {} with option {}", username, option);
- return -1;
- }
- return Long.parseLong(output);
- }
-
- /**
- * Gets the user name from the user id.
- *
- * @param uid user id
- * @return user name
- */
- public static String getUserName(long uid) throws IOException {
- return ShellUtils.execCommand("id", "-nu", Long.toString(uid)).trim();
- }
-
- /**
- * Gets the primary group name from the user name.
- *
- * @param userName the user name
- * @return group name
- */
- public static String getGroupName(String userName) throws IOException {
- return ShellUtils.execCommand("id", "-ng", userName).trim();
- }
-
- /**
- * Gets the group name from the group id.
- *
- * @param gid the group id
- * @return group name
- */
- public static String getGroupName(long gid) throws IOException {
- if (OSUtils.isLinux()) {
- String script = "getent group " + gid + " | cut -d: -f1";
- return ShellUtils.execCommand("bash", "-c", script).trim();
- } else if (OSUtils.isMacOS()) {
- String script = "dscl . list /Groups PrimaryGroupID | awk '($2 == \""
- + gid + "\") { print $1 }'";
- return ShellUtils.execCommand("bash", "-c", script).trim();
- }
- return "";
- }
-
- /**
- * Checks whether fuse is installed in local file system. Hcfs-Fuse only support mac and
- * linux.
- *
- * @return true if fuse is installed, false otherwise
- */
- public static boolean isFuseInstalled() {
- try {
- if (OSUtils.isLinux()) {
- String result = ShellUtils.execCommand("fusermount", "-V");
- return !result.isEmpty();
- } else if (OSUtils.isMacOS()) {
- String result = ShellUtils.execCommand("bash", "-c",
- "pkgutil --pkgs | grep -i com.github.osxfuse.pkg.Core");
- return !result.isEmpty();
- }
- } catch (Exception e) {
- return false;
- }
- return false;
- }
-
- /**
- * Gets the corresponding error code of a throwable.
- *
- * @param t throwable
- * @return the corresponding error code
- */
- public static int getErrorCode(Throwable t) {
- // Error codes and their explanations are described in
- // the Errno.java in jnr-constants
- if (t instanceof IOException) {
- return -ErrorCodes.EIO();
- } else {
- return -ErrorCodes.EBADMSG();
- }
- }
-
- /**
- * An interface representing a callable for FUSE APIs.
- */
- public interface FuseCallable {
- /**
- * The RPC implementation.
- *
- * @return the return value from the RPC
- */
- int call();
- }
-
- /**
- * Calls the given {@link FuseCallable} and returns its result.
- *
- * @param logger the logger to use for this call
- * @param callable the callable to call
- * @param methodName the name of the method, used for metrics
- * @param description the format string of the description, used for logging
- * @param args the arguments for the description
- * @return the result
- */
- public static int call(Logger logger, FuseCallable callable, String methodName,
- String description, Object... args) {
- String debugDesc = logger.isDebugEnabled() ? String.format(description, args) : null;
- logger.debug("Enter: {}({})", methodName, debugDesc);
- long startMs = System.currentTimeMillis();
- int ret = callable.call();
- long durationMs = System.currentTimeMillis() - startMs;
- logger.debug("Exit ({}): {}({}) in {} ms", ret, methodName, debugDesc, durationMs);
- if (durationMs >= THRESHOLD) {
- logger.warn("{}({}) returned {} in {} ms (>={} ms)", methodName,
- String.format(description, args), ret, durationMs, THRESHOLD);
- }
- return ret;
- }
/**
* Get current process id.
diff --git a/src/main/java/hcfsfuse/fuse/HCFSJniFuseFileSystem.java b/src/main/java/hcfsfuse/fuse/HCFSJniFuseFileSystem.java
index 7e3cf60..6ab47b5 100644
--- a/src/main/java/hcfsfuse/fuse/HCFSJniFuseFileSystem.java
+++ b/src/main/java/hcfsfuse/fuse/HCFSJniFuseFileSystem.java
@@ -1,10 +1,11 @@
package hcfsfuse.fuse;
-import hcfsfuse.jnifuse.AbstractFuseFileSystem;
-import hcfsfuse.jnifuse.ErrorCodes;
-import hcfsfuse.jnifuse.struct.FileStat;
-import hcfsfuse.jnifuse.struct.FuseContext;
-import hcfsfuse.jnifuse.struct.FuseFileInfo;
+import alluxio.fuse.AlluxioFuseUtils;
+import alluxio.jnifuse.AbstractFuseFileSystem;
+import alluxio.jnifuse.ErrorCodes;
+import alluxio.jnifuse.struct.FileStat;
+import alluxio.jnifuse.struct.FuseContext;
+import alluxio.jnifuse.struct.FuseFileInfo;
import alluxio.jnifuse.FuseFillDir;
import alluxio.resource.LockResource;
@@ -81,8 +82,8 @@ public final class HCFSJniFuseFileSystem extends AbstractFuseFileSystem {
private static final String USER_NAME = System.getProperty("user.name");
private static final String GROUP_NAME = System.getProperty("user.name");
- private static final long DEFAULT_UID = HCFSFuseUtil.getUid(USER_NAME);
- private static final long DEFAULT_GID = HCFSFuseUtil.getGid(GROUP_NAME);
+ private static final long DEFAULT_UID = AlluxioFuseUtils.getUid(USER_NAME);
+ private static final long DEFAULT_GID = AlluxioFuseUtils.getGid(GROUP_NAME);
/**
* Creates a new instance of {@link HCFSJniFuseFileSystem}.
@@ -118,7 +119,7 @@ public Path load(String fusePath) {
.build(new CacheLoader() {
@Override
public Long load(String userName) {
- return HCFSFuseUtil.getUid(userName);
+ return AlluxioFuseUtils.getUid(userName);
}
});
mGidCache = CacheBuilder.newBuilder()
@@ -126,7 +127,7 @@ public Long load(String userName) {
.build(new CacheLoader() {
@Override
public Long load(String groupName) {
- return HCFSFuseUtil.getGidFromGroupName(groupName);
+ return AlluxioFuseUtils.getGidFromGroupName(groupName);
}
});
mIsUserGroupTranslation = true;
@@ -140,7 +141,7 @@ private void setUserGroupIfNeeded(Path uri) throws Exception {
String gname = "";
String uname = "";
if (gid != DEFAULT_GID) {
- String groupName = HCFSFuseUtil.getGroupName(gid);
+ String groupName = AlluxioFuseUtils.getGroupName(gid);
if (groupName.isEmpty()) {
// This should never be reached since input gid is always valid
LOG.error("Failed to get group name from gid {}, fallback to {}.", gid, GROUP_NAME);
@@ -149,7 +150,7 @@ private void setUserGroupIfNeeded(Path uri) throws Exception {
gname = groupName;
}
if (uid != DEFAULT_UID) {
- String userName = HCFSFuseUtil.getUserName(uid);
+ String userName = AlluxioFuseUtils.getUserName(uid);
if (userName.isEmpty()) {
// This should never be reached since input uid is always valid
LOG.error("Failed to get user name from uid {}, fallback to {}", uid, USER_NAME);
@@ -165,7 +166,7 @@ private void setUserGroupIfNeeded(Path uri) throws Exception {
@Override
public int create(String path, long mode, FuseFileInfo fi) {
- return HCFSFuseUtil.call(LOG, () -> createInternal(path, mode, fi),
+ return AlluxioFuseUtils.call(LOG, () -> createInternal(path, mode, fi),
"create", "path=%s,mode=%o", path, mode);
}
@@ -192,7 +193,7 @@ private int createInternal(String path, long mode, FuseFileInfo fi) {
@Override
public int getattr(String path, FileStat stat) {
- return HCFSFuseUtil.call(
+ return AlluxioFuseUtils.call(
LOG, () -> getattrInternal(path, stat), "getattr", "path=%s", path);
}
@@ -252,7 +253,7 @@ private int getattrInternal(String path, FileStat stat) {
@Override
public int readdir(String path, long buff, FuseFillDir filter, long offset,
FuseFileInfo fi) {
- return HCFSFuseUtil.call(LOG, () -> readdirInternal(path, buff, filter, offset, fi),
+ return AlluxioFuseUtils.call(LOG, () -> readdirInternal(path, buff, filter, offset, fi),
"readdir", "path=%s,buf=%s", path, buff);
}
@@ -277,7 +278,7 @@ private int readdirInternal(String path, long buff, FuseFillDir filter, long off
@Override
public int open(String path, FuseFileInfo fi) {
- return HCFSFuseUtil.call(LOG, () -> openInternal(path, fi), "open", "path=%s", path);
+ return AlluxioFuseUtils.call(LOG, () -> openInternal(path, fi), "open", "path=%s", path);
}
private int openInternal(String path, FuseFileInfo fi) {
@@ -296,7 +297,7 @@ private int openInternal(String path, FuseFileInfo fi) {
@Override
public int read(String path, ByteBuffer buf, long size, long offset, FuseFileInfo fi) {
- return HCFSFuseUtil.call(LOG, () -> readInternal(path, buf, size, offset, fi),
+ return AlluxioFuseUtils.call(LOG, () -> readInternal(path, buf, size, offset, fi),
"read", "path=%s,buf=%s,size=%d,offset=%d", path, buf, size, offset);
}
@@ -335,7 +336,7 @@ private int readInternal(String path, ByteBuffer buf, long size, long offset, Fu
@Override
public int write(String path, ByteBuffer buf, long size, long offset, FuseFileInfo fi) {
- return HCFSFuseUtil.call(LOG, () -> writeInternal(path, buf, size, offset, fi),
+ return AlluxioFuseUtils.call(LOG, () -> writeInternal(path, buf, size, offset, fi),
"write", "path=%s,buf=%s,size=%d,offset=%d", path, buf, size, offset);
}
@@ -369,7 +370,7 @@ private int writeInternal(String path, ByteBuffer buf, long size, long offset, F
@Override
public int flush(String path, FuseFileInfo fi) {
- return HCFSFuseUtil.call(LOG, () -> flushInternal(path, fi), "flush", "path=%s", path);
+ return AlluxioFuseUtils.call(LOG, () -> flushInternal(path, fi), "flush", "path=%s", path);
}
private int flushInternal(String path, FuseFileInfo fi) {
@@ -378,7 +379,7 @@ private int flushInternal(String path, FuseFileInfo fi) {
@Override
public int release(String path, FuseFileInfo fi) {
- return HCFSFuseUtil.call(LOG, () -> releaseInternal(path, fi), "release", "path=%s", path);
+ return AlluxioFuseUtils.call(LOG, () -> releaseInternal(path, fi), "release", "path=%s", path);
}
private int releaseInternal(String path, FuseFileInfo fi) {
@@ -405,7 +406,7 @@ private int releaseInternal(String path, FuseFileInfo fi) {
@Override
public int mkdir(String path, long mode) {
- return HCFSFuseUtil.call(LOG, () -> mkdirInternal(path, mode),
+ return AlluxioFuseUtils.call(LOG, () -> mkdirInternal(path, mode),
"mkdir", "path=%s,mode=%o,", path, mode);
}
@@ -428,12 +429,12 @@ private int mkdirInternal(String path, long mode) {
@Override
public int unlink(String path) {
- return HCFSFuseUtil.call(LOG, () -> rmInternal(path), "unlink", "path=%s", path);
+ return AlluxioFuseUtils.call(LOG, () -> rmInternal(path), "unlink", "path=%s", path);
}
@Override
public int rmdir(String path) {
- return HCFSFuseUtil.call(LOG, () -> rmInternal(path), "rmdir", "path=%s", path);
+ return AlluxioFuseUtils.call(LOG, () -> rmInternal(path), "rmdir", "path=%s", path);
}
/**
@@ -457,7 +458,7 @@ private int rmInternal(String path) {
@Override
public int rename(String oldPath, String newPath) {
- return HCFSFuseUtil.call(LOG, () -> renameInternal(oldPath, newPath),
+ return AlluxioFuseUtils.call(LOG, () -> renameInternal(oldPath, newPath),
"rename", "oldPath=%s,newPath=%s,", oldPath, newPath);
}
@@ -482,7 +483,7 @@ private int renameInternal(String oldPath, String newPath) {
@Override
public int chmod(String path, long mode) {
- return HCFSFuseUtil.call(LOG, () -> chmodInternal(path, mode),
+ return AlluxioFuseUtils.call(LOG, () -> chmodInternal(path, mode),
"chmod", "path=%s,mode=%o", path, mode);
}
@@ -493,14 +494,14 @@ private int chmodInternal(String path, long mode) {
mFileSystem.setPermission(uri, new FsPermission((int) mode));
} catch (Throwable t) {
LOG.error("Failed to change {} to mode {}", path, mode, t);
- return HCFSFuseUtil.getErrorCode(t);
+ return AlluxioFuseUtils.getErrorCode(t);
}
return 0;
}
@Override
public int chown(String path, long uid, long gid) {
- return HCFSFuseUtil.call(LOG, () -> chownInternal(path, uid, gid),
+ return AlluxioFuseUtils.call(LOG, () -> chownInternal(path, uid, gid),
"chown", "path=%s,uid=%o,gid=%o", path, uid, gid);
}
@@ -515,7 +516,7 @@ private int chownInternal(String path, long uid, long gid) {
String userName = "";
if (uid != ID_NOT_SET_VALUE && uid != ID_NOT_SET_VALUE_UNSIGNED) {
- userName = HCFSFuseUtil.getUserName(uid);
+ userName = AlluxioFuseUtils.getUserName(uid);
if (userName.isEmpty()) {
// This should never be reached
LOG.error("Failed to get user name from uid {}", uid);
@@ -525,14 +526,14 @@ private int chownInternal(String path, long uid, long gid) {
String groupName = "";
if (gid != ID_NOT_SET_VALUE && gid != ID_NOT_SET_VALUE_UNSIGNED) {
- groupName = HCFSFuseUtil.getGroupName(gid);
+ groupName = AlluxioFuseUtils.getGroupName(gid);
if (groupName.isEmpty()) {
// This should never be reached
LOG.error("Failed to get group name from gid {}", gid);
return -ErrorCodes.EINVAL();
}
} else if (!userName.isEmpty()) {
- groupName = HCFSFuseUtil.getGroupName(userName);
+ groupName = AlluxioFuseUtils.getGroupName(userName);
}
if (userName.isEmpty() && groupName.isEmpty()) {
@@ -548,7 +549,7 @@ private int chownInternal(String path, long uid, long gid) {
}
} catch (Throwable t) {
LOG.error("Failed to chown {} to uid {} and gid {}", path, uid, gid, t);
- return HCFSFuseUtil.getErrorCode(t);
+ return AlluxioFuseUtils.getErrorCode(t);
}
return 0;
}
diff --git a/src/main/java/hcfsfuse/jnifuse/AbstractFuseFileSystem.java b/src/main/java/hcfsfuse/jnifuse/AbstractFuseFileSystem.java
deleted file mode 100644
index ec4835e..0000000
--- a/src/main/java/hcfsfuse/jnifuse/AbstractFuseFileSystem.java
+++ /dev/null
@@ -1,275 +0,0 @@
-package hcfsfuse.jnifuse;
-
-import alluxio.jnifuse.FuseFillDir;
-import alluxio.jnifuse.LibFuse;
-import hcfsfuse.jnifuse.struct.FileStat;
-import hcfsfuse.jnifuse.struct.FuseFileInfo;
-import hcfsfuse.jnifuse.struct.Statvfs;
-import hcfsfuse.jnifuse.utils.SecurityUtils;
-
-import alluxio.util.OSUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.file.Path;
-import java.util.Arrays;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-/**
- * Abstract class for other File System to extend and integrate with Fuse.
- */
-public abstract class AbstractFuseFileSystem implements FuseFileSystem {
-
- static {
- System.loadLibrary("jnifuse");
- }
-
- private static final Logger
- LOG = LoggerFactory.getLogger(AbstractFuseFileSystem.class);
- // timeout to mount a JNI fuse file system in ms
- private static final int MOUNT_TIMEOUT_MS = 2000;
-
- private final LibFuse libFuse;
- private final AtomicBoolean mounted = new AtomicBoolean();
- private final Path mountPoint;
-
- public AbstractFuseFileSystem(Path mountPoint) {
- this.libFuse = new LibFuse();
- this.mountPoint = mountPoint;
- }
-
- /**
- * Executes mount command.
- *
- * @param blocking whether this command is blocking
- * @param debug whether to show debug information
- * @param fuseOpts
- */
- public void mount(boolean blocking, boolean debug, String[] fuseOpts) {
- if (!mounted.compareAndSet(false, true)) {
- throw new FuseException("Fuse File System already mounted!");
- }
- String[] arg;
- String mountPointStr = mountPoint.toAbsolutePath().toString();
- if (mountPointStr.endsWith("\\")) {
- mountPointStr = mountPointStr.substring(0, mountPointStr.length() - 1);
- }
- if (!debug) {
- arg = new String[] {getFileSystemName(), "-f", mountPointStr};
- } else {
- arg = new String[] {getFileSystemName(), "-f", "-d", mountPointStr};
- }
- if (fuseOpts.length != 0) {
- int argLen = arg.length;
- arg = Arrays.copyOf(arg, argLen + fuseOpts.length);
- System.arraycopy(fuseOpts, 0, arg, argLen, fuseOpts.length);
- }
-
- final String[] args = arg;
- try {
- if (SecurityUtils.canHandleShutdownHooks()) {
- Runtime.getRuntime().addShutdownHook(new Thread(this::umount));
- }
- int res;
- if (blocking) {
- res = execMount(args);
- } else {
- try {
- res = CompletableFuture.supplyAsync(() -> execMount(args)).get(MOUNT_TIMEOUT_MS,
- TimeUnit.MILLISECONDS);
- } catch (TimeoutException e) {
- // ok
- res = 0;
- }
- }
- if (res != 0) {
- throw new FuseException("Unable to mount FS, return code = " + res);
- }
- } catch (Exception e) {
- mounted.set(false);
- throw new FuseException("Unable to mount FS", e);
- }
- }
-
- private int execMount(String[] arg) {
- return libFuse.fuse_main_real(this, arg.length, arg);
- }
-
- public void umount() {
- if (!mounted.get()) {
- return;
- }
- if (OSUtils.isWindows()) {
- // Pointer fusePointer = this.fusePointer;
- // if (fusePointer != null) {
- // libFuse.fuse_exit(fusePointer);
- // }
- } else {
- String mountPath = mountPoint.toAbsolutePath().toString();
- try {
- new ProcessBuilder("fusermount", "-u", "-z", mountPath).start();
- } catch (IOException e) {
- try {
- new ProcessBuilder("umount", mountPath).start().waitFor();
- } catch (InterruptedException ie) {
- Thread.currentThread().interrupt();
- throw new FuseException("Unable to umount FS", e);
- } catch (IOException ioe) {
- ioe.addSuppressed(e);
- throw new FuseException("Unable to umount FS", ioe);
- }
- }
- }
- mounted.set(false);
- }
-
- public int openCallback(String path, ByteBuffer buf) {
- try {
- return open(path, FuseFileInfo.wrap(buf));
- } catch (Exception e) {
- LOG.error("Failed to open {}: ", path, e);
- return -ErrorCodes.EIO();
- }
- }
-
- public int readCallback(String path, ByteBuffer buf, long size, long offset, ByteBuffer fibuf) {
- try {
- return read(path, buf, size, offset, FuseFileInfo.wrap(fibuf));
- } catch (Exception e) {
- LOG.error("Failed to read {}, size {}, offset {}: ", path, size, offset, e);
- return -ErrorCodes.EIO();
- }
- }
-
- public int getattrCallback(String path, ByteBuffer buf) {
- try {
- return getattr(path, FileStat.wrap(buf));
- } catch (Exception e) {
- LOG.error("Failed to getattr {}: ", path, e);
- return -ErrorCodes.EIO();
- }
- }
-
- public int readdirCallback(String path, long bufaddr, FuseFillDir filter, long offset,
- ByteBuffer fi) {
- try {
- return readdir(path, bufaddr, filter, offset, new FuseFileInfo(fi));
- } catch (Exception e) {
- LOG.error("Failed to readdir {}, offset {}: ", path, offset, e);
- return -ErrorCodes.EIO();
- }
- }
-
- public int unlinkCallback(String path) {
- try {
- return unlink(path);
- } catch (Exception e) {
- LOG.error("Failed to unlink {}: ", path, e);
- return -ErrorCodes.EIO();
- }
- }
-
- public int flushCallback(String path, ByteBuffer fi) {
- try {
- return flush(path, FuseFileInfo.wrap(fi));
- } catch (Exception e) {
- LOG.error("Failed to flush {}: ", path, e);
- return -ErrorCodes.EIO();
- }
- }
-
- public int releaseCallback(String path, ByteBuffer fi) {
- try {
- return release(path, FuseFileInfo.wrap(fi));
- } catch (Exception e) {
- LOG.error("Failed to release {}: ", path, e);
- return -ErrorCodes.EIO();
- }
- }
-
- public int chmodCallback(String path, long mode) {
- try {
- return chmod(path, mode);
- } catch (Exception e) {
- LOG.error("Failed to chmod {}, mode {}: ", path, mode, e);
- return -ErrorCodes.EIO();
- }
- }
-
- public int chownCallback(String path, long uid, long gid) {
- try {
- return chown(path, uid, gid);
- } catch (Exception e) {
- LOG.error("Failed to chown {}, uid {}, gid {}: ", path, uid, gid, e);
- return -ErrorCodes.EIO();
- }
- }
-
- public int createCallback(String path, long mode, ByteBuffer fi) {
- try {
- return create(path, mode, FuseFileInfo.wrap(fi));
- } catch (Exception e) {
- LOG.error("Failed to create {}, mode {}: ", path, mode, e);
- return -ErrorCodes.EIO();
- }
- }
-
- public int mkdirCallback(String path, long mode) {
- try {
- return mkdir(path, mode);
- } catch (Exception e) {
- LOG.error("Failed to mkdir {}, mode {}: ", path, mode, e);
- return -ErrorCodes.EIO();
- }
- }
-
- public int renameCallback(String oldPath, String newPath) {
- try {
- return rename(oldPath, newPath);
- } catch (Exception e) {
- LOG.error("Failed to rename {}, newPath {}: ", oldPath, newPath, e);
- return -ErrorCodes.EIO();
- }
- }
-
- public int rmdirCallback(String path) {
- try {
- return rmdir(path);
- } catch (Exception e) {
- LOG.error("Failed to rmdir {}: ", path, e);
- return -ErrorCodes.EIO();
- }
- }
-
- public int statfsCallback(String path, ByteBuffer stbuf) {
- try {
- return statfs(path, Statvfs.wrap(stbuf));
- } catch (Exception e) {
- LOG.error("Failed to statfs {}: ", path, e);
- return -ErrorCodes.EIO();
- }
- }
-
- public int truncateCallback(String path, long size) {
- try {
- return truncate(path, size);
- } catch (Exception e) {
- LOG.error("Failed to truncate {}, size {}: ", path, size, e);
- return -ErrorCodes.EIO();
- }
- }
-
- public int writeCallback(String path, ByteBuffer buf, long size, long offset, ByteBuffer fi) {
- try {
- return write(path, buf, size, offset, FuseFileInfo.wrap(fi));
- } catch (Exception e) {
- LOG.error("Failed to write {}, size {}, offset {}: ", path, size, offset, e);
- return -ErrorCodes.EIO();
- }
- }
-}
diff --git a/src/main/java/hcfsfuse/jnifuse/ErrorCodes.java b/src/main/java/hcfsfuse/jnifuse/ErrorCodes.java
deleted file mode 100644
index 0f66cd0..0000000
--- a/src/main/java/hcfsfuse/jnifuse/ErrorCodes.java
+++ /dev/null
@@ -1,939 +0,0 @@
-package hcfsfuse.jnifuse;
-
-import hcfsfuse.jnifuse.constants.Errno;
-
-public class ErrorCodes {
- /**
- * Argument list too long
- */
- public static int E2BIG() {
- return Errno.E2BIG.intValue();
- }
-
- /**
- * Permission denied
- */
- public static int EACCES() {
- return Errno.EACCES.intValue();
- }
-
- /**
- * Address already in use
- */
- public static int EADDRINUSE() {
- return Errno.EADDRINUSE.intValue();
- }
-
- /**
- * Cannot assign requested address
- */
- public static int EADDRNOTAVAIL() {
- return Errno.EADDRNOTAVAIL.intValue();
- }
-
- /**
- * Advertise error
- */
- public static int EADV() {
- return 68;
- }
-
- /**
- * Address family not supported by protocol
- */
- public static int EAFNOSUPPORT() {
- return Errno.EAFNOSUPPORT.intValue();
- }
-
- /**
- * Try again
- */
- public static int EAGAIN() {
- return Errno.EAGAIN.intValue();
- }
-
- /**
- * Operation already in progress
- */
- public static int EALREADY() {
- return Errno.EALREADY.intValue();
- }
-
- /**
- * Invalid exchange
- */
- public static int EBADE() {
- return 52;
- }
-
- /**
- * Bad file number
- */
- public static int EBADF() {
- return Errno.EBADF.intValue();
- }
-
- /**
- * File descriptor in bad state
- */
- public static int EBADFD() {
- return 77;
- }
-
- /**
- * Not a data message
- */
- public static int EBADMSG() {
- return Errno.EBADMSG.intValue();
- }
-
- /**
- * Invalid request descriptor
- */
- public static int EBADR() {
- return 53;
- }
-
- /**
- * Invalid request code
- */
- public static int EBADRQC() {
- return 56;
- }
-
- /**
- * Invalid slot
- */
- public static int EBADSLT() {
- return 57;
- }
-
- /**
- * Bad font file format
- */
- public static int EBFONT() {
- return 59;
- }
-
- /**
- * Device or resource busy
- */
- public static int EBUSY() {
- return Errno.EBUSY.intValue();
- }
-
- /**
- * Operation Canceled
- */
- public static int ECANCELED() {
- return 125;
- }
-
- /**
- * No child processes
- */
- public static int ECHILD() {
- return Errno.ECHILD.intValue();
- }
-
- /**
- * Channel number out of range
- */
- public static int ECHRNG() {
- return 44;
- }
-
- /**
- * Communication error on send
- */
- public static int ECOMM() {
- return 70;
- }
-
- /**
- * Software caused connection abort
- */
- public static int ECONNABORTED() {
- return Errno.ECONNABORTED.intValue();
- }
-
- /**
- * Connection refused
- */
- public static int ECONNREFUSED() {
- return Errno.ECONNREFUSED.intValue();
- }
-
- /**
- * Connection reset by peer
- */
- public static int ECONNRESET() {
- return Errno.ECONNRESET.intValue();
- }
-
- /**
- * Resource deadlock would occur
- */
- public static int EDEADLK() {
- return Errno.EDEADLK.intValue();
- }
-
- public static int EDEADLOCK() {
- return EDEADLK();
- }
-
- /**
- * Destination address required
- */
- public static int EDESTADDRREQ() {
- return Errno.EDESTADDRREQ.intValue();
- }
-
- /**
- * Math argument out of domain of func
- */
- public static int EDOM() {
- return Errno.EDOM.intValue();
- }
-
- /**
- * RFS specific error
- */
- public static int EDOTDOT() {
- return 73;
- }
-
- /**
- * Quota exceeded
- */
- public static int EDQUOT() {
- return Errno.EDQUOT.intValue();
- }
-
- /**
- * File exists
- */
- public static int EEXIST() {
- return Errno.EEXIST.intValue();
- }
-
- /**
- * Bad address
- */
- public static int EFAULT() {
- return Errno.EFAULT.intValue();
- }
-
- /**
- * File too large
- */
- public static int EFBIG() {
- return Errno.EFBIG.intValue();
- }
-
- /**
- * Host is down
- */
- public static int EHOSTDOWN() {
- return Errno.EHOSTDOWN.intValue();
- }
-
- /**
- * No route to host
- */
- public static int EHOSTUNREACH() {
- return Errno.EHOSTUNREACH.intValue();
- }
-
- /**
- * Identifier removed
- */
- public static int EIDRM() {
- return Errno.EIDRM.intValue();
- }
-
- /**
- * Illegal byte sequence
- */
- public static int EILSEQ() {
- return Errno.EILSEQ.intValue();
- }
-
- /**
- * Operation now in progress
- */
- public static int EINPROGRESS() {
- return Errno.EINPROGRESS.intValue();
- }
-
- /**
- * Interrupted system call
- */
- public static int EINTR() {
- return Errno.EINTR.intValue();
- }
-
- /**
- * Invalid argument
- */
- public static int EINVAL() {
- return Errno.EINVAL.intValue();
- }
-
- /**
- * I/O error
- */
- public static int EIO() {
- return Errno.EIO.intValue();
- }
-
- /**
- * Transport endpoint is already connected
- */
- public static int EISCONN() {
- return Errno.EISCONN.intValue();
- }
-
- /**
- * Is a directory
- */
- public static int EISDIR() {
- return Errno.EISDIR.intValue();
- }
-
- /**
- * Is a named type file
- */
- public static int EISNAM() {
- return 120;
- }
-
- /**
- * Key has expired
- */
- public static int EKEYEXPIRED() {
- return 127;
- }
-
- /**
- * Key was rejected by service
- */
- public static int EKEYREJECTED() {
- return 129;
- }
-
- /**
- * Key has been revoked
- */
- public static int EKEYREVOKED() {
- return 128;
- }
-
- /**
- * Level 2 halted
- */
- public static int EL2HLT() {
- return 51;
- }
-
- /**
- * Level 2 not synchronized
- */
- public static int EL2NSYNC() {
- return 45;
- }
-
- /**
- * Level 3 halted
- */
- public static int EL3HLT() {
- return 46;
- }
-
- /**
- * Level 3 reset
- */
- public static int EL3RST() {
- return 47;
- }
-
- /**
- * Can not access a needed shared library
- */
- public static int ELIBACC() {
- return 79;
- }
-
- /**
- * Accessing a corrupted shared library
- */
- public static int ELIBBAD() {
- return 80;
- }
-
- /**
- * Cannot exec a shared library directly
- */
- public static int ELIBEXEC() {
- return 83;
- }
-
- /**
- * Attempting to link in too many shared libraries
- */
- public static int ELIBMAX() {
- return 82;
- }
-
- /**
- * .lib section in a.out corrupted
- */
- public static int ELIBSCN() {
- return 81;
- }
-
- /**
- * Link number out of range
- */
- public static int ELNRNG() {
- return 48;
- }
-
- /**
- * Too many symbolic links encountered
- */
- public static int ELOOP() {
- return Errno.ELOOP.intValue();
- }
-
- /**
- * Wrong medium type
- */
- public static int EMEDIUMTYPE() {
- return 124;
- }
-
- /**
- * Too many open files
- */
- public static int EMFILE() {
- return Errno.EMFILE.intValue();
- }
-
- /**
- * Too many links
- */
- public static int EMLINK() {
- return Errno.EMLINK.intValue();
- }
-
- /**
- * Message too long
- */
- public static int EMSGSIZE() {
- return Errno.EMSGSIZE.intValue();
- }
-
- /**
- * Multihop attempted
- */
- public static int EMULTIHOP() {
- return Errno.EMULTIHOP.intValue();
- }
-
- /**
- * File name too long
- */
- public static int ENAMETOOLONG() {
- return Errno.ENAMETOOLONG.intValue();
- }
-
- /**
- * No XENIX semaphores available
- */
- public static int ENAVAIL() {
- return 119;
- }
-
- /**
- * Network is down
- */
- public static int ENETDOWN() {
- return Errno.ENETDOWN.intValue();
- }
-
- /**
- * Network dropped connection because of reset
- */
- public static int ENETRESET() {
- return Errno.ENETRESET.intValue();
- }
-
- /**
- * Network is unreachable
- */
- public static int ENETUNREACH() {
- return Errno.ENETUNREACH.intValue();
- }
-
- /**
- * File table overflow
- */
- public static int ENFILE() {
- return Errno.ENFILE.intValue();
- }
-
- /**
- * No anode
- */
- public static int ENOANO() {
- return 55;
- }
-
- /**
- * No buffer space available
- */
- public static int ENOBUFS() {
- return Errno.ENOBUFS.intValue();
- }
-
- /**
- * No CSI structure available
- */
- public static int ENOCSI() {
- return 50;
- }
-
- /**
- * No data available
- */
- public static int ENODATA() {
- return Errno.ENODATA.intValue();
- }
-
- /**
- * No such device
- */
- public static int ENODEV() {
- return Errno.ENODEV.intValue();
- }
-
- /**
- * No such file or directory
- */
- public static int ENOENT() {
- return Errno.ENOENT.intValue();
- }
-
- /**
- * Exec format error
- */
- public static int ENOEXEC() {
- return Errno.ENOEXEC.intValue();
- }
-
- /**
- * Required key not available
- */
- public static int ENOKEY() {
- return 126;
- }
-
- /**
- * No record locks available
- */
- public static int ENOLCK() {
- return Errno.ENOLCK.intValue();
- }
-
- /**
- * Link has been severed
- */
- public static int ENOLINK() {
- return Errno.ENOLINK.intValue();
- }
-
- /**
- * No medium found
- */
- public static int ENOMEDIUM() {
- return 123;
- }
-
- /**
- * Out of memory
- */
- public static int ENOMEM() {
- return Errno.ENOMEM.intValue();
- }
-
- /**
- * No message of desired type
- */
- public static int ENOMSG() {
- return Errno.ENOMSG.intValue();
- }
-
- /**
- * Machine is not on the network
- */
- public static int ENONET() {
- return 64;
- }
-
- /**
- * Package not installed
- */
- public static int ENOPKG() {
- return 65;
- }
-
- /**
- * Protocol not available
- */
- public static int ENOPROTOOPT() {
- return Errno.ENOPROTOOPT.intValue();
- }
-
- /**
- * No space left on device
- */
- public static int ENOSPC() {
- return Errno.ENOSPC.intValue();
- }
-
- /**
- * Out of streams resources
- */
- public static int ENOSR() {
- return Errno.ENOSR.intValue();
- }
-
- /**
- * Device not a stream
- */
- public static int ENOSTR() {
- return Errno.ENOSTR.intValue();
- }
-
- /**
- * Function not implemented
- */
- public static int ENOSYS() {
- return Errno.ENOSYS.intValue();
- }
-
- /**
- * Block device required
- */
- public static int ENOTBLK() {
- return Errno.ENOTBLK.intValue();
- }
-
- /**
- * Transport endpoint is not connected
- */
- public static int ENOTCONN() {
- return Errno.ENOTCONN.intValue();
- }
-
- /**
- * Not a directory
- */
- public static int ENOTDIR() {
- return Errno.ENOTDIR.intValue();
- }
-
- /**
- * Directory not empty
- */
- public static int ENOTEMPTY() {
- return Errno.ENOTEMPTY.intValue();
- }
-
- /**
- * Not a XENIX named type file
- */
- public static int ENOTNAM() {
- return 118;
- }
-
- /**
- * State not recoverable
- */
- public static int ENOTRECOVERABLE() {
- return 131;
- }
-
- /**
- * Socket operation on non-socket
- */
- public static int ENOTSOCK() {
- return Errno.ENOTSOCK.intValue();
- }
-
- /**
- * Not a typewriter
- */
- public static int ENOTTY() {
- return Errno.ENOTTY.intValue();
- }
-
- /**
- * Name not unique on network
- */
- public static int ENOTUNIQ() {
- return 76;
- }
-
- /**
- * No such device or address
- */
- public static int ENXIO() {
- return Errno.ENXIO.intValue();
- }
-
- /**
- * Operation not supported on transport endpoint
- */
- public static int EOPNOTSUPP() {
- return Errno.EOPNOTSUPP.intValue();
- }
-
- /**
- * Value too large for defined data type
- */
- public static int EOVERFLOW() {
- return Errno.EOVERFLOW.intValue();
- }
-
- /**
- * Owner died
- */
- public static int EOWNERDEAD() {
- return 130;
- }
-
- /**
- * Operation not permitted
- */
- /**
- * Operation not permitted
- */
- public static int EPERM() {
- return Errno.EPERM.intValue();
- }
-
- /**
- * Protocol family not supported
- */
- public static int EPFNOSUPPORT() {
- return Errno.EPFNOSUPPORT.intValue();
- }
-
- /**
- * Broken pipe
- */
- public static int EPIPE() {
- return Errno.EPIPE.intValue();
- }
-
- /**
- * Protocol error
- */
- public static int EPROTO() {
- return Errno.EPROTO.intValue();
- }
-
- /**
- * Protocol not supported
- */
- public static int EPROTONOSUPPORT() {
- return Errno.EPROTONOSUPPORT.intValue();
- }
-
- /**
- * Protocol wrong type for socket
- */
- public static int EPROTOTYPE() {
- return Errno.EPROTOTYPE.intValue();
- }
-
- /**
- * Math result not representable
- */
- public static int ERANGE() {
- return Errno.ERANGE.intValue();
- }
-
- /**
- * Remote address changed
- */
- public static int EREMCHG() {
- return 78;
- }
-
- /**
- * Object is remote
- */
- public static int EREMOTE() {
- return Errno.EREMOTE.intValue();
- }
-
- /**
- * Remote I/O error
- */
- public static int EREMOTEIO() {
- return 121;
- }
-
- /**
- * Interrupted system call should be restarted
- */
- public static int ERESTART() {
- return 85;
- }
-
- /**
- * Read-only file system
- */
- public static int EROFS() {
- return Errno.EROFS.intValue();
- }
-
- /**
- * Cannot send after transport endpoint shutdown
- */
- public static int ESHUTDOWN() {
- return Errno.ESHUTDOWN.intValue();
- }
-
- /**
- * Socket type not supported
- */
- public static int ESOCKTNOSUPPORT() {
- return Errno.ESOCKTNOSUPPORT.intValue();
- }
-
- /**
- * Illegal seek
- */
- public static int ESPIPE() {
- return Errno.ESPIPE.intValue();
- }
-
- /**
- * No such process
- */
- public static int ESRCH() {
- return Errno.ESRCH.intValue();
- }
-
- /**
- * Srmount error
- */
- public static int ESRMNT() {
- return 69;
- }
-
- /**
- * Stale file handle
- */
- public static int ESTALE() {
- return Errno.ESTALE.intValue();
- }
-
- /**
- * Streams pipe error
- */
- public static int ESTRPIPE() {
- return 86;
- }
-
- /**
- * Timer expired
- */
- public static int ETIME() {
- return Errno.ETIME.intValue();
- }
-
- /**
- * Connection timed out
- */
- public static int ETIMEDOUT() {
- return Errno.ETIMEDOUT.intValue();
- }
-
- /**
- * Too many references: cannot splice
- */
- public static int ETOOMANYREFS() {
- return Errno.ETOOMANYREFS.intValue();
- }
-
- /**
- * Text file busy
- */
- public static int ETXTBSY() {
- return Errno.ETXTBSY.intValue();
- }
-
- /**
- * Structure needs cleaning
- */
- public static int EUCLEAN() {
- return 117;
- }
-
- /**
- * Protocol driver not attached
- */
- public static int EUNATCH() {
- return 49;
- }
-
- /**
- * Too many users
- */
- public static int EUSERS() {
- return Errno.EUSERS.intValue();
- }
-
- /**
- * Operation would block
- */
- public static int EWOULDBLOCK() {
- return Errno.EWOULDBLOCK.intValue();
- }
-
- /**
- * Cross-device link
- */
- public static int EXDEV() {
- return Errno.EXDEV.intValue();
- }
-
- /**
- * Exchange full
- */
- public static int EXFULL() {
- return 54;
- }
-
- /**
- * The extended attribute does not exist
- */
- public static int ENOATTR() {
- return 93;
- }
-
- /**
- * The file system does not support extended attributes or has the feature disabled
- */
- public static int ENOTSUP() {
- return 45;
- }
-
- private ErrorCodes() {
- }
-}
diff --git a/src/main/java/hcfsfuse/jnifuse/FuseException.java b/src/main/java/hcfsfuse/jnifuse/FuseException.java
deleted file mode 100644
index 4a4ac73..0000000
--- a/src/main/java/hcfsfuse/jnifuse/FuseException.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package hcfsfuse.jnifuse;
-
-/**
- * Exception indicating Fuse errors.
- */
-public class FuseException extends RuntimeException {
-
- /**
- * @param message error message
- */
- public FuseException(String message) {
- super(message);
- }
-
- /**
- * @param message error message
- * @param cause exception cause
- */
- public FuseException(String message, Throwable cause) {
- super(message, cause);
- }
-}
-
diff --git a/src/main/java/hcfsfuse/jnifuse/FuseFileSystem.java b/src/main/java/hcfsfuse/jnifuse/FuseFileSystem.java
deleted file mode 100644
index 887fe13..0000000
--- a/src/main/java/hcfsfuse/jnifuse/FuseFileSystem.java
+++ /dev/null
@@ -1,101 +0,0 @@
-package hcfsfuse.jnifuse;
-
-import alluxio.jnifuse.FuseFillDir;
-import hcfsfuse.jnifuse.struct.FileStat;
-import hcfsfuse.jnifuse.struct.FuseContext;
-import hcfsfuse.jnifuse.struct.FuseFileInfo;
-import hcfsfuse.jnifuse.struct.Statvfs;
-
-import java.nio.ByteBuffer;
-import java.util.concurrent.ThreadLocalRandom;
-
-public interface FuseFileSystem {
-
- default int getattr(String path, FileStat stat) {
- throw new UnsupportedOperationException("getattr");
- }
-
- default int mkdir(String path, long mode) {
- throw new UnsupportedOperationException("mkdir");
- }
-
- default int unlink(String path) {
- throw new UnsupportedOperationException("unlink");
- }
-
- default int rmdir(String path) {
- throw new UnsupportedOperationException("rmdir");
- }
-
- default int symlink(String oldpath, String newpath) {
- throw new UnsupportedOperationException("symlink");
- }
-
- default int rename(String oldpath, String newpath) {
- throw new UnsupportedOperationException("rename");
- }
-
- default int link(String oldpath, String newpath) {
- throw new UnsupportedOperationException("link");
- }
-
- default int chmod(String path, long mode) {
- throw new UnsupportedOperationException("chmod");
- }
-
- default int chown(String path, long uid, long gid) {
- throw new UnsupportedOperationException("chown");
- }
-
- default int truncate(String path, long size) {
- throw new UnsupportedOperationException("truncate");
- }
-
- default int open(String path, FuseFileInfo fi) {
- throw new UnsupportedOperationException("open");
- }
-
- default int read(String path, ByteBuffer buf, long size, long offset, FuseFileInfo fi) {
- throw new UnsupportedOperationException("read");
- }
-
- default int write(String path, ByteBuffer buf, long size, long offset, FuseFileInfo fi) {
- throw new UnsupportedOperationException("write");
- }
-
- default int statfs(String path, Statvfs stbuf) {
- throw new UnsupportedOperationException("statfs");
- }
-
- default int flush(String path, FuseFileInfo fi) {
- throw new UnsupportedOperationException("flush");
- }
-
- default int release(String path, FuseFileInfo fi) {
- throw new UnsupportedOperationException("release");
- }
-
- default int opendir(String path, FuseFileInfo fi) {
- throw new UnsupportedOperationException("opendir");
- }
-
- default int readdir(String path, long bufaddr, FuseFillDir filter, long offset, FuseFileInfo fi) {
- throw new UnsupportedOperationException("readdir");
- }
-
- default int releasedir(String path, FuseFileInfo fi) {
- throw new UnsupportedOperationException("releasedir");
- }
-
- default int create(String path, long mode, FuseFileInfo fi) {
- throw new UnsupportedOperationException("create");
- }
-
- default FuseContext getContext() {
- return new FuseContext(ByteBuffer.allocate(32));
- }
-
- default String getFileSystemName() {
- return "fusefs" + ThreadLocalRandom.current().nextInt();
- }
-}
diff --git a/src/main/java/hcfsfuse/jnifuse/constants/Errno.java b/src/main/java/hcfsfuse/jnifuse/constants/Errno.java
deleted file mode 100644
index 8937821..0000000
--- a/src/main/java/hcfsfuse/jnifuse/constants/Errno.java
+++ /dev/null
@@ -1,192 +0,0 @@
-package hcfsfuse.jnifuse.constants;
-
-public enum Errno {
- EPERM(1),
- ENOENT(2),
- ESRCH(3),
- EINTR(4),
- EIO(5),
- ENXIO(6),
- E2BIG(7),
- ENOEXEC(8),
- EBADF(9),
- ECHILD(10),
- EDEADLK(35),
- ENOMEM(12),
- EACCES(13),
- EFAULT(14),
- ENOTBLK(15),
- EBUSY(16),
- EEXIST(17),
- EXDEV(18),
- ENODEV(19),
- ENOTDIR(20),
- EISDIR(21),
- EINVAL(22),
- ENFILE(23),
- EMFILE(24),
- ENOTTY(25),
- ETXTBSY(26),
- EFBIG(27),
- ENOSPC(28),
- ESPIPE(29),
- EROFS(30),
- EMLINK(31),
- EPIPE(32),
- EDOM(33),
- ERANGE(34),
- EWOULDBLOCK(11),
- EAGAIN(11),
- EINPROGRESS(115),
- EALREADY(114),
- ENOTSOCK(88),
- EDESTADDRREQ(89),
- EMSGSIZE(90),
- EPROTOTYPE(91),
- ENOPROTOOPT(92),
- EPROTONOSUPPORT(93),
- ESOCKTNOSUPPORT(94),
- EOPNOTSUPP(95),
- EPFNOSUPPORT(96),
- EAFNOSUPPORT(97),
- EADDRINUSE(98),
- EADDRNOTAVAIL(99),
- ENETDOWN(100),
- ENETUNREACH(101),
- ENETRESET(102),
- ECONNABORTED(103),
- ECONNRESET(104),
- ENOBUFS(105),
- EISCONN(106),
- ENOTCONN(107),
- ESHUTDOWN(108),
- ETOOMANYREFS(109),
- ETIMEDOUT(110),
- ECONNREFUSED(111),
- ELOOP(40),
- ENAMETOOLONG(36),
- EHOSTDOWN(112),
- EHOSTUNREACH(113),
- ENOTEMPTY(39),
- EUSERS(87),
- EDQUOT(122),
- ESTALE(116),
- EREMOTE(66),
- ENOLCK(37),
- ENOSYS(38),
- EOVERFLOW(75),
- EIDRM(43),
- ENOMSG(42),
- EILSEQ(84),
- EBADMSG(74),
- EMULTIHOP(72),
- ENODATA(61),
- ENOLINK(67),
- ENOSR(63),
- ENOSTR(60),
- EPROTO(71),
- ETIME(62);
- private final int value;
- private Errno(int value) { this.value = value; }
- public static final long MIN_VALUE = 1;
- public static final long MAX_VALUE = 122;
-
- static final class StringTable {
- public static final java.util.Map descriptions = generateTable();
- public static java.util.Map generateTable() {
- java.util.Map map = new java.util.EnumMap(Errno.class);
- map.put(EPERM, "Operation not permitted");
- map.put(ENOENT, "No such file or directory");
- map.put(ESRCH, "No such process");
- map.put(EINTR, "Interrupted system call");
- map.put(EIO, "Input/output error");
- map.put(ENXIO, "No such device or address");
- map.put(E2BIG, "Argument list too long");
- map.put(ENOEXEC, "Exec format error");
- map.put(EBADF, "Bad file descriptor");
- map.put(ECHILD, "No child processes");
- map.put(EDEADLK, "Resource deadlock avoided");
- map.put(ENOMEM, "Cannot allocate memory");
- map.put(EACCES, "Permission denied");
- map.put(EFAULT, "Bad address");
- map.put(ENOTBLK, "Block device required");
- map.put(EBUSY, "Device or resource busy");
- map.put(EEXIST, "File exists");
- map.put(EXDEV, "Invalid cross-device link");
- map.put(ENODEV, "No such device");
- map.put(ENOTDIR, "Not a directory");
- map.put(EISDIR, "Is a directory");
- map.put(EINVAL, "Invalid argument");
- map.put(ENFILE, "Too many open files in system");
- map.put(EMFILE, "Too many open files");
- map.put(ENOTTY, "Inappropriate ioctl for device");
- map.put(ETXTBSY, "Text file busy");
- map.put(EFBIG, "File too large");
- map.put(ENOSPC, "No space left on device");
- map.put(ESPIPE, "Illegal seek");
- map.put(EROFS, "Read-only file system");
- map.put(EMLINK, "Too many links");
- map.put(EPIPE, "Broken pipe");
- map.put(EDOM, "Numerical argument out of domain");
- map.put(ERANGE, "Numerical result out of range");
- map.put(EWOULDBLOCK, "Resource temporarily unavailable");
- map.put(EAGAIN, "Resource temporarily unavailable");
- map.put(EINPROGRESS, "Operation now in progress");
- map.put(EALREADY, "Operation already in progress");
- map.put(ENOTSOCK, "Socket operation on non-socket");
- map.put(EDESTADDRREQ, "Destination address required");
- map.put(EMSGSIZE, "Message too long");
- map.put(EPROTOTYPE, "Protocol wrong type for socket");
- map.put(ENOPROTOOPT, "Protocol not available");
- map.put(EPROTONOSUPPORT, "Protocol not supported");
- map.put(ESOCKTNOSUPPORT, "Socket type not supported");
- map.put(EOPNOTSUPP, "Operation not supported");
- map.put(EPFNOSUPPORT, "Protocol family not supported");
- map.put(EAFNOSUPPORT, "Address family not supported by protocol");
- map.put(EADDRINUSE, "Address already in use");
- map.put(EADDRNOTAVAIL, "Cannot assign requested address");
- map.put(ENETDOWN, "Network is down");
- map.put(ENETUNREACH, "Network is unreachable");
- map.put(ENETRESET, "Network dropped connection on reset");
- map.put(ECONNABORTED, "Software caused connection abort");
- map.put(ECONNRESET, "Connection reset by peer");
- map.put(ENOBUFS, "No buffer space available");
- map.put(EISCONN, "Transport endpoint is already connected");
- map.put(ENOTCONN, "Transport endpoint is not connected");
- map.put(ESHUTDOWN, "Cannot send after transport endpoint shutdown");
- map.put(ETOOMANYREFS, "Too many references: cannot splice");
- map.put(ETIMEDOUT, "Connection timed out");
- map.put(ECONNREFUSED, "Connection refused");
- map.put(ELOOP, "Too many levels of symbolic links");
- map.put(ENAMETOOLONG, "File name too long");
- map.put(EHOSTDOWN, "Host is down");
- map.put(EHOSTUNREACH, "No route to host");
- map.put(ENOTEMPTY, "Directory not empty");
- map.put(EUSERS, "Too many users");
- map.put(EDQUOT, "Disk quota exceeded");
- map.put(ESTALE, "Stale NFS file handle");
- map.put(EREMOTE, "Object is remote");
- map.put(ENOLCK, "No locks available");
- map.put(ENOSYS, "Function not implemented");
- map.put(EOVERFLOW, "Value too large for defined data type");
- map.put(EIDRM, "Identifier removed");
- map.put(ENOMSG, "No message of desired type");
- map.put(EILSEQ, "Invalid or incomplete multibyte or wide character");
- map.put(EBADMSG, "Bad message");
- map.put(EMULTIHOP, "Multihop attempted");
- map.put(ENODATA, "No data available");
- map.put(ENOLINK, "Link has been severed");
- map.put(ENOSR, "Out of streams resources");
- map.put(ENOSTR, "Device not a stream");
- map.put(EPROTO, "Protocol error");
- map.put(ETIME, "Timer expired");
- return map;
- }
- }
- public final String toString() { return StringTable.descriptions.get(this); }
- public final int value() { return value; }
- public final int intValue() { return value; }
- public final long longValue() { return value; }
- public final boolean defined() { return true; }
-}
-
diff --git a/src/main/java/hcfsfuse/jnifuse/struct/FileStat.java b/src/main/java/hcfsfuse/jnifuse/struct/FileStat.java
deleted file mode 100644
index 70f3370..0000000
--- a/src/main/java/hcfsfuse/jnifuse/struct/FileStat.java
+++ /dev/null
@@ -1,131 +0,0 @@
-package hcfsfuse.jnifuse.struct;
-
-import alluxio.util.OSUtils;
-
-import java.nio.ByteBuffer;
-
-public class FileStat extends Struct {
- public static final int S_IFIFO = 0010000; // named pipe (fifo)
- public static final int S_IFCHR = 0020000; // character special
- public static final int S_IFDIR = 0040000; // directory
- public static final int S_IFBLK = 0060000; // block special
- public static final int S_IFREG = 0100000; // regular
- public static final int S_IFLNK = 0120000; // symbolic link
- public static final int S_IFSOCK = 0140000; // socket
- public static final int S_IFMT = 0170000; // file mask for type checks
- public static final int S_ISUID = 0004000; // set user id on execution
- public static final int S_ISGID = 0002000; // set group id on execution
- public static final int S_ISVTX = 0001000; // save swapped text even after use
- public static final int S_IRUSR = 0000400; // read permission, owner
- public static final int S_IWUSR = 0000200; // write permission, owner
- public static final int S_IXUSR = 0000100; // execute/search permission, owner
- public static final int S_IRGRP = 0000040; // read permission, group
- public static final int S_IWGRP = 0000020; // write permission, group
- public static final int S_IXGRP = 0000010; // execute/search permission, group
- public static final int S_IROTH = 0000004; // read permission, other
- public static final int S_IWOTH = 0000002; // write permission, other
- public static final int S_IXOTH = 0000001; // execute permission, other
-
- public static final int ALL_READ = S_IRUSR | S_IRGRP | S_IROTH;
- public static final int ALL_WRITE = S_IWUSR | S_IWGRP | S_IWOTH;
- public static final int S_IXUGO = S_IXUSR | S_IXGRP | S_IXOTH;
-
- public static boolean S_ISTYPE(int mode, int mask) {
- return (mode & S_IFMT) == mask;
- }
-
- public static boolean S_ISDIR(int mode) {
- return S_ISTYPE(mode, S_IFDIR);
- }
-
- public static boolean S_ISCHR(int mode) {
- return S_ISTYPE(mode, S_IFCHR);
- }
-
- public static boolean S_ISBLK(int mode) {
- return S_ISTYPE(mode, S_IFBLK);
- }
-
- public static boolean S_ISREG(int mode) {
- return S_ISTYPE(mode, S_IFREG);
- }
-
- public static boolean S_ISFIFO(int mode) {
- return S_ISTYPE(mode, S_IFIFO);
- }
-
- public static boolean S_ISLNK(int mode) {
- return S_ISTYPE(mode, S_IFLNK);
- }
-
- public FileStat(ByteBuffer buffer) {
- super(buffer);
- if (OSUtils.isMacOS()) {
- st_dev = new Unsigned64();
- st_mode = new Unsigned32();
- st_nlink = new Unsigned64();
- st_ino = new Unsigned64();
- st_uid = new Unsigned32();
- st_gid = new Unsigned32();
- st_rdev = new Unsigned64();
- st_atim = new Timespec();
- st_mtim = new Timespec();
- st_ctim = new Timespec();
- st_birthtime = new Timespec();
- st_size = new SignedLong();
- st_blocks = new SignedLong();
- st_blksize = new SignedLong();
- st_flags = new Unsigned32();
- st_gen = new Unsigned32();
- new Signed32();
- new Signed64();
- new Signed64();
-
- pad1 = null;
- } else {
- // Linux platform
- st_dev = new Unsigned64();
- pad1 = null;
- st_ino = new Unsigned64();
- st_nlink = new Unsigned64();
- st_mode = new Unsigned32();
- st_uid = new Unsigned32();
- st_gid = new Unsigned32();
- st_rdev = new Unsigned64();
- st_size = new SignedLong();
- st_blksize = new SignedLong();
- st_blocks = new SignedLong();
- st_atim = new Timespec();
- st_mtim = new Timespec();
- st_ctim = new Timespec();
-
- st_birthtime = null;
- st_flags = null;
- st_gen = null;
- }
- }
-
- public final Unsigned64 st_dev;
- public final Unsigned16 pad1;
- public final Unsigned64 st_ino;
- public final Unsigned64 st_nlink;
- public final Unsigned32 st_mode;
- public final Unsigned32 st_uid;
- public final Unsigned32 st_gid;
- public final Unsigned64 st_rdev;
- public final SignedLong st_size;
- public final SignedLong st_blksize;
- public final SignedLong st_blocks;
- public final Timespec st_atim;
- public final Timespec st_mtim;
- public final Timespec st_ctim;
- public final Timespec st_birthtime;
-
- /** MacOS specific */
- public final Unsigned32 st_flags;
- public final Unsigned32 st_gen;
-
- public static FileStat wrap(ByteBuffer buffer) {
- return new FileStat(buffer);
- }
-}
diff --git a/src/main/java/hcfsfuse/jnifuse/struct/FuseContext.java b/src/main/java/hcfsfuse/jnifuse/struct/FuseContext.java
deleted file mode 100644
index df3db86..0000000
--- a/src/main/java/hcfsfuse/jnifuse/struct/FuseContext.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package hcfsfuse.jnifuse.struct;
-
-import java.nio.ByteBuffer;
-
-public class FuseContext extends Struct {
-
- public final Unsigned32 uid = new Unsigned32();
- public final Unsigned32 gid = new Unsigned32();
-
- public FuseContext(ByteBuffer buffer) {
- super(buffer);
- }
-}
diff --git a/src/main/java/hcfsfuse/jnifuse/struct/FuseFileInfo.java b/src/main/java/hcfsfuse/jnifuse/struct/FuseFileInfo.java
deleted file mode 100644
index 5cd9308..0000000
--- a/src/main/java/hcfsfuse/jnifuse/struct/FuseFileInfo.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package hcfsfuse.jnifuse.struct;
-
-import java.nio.ByteBuffer;
-
-public class FuseFileInfo extends Struct {
-
- public FuseFileInfo(ByteBuffer buffer) {
- super(buffer);
- flags = new Signed32();
- fh_old = new UnsignedLong();
- writepage = new Signed32();
- pad1 = new Padding(2);
- fh = new u_int64_t();
- lock_owner = new u_int64_t();
- }
-
- public final Signed32 flags;
- public final UnsignedLong fh_old;
- public final Signed32 writepage;
- public final Padding pad1;
- public final u_int64_t fh;
- public final u_int64_t lock_owner;
-
- public static FuseFileInfo wrap(ByteBuffer buffer) {
- return new FuseFileInfo(buffer);
- }
-}
diff --git a/src/main/java/hcfsfuse/jnifuse/struct/Statvfs.java b/src/main/java/hcfsfuse/jnifuse/struct/Statvfs.java
deleted file mode 100644
index e5ca46f..0000000
--- a/src/main/java/hcfsfuse/jnifuse/struct/Statvfs.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package hcfsfuse.jnifuse.struct;
-
-import java.nio.ByteBuffer;
-
-public class Statvfs extends Struct {
- /* Definitions for the flag in `f_flag'. */
- public static final int ST_RDONLY = 1; /* Mount read-only. */
- public static final int ST_NOSUID = 2; /* Ignore suid and sgid bits. */
- public static final int ST_NODEV = 4; /* Disallow access to device special files. */
- public static final int ST_NOEXEC = 8; /* Disallow program execution. */
- public static final int ST_SYNCHRONOUS = 16;/* Writes are synced at once. */
- public static final int ST_MANDLOCK = 64; /* Allow mandatory locks on an FS. */
- public static final int ST_WRITE = 128; /* Write on file/directory/symlink. */
- public static final int ST_APPEND = 256; /* Append-only file. */
- public static final int ST_IMMUTABLE = 512; /* Immutable file. */
- public static final int ST_NOATIME = 1024; /* Do not update access times. */
- public static final int ST_NODIRATIME = 2048;/* Do not update directory access times. */
- public static final int ST_RELATIME = 4096; /* Update atime relative to mtime/ctime. */
-
- public Statvfs(ByteBuffer buffer) {
- super(buffer);
- f_bsize = new UnsignedLong();
- f_frsize = new UnsignedLong();
- f_blocks = new UnsignedLong();
- f_bfree = new UnsignedLong();
- f_bavail = new UnsignedLong();
- f_files = new UnsignedLong();
- f_ffree = new UnsignedLong();
- f_favail = new UnsignedLong();
- f_fsid = new UnsignedLong();
- f_unused = null;
- f_flag = new UnsignedLong();
- f_namemax = new UnsignedLong();
- }
-
- public final UnsignedLong f_bsize;
- public final UnsignedLong f_frsize;
- public final UnsignedLong f_blocks;
- public final UnsignedLong f_bfree;
- public final UnsignedLong f_bavail;
- public final UnsignedLong f_files;
- public final UnsignedLong f_ffree;
- public final UnsignedLong f_favail;
- public final UnsignedLong f_fsid;
- public final Signed32 f_unused;
- public final UnsignedLong f_flag;
- public final UnsignedLong f_namemax;
- // __f_spare
-
- public static Statvfs wrap(ByteBuffer buffer) {
- return new Statvfs(buffer);
- }
-}
diff --git a/src/main/java/hcfsfuse/jnifuse/struct/Struct.java b/src/main/java/hcfsfuse/jnifuse/struct/Struct.java
deleted file mode 100644
index ba70b8b..0000000
--- a/src/main/java/hcfsfuse/jnifuse/struct/Struct.java
+++ /dev/null
@@ -1,310 +0,0 @@
-package hcfsfuse.jnifuse.struct;
-
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
-
-public abstract class Struct {
- static final Charset ASCII = StandardCharsets.US_ASCII;
- static final Charset UTF8 = StandardCharsets.UTF_8;
-
- public ByteBuffer buffer;
-
- static final class Info {
- int _offset = 0;
-
- private static int align(int offset, int align) {
- return (offset + align - 1) & ~(align - 1);
- }
-
- protected final int addField(int sizeBits, int alignBits) {
- final int alignment = alignBits >> 3;
- final int offset = align(this._offset, alignment);
- this._offset += sizeBits >> 3;
- return offset;
- }
- }
-
- final Info _info;
-
- protected Struct(ByteBuffer bb) {
- this._info = new Info();
- this.buffer = bb;
- bb.order(ByteOrder.LITTLE_ENDIAN);
- }
-
- protected abstract class Member {
- abstract int offset();
- }
-
- public abstract class NumberField extends Member {
- private final int offset;
-
- protected NumberField() {
- this.offset = _info.addField(getSize() * 8, getAlignment() * 8);
- }
-
- public final int offset() {
- return offset;
- }
-
- protected abstract int getSize();
-
- protected abstract int getAlignment();
- }
-
- public class Signed16 extends NumberField {
- @Override
- protected int getSize() {
- return 2;
- }
-
- @Override
- protected int getAlignment() {
- return 2;
- }
-
- public final short get() {
- return buffer.getShort(offset());
- }
-
- public final void set(short value) {
- buffer.putShort(offset(), value);
- }
- }
-
- public class Unsigned16 extends NumberField {
-
- @Override
- protected int getSize() {
- return 2;
- }
-
- @Override
- protected int getAlignment() {
- return 2;
- }
-
- public final int get() {
- int value = buffer.getShort(offset());
- return value < 0 ? (int) ((value & 0x7FFF) + 0x8000) : value;
- }
-
- public final void set(int value) {
- buffer.putShort(offset(), (short) value);
- }
- }
-
- public class Signed32 extends NumberField {
-
- @Override
- protected int getSize() {
- return 4;
- }
-
- @Override
- protected int getAlignment() {
- return 4;
- }
-
- public final void set(int value) {
- buffer.putInt(offset(), value);
- }
-
- public final int get() {
- return buffer.getInt(offset());
- }
- }
-
- public class Unsigned32 extends NumberField {
- @Override
- protected int getSize() {
- return 4;
- }
-
- @Override
- protected int getAlignment() {
- return 4;
- }
-
- public final long get() {
- long value = buffer.getInt(offset());
- return value < 0 ? (long) ((value & 0x7FFFFFFFL) + 0x80000000L) : value;
- }
-
- public final void set(long value) {
- buffer.putInt(offset(), (int) value);
- }
-
- public final int intValue() {
- return (int) get();
- }
- }
-
- public class Signed64 extends NumberField {
-
- @Override
- protected int getSize() {
- return 8;
- }
-
- @Override
- protected int getAlignment() {
- return 8;
- }
-
- public final long get() {
- return buffer.getLong(offset());
- }
-
- public final void set(long value) {
- buffer.putLong(offset(), value);
- }
- }
-
- public class Unsigned64 extends NumberField {
-
- @Override
- protected int getSize() {
- return 8;
- }
-
- @Override
- protected int getAlignment() {
- return 8;
- }
-
- public final long get() {
- return buffer.getLong(offset());
- }
-
- public final void set(long value) {
- buffer.putLong(offset(), value);
- }
- }
-
- public class SignedLong extends NumberField {
-
- @Override
- protected int getSize() {
- return 8;
- }
-
- @Override
- protected int getAlignment() {
- return 8;
- }
-
- public final long get() {
- return buffer.getLong(offset());
- }
-
- public final void set(long value) {
- buffer.putLong(offset(), value);
- }
-
- public final int intValue() {
- return (int) get();
- }
-
- public final long longValue() {
- return get();
- }
- }
-
- public class UnsignedLong extends NumberField {
-
- @Override
- protected int getSize() {
- return 8;
- }
-
- @Override
- protected int getAlignment() {
- return 8;
- }
-
- public final long get() {
- return buffer.getLong(offset());
- }
-
- public final void set(long value) {
- buffer.putLong(offset(), value);
- }
-
- public final int intValue() {
- return (int) get();
- }
-
- public final long longValue() {
- return get();
- }
- }
-
- public final class u_int64_t extends NumberField {
-
- @Override
- protected int getSize() {
- return 8;
- }
-
- @Override
- protected int getAlignment() {
- return 8;
- }
-
- public final long get() {
- return buffer.getLong(offset());
- }
-
- public final void set(long value) {
- buffer.putLong(offset(), value);
- }
- }
-
- protected abstract class AbstrctMember extends Member {
- private final int offset;
-
- protected AbstrctMember(int size) {
- this.offset = _info.addField(size * 8, 8);
- }
-
- @Override
- public final int offset() {
- return offset;
- }
- }
-
- public final class Padding extends AbstrctMember {
- public Padding(int size) {
- super(size);
- }
- }
-
- public final class Timespec extends Member {
- public final SignedLong tv_sec;
- public final SignedLong tv_nsec;
- public final int offset;
-
- protected Timespec() {
- // TODO: this may cause error
- tv_sec = new SignedLong();
- tv_nsec = new SignedLong();
- offset = tv_sec.offset();
- }
-
- @Override
- int offset() {
- return offset;
- }
-
- protected int getSize() {
- return tv_sec.getSize() + tv_nsec.getSize();
- }
-
- protected int getAlignment() {
- return Math.max(tv_sec.getAlignment(), tv_nsec.getAlignment());
- }
- }
-}
diff --git a/src/main/java/hcfsfuse/jnifuse/utils/SecurityUtils.java b/src/main/java/hcfsfuse/jnifuse/utils/SecurityUtils.java
deleted file mode 100644
index 8354480..0000000
--- a/src/main/java/hcfsfuse/jnifuse/utils/SecurityUtils.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package hcfsfuse.jnifuse.utils;
-
-public final class SecurityUtils {
- public static boolean canHandleShutdownHooks() {
- SecurityManager security = System.getSecurityManager();
- if (security == null) {
- return true;
- }
- try {
- security.checkPermission(new RuntimePermission("shutdownHooks"));
- return true;
- } catch (final SecurityException e) {
- return false;
- }
- }
-
- private SecurityUtils() {} // prevent instantiation
-}