/** * Creates a new dir. * * @param path the path on the FS of the new dir * @param mode Dir creation flags (IGNORED) * @return 0 on success, a negative value on error */ @Override public int mkdir(String path, @mode_t long mode) { final AlluxioURI turi = mPathResolverCache.getUnchecked(path); LOG.trace("mkdir({}) [Alluxio: {}]", path, turi); try { mFileSystem.createDirectory(turi); } catch (Throwable t) { LOG.error("Failed to create directory {}", path, t); return AlluxioFuseUtils.getErrorCode(t); } return 0; }
/** * Set the attribute NAME of the file pointed to by PATH to VALUE (which * is SIZE bytes long). * * @param flags @see {@link ru.serce.jnrfuse.flags.XAttrConstants} * @return Return 0 on success, -1 for errors. */ int setxattr(String path, String name, Pointer value, @size_t long size, int flags);
/** * Create a file node * <p> * This is called for creation of all non-directory, non-symlink * nodes. If the filesystem defines a create() method, then for * regular files that will be called instead. * * @param mode The argument mode specifies the permissions to use in case a new file * is created. @see ru.serce.jnrfuse.struct.FileStat flags */ int mknod(String path, @mode_t long mode, @dev_t long rdev);
/** * Reads the contents of a directory. * * @param path The FS path of the directory * @param buff The FUSE buffer to fill * @param filter FUSE filter * @param offset Ignored in alluxio-fuse * @param fi FileInfo data structure kept by FUSE * @return 0 on success, a negative value on error */ @Override public int readdir(String path, Pointer buff, FuseFillDir filter, @off_t long offset, FuseFileInfo fi) { final AlluxioURI turi = mPathResolverCache.getUnchecked(path); LOG.trace("readdir({}) [Alluxio: {}]", path, turi); try { final List<URIStatus> ls = mFileSystem.listStatus(turi); // standard . and .. entries filter.apply(buff, ".", null, 0); filter.apply(buff, "..", null, 0); for (final URIStatus file : ls) { filter.apply(buff, file.getName(), null, 0); } } catch (Throwable t) { LOG.error("Failed to read directory {}", path, t); return AlluxioFuseUtils.getErrorCode(t); } return 0; }
/** * Read the target of a symbolic link * <p> * The buffer should be filled with a null terminated string. The * buffer size argument includes the space for the terminating * null character. If the linkname is too long to fit in the * buffer, it should be truncated. The return value should be 0 * for success. */ int readlink(String path, Pointer buf, @size_t long size);
/** * Create a file node * <p> * This is called for creation of all non-directory, non-symlink * nodes. If the filesystem defines a create() method, then for * regular files that will be called instead. * * @param mode The argument mode specifies the permissions to use in case a new file * is created. @see ru.serce.jnrfuse.struct.FileStat flags */ int mknod(String path, @mode_t long mode, @dev_t long rdev);
/** * Allocates space for an open file * <p> * This function ensures that required space is allocated for specified * file. If this function returns success then any subsequent write * request to specified range is guaranteed not to fail because of lack * of space on the file system media. */ int fallocate(String path, int mode, @off_t long off, @off_t long length, FuseFileInfo fi); }
/** * Changes the mode of an Alluxio file. * * @param path the path of the file * @param mode the mode to change to * @return 0 on success, a negative value on error */ @Override public int chmod(String path, @mode_t long mode) { AlluxioURI uri = mPathResolverCache.getUnchecked(path); SetAttributePOptions options = SetAttributePOptions.newBuilder() .setMode(new alluxio.security.authorization.Mode((short) mode).toProto()).build(); try { mFileSystem.setAttribute(uri, options); } catch (Throwable t) { LOG.error("Failed to change {} to mode {}", path, mode, t); return AlluxioFuseUtils.getErrorCode(t); } return 0; }
/** * Write data to an open file * <p> * Write should return exactly the number of bytes requested * except on error. An exception to this is when the 'direct_io' * mount option is specified (see read operation). */ int write(String path, Pointer buf, @size_t long size, @off_t long offset, FuseFileInfo fi);
/** * Map block index within file to block index within device * <p> * Note: This makes sense only for block device backed filesystems * mounted with the 'blkdev' option * * @param idx block index within file * @param blocksize unit of block index */ int bmap(String path, @size_t long blocksize, long idx);
/** * Write contents of buffer to an open file * <p> * Similar to the write() method, but data is supplied in a * generic buffer. Use fuse_buf_copy() to transfer data to * the destination. * <p> * IMPORTANT: * Is not enabled by default, for enabling use * ru.serce.jnrfuse.AbstractFuseFS#isBufOperationsImplemented() */ int write_buf(String path, FuseBufvec buf, @off_t long off, FuseFileInfo fi);
public int create(String path, @mode_t long mode, FuseFileInfo fi) { final AlluxioURI uri = mPathResolverCache.getUnchecked(path); final int flags = fi.flags.get();
/** * Read data from an open file * <p> * Read should return exactly the number of bytes requested except * on EOF or error, otherwise the rest of the data will be * substituted with zeroes. An exception to this is when the * 'direct_io' mount option is specified, in which case the return * value of the read system call will reflect the return value of * this operation. */ int read(String path, Pointer buf, @size_t long size, @off_t long offset, FuseFileInfo fi);
/** * Write data to an open file * <p> * Write should return exactly the number of bytes requested * except on error. An exception to this is when the 'direct_io' * mount option is specified (see read operation). */ int write(String path, Pointer buf, @size_t long size, @off_t long offset, FuseFileInfo fi);
/** * Read data from an open file * <p> * Read should return exactly the number of bytes requested except * on EOF or error, otherwise the rest of the data will be * substituted with zeroes. An exception to this is when the * 'direct_io' mount option is specified, in which case the return * value of the read system call will reflect the return value of * this operation. */ int read(String path, Pointer buf, @size_t long size, @off_t long offset, FuseFileInfo fi);