stat.st_size.set(size); stat.st_blocks.set((int) Math.ceil((double) size / 512)); stat.st_ctim.tv_sec.set(ctime_sec); 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(AlluxioFuseUtils.getUid(status.getOwner())); stat.st_gid.set(AlluxioFuseUtils.getGidFromGroupName(status.getGroup())); } else { stat.st_uid.set(UID); stat.st_gid.set(GID); mode |= FileStat.S_IFREG; stat.st_mode.set(mode); stat.st_nlink.set(1); } catch (Throwable t) { LOG.error("Failed to get info of {}", path, t);
public int create(String path, @mode_t long mode, FuseFileInfo fi) { final AlluxioURI uri = mPathResolverCache.getUnchecked(path); final int flags = fi.flags.get(); LOG.trace("create({}, {}) [Alluxio: {}]", path, Integer.toHexString(flags), uri); synchronized (mOpenFiles) { mOpenFiles.add(new OpenFileEntry(mNextOpenFileId, path, null, os)); fi.fh.set(mNextOpenFileId);
public int write(String path, Pointer buf, @size_t long size, @off_t long offset, FuseFileInfo fi) { if (size > Integer.MAX_VALUE) { final long fd = fi.fh.get(); OpenFileEntry oe = mOpenFiles.getFirstByField(ID_INDEX, fd); if (oe == null) { buf.get(0, dest, 0, sz); oe.getOut().write(dest); oe.setWriteOffset(offset + size);
/** * Gets the value for this field. * * @return a int. */ public final long get() { long value = getMemory().getNativeLong(offset()); final long mask = getRuntime().findType(NativeType.SLONG).size() == 32 ? 0xffffffffL : 0xffffffffffffffffL; return value < 0 ? (long) ((value & mask) + mask + 1) : value; }
/** * Gets the size of a Pointer in bits * * @return the size of the Pointer */ public final int size() { return getRuntime().findType(NativeType.ADDRESS).size(); }
/** * Gets the value for this field. * * @return a int. */ public final long get(jnr.ffi.Pointer ptr) { long value = ptr.getNativeLong(offset()); final long mask = getRuntime().findType(NativeType.SLONG).size() == 4 ? 0xffffffffL : 0xffffffffffffffffL; return value < 0 ? (long) ((value & mask) + mask + 1) : value; }
/** * Gets the size of a Pointer in bits * * @return the size of the Pointer */ public final int size() { return getRuntime().findType(NativeType.ADDRESS).size() * 8; }
/** * Puts a {@link jnr.ffi.Address} value into the native memory. * * @param value the value to write. */ public final void set(jnr.ffi.Address value) { getMemory().putAddress(offset(), value != null ? value.nativeAddress() : 0); }
/** * Returns the current timestamp with microsecond precision via a system call to {@code * gettimeofday}, through JNR C library. * * @return the current timestamp with microsecond precision. * @throws UnsupportedOperationException if JNR C library is not loaded or {@code gettimeofday} is * not available. * @throws IllegalStateException if the call to {@code gettimeofday} did not complete with return * code 0. */ public static long currentTimeMicros() { if (!isGettimeofdayAvailable()) throw new UnsupportedOperationException( "JNR C library not loaded or gettimeofday not available"); LibCLoader.Timeval tv = new LibCLoader.Timeval(LibCLoader.LIB_C_RUNTIME); int res = LibCLoader.LIB_C.gettimeofday(tv, null); if (res != 0) throw new IllegalStateException("Call to gettimeofday failed with result " + res); return tv.tv_sec.get() * 1000000 + tv.tv_usec.get(); }
/** * Releases the resources associated to an open file. Release() is async. * * Guaranteed to be called once for each open() or create(). * * @param path the FS path of the file to release * @param fi FileInfo data structure kept by FUSE * @return 0. The return value is ignored by FUSE (any error should be reported * on flush instead) */ @Override public int release(String path, FuseFileInfo fi) { LOG.trace("release({})", path); OpenFileEntry oe; final long fd = fi.fh.get(); synchronized (mOpenFiles) { oe = mOpenFiles.getFirstByField(ID_INDEX, fd); mOpenFiles.remove(oe); } if (oe == null) { LOG.error("Cannot find fd for {} in table", path); return -ErrorCodes.EBADFD(); } try { oe.close(); } catch (IOException e) { LOG.error("Failed closing {} [in]", path, e); } return 0; }
/** * Gets the value for this field. * * @return a int. */ public final long get() { long value = getMemory().getNativeLong(offset()); final long mask = getRuntime().findType(NativeType.SLONG).size() == 32 ? 0xffffffffL : 0xffffffffffffffffL; return value < 0 ? (long) ((value & mask) + mask + 1) : value; }
/** * Gets the size of a Pointer in bits * * @return the size of the Pointer */ public final int size() { return getRuntime().findType(NativeType.ADDRESS).size(); }
/** * Gets the size of a Pointer in bits * * @return the size of the Pointer */ public final int size() { return getRuntime().findType(NativeType.ADDRESS).size() * 8; }
/** * Flushes cached data on Alluxio. * * Called on explicit sync() operation or at close(). * * @param path The path on the FS of the file to close * @param fi FileInfo data struct kept by FUSE * @return 0 on success, a negative value on error */ @Override public int flush(String path, FuseFileInfo fi) { LOG.trace("flush({})", path); final long fd = fi.fh.get(); OpenFileEntry oe = mOpenFiles.getFirstByField(ID_INDEX, fd); if (oe == null) { LOG.error("Cannot find fd for {} in table", path); return -ErrorCodes.EBADFD(); } if (oe.getOut() != null) { try { oe.getOut().flush(); } catch (IOException e) { LOG.error("Failed to flush {}", path, e); return -ErrorCodes.EIO(); } } else { LOG.debug("Not flushing: {} was not open for writing", path); } return 0; }
/** * Gets the value for this field. * * @return a int. */ public final long get() { long value = getMemory().getNativeLong(offset()); final long mask = getRuntime().findType(NativeType.SLONG).size() == 32 ? 0xffffffffL : 0xffffffffffffffffL; return value < 0 ? (long) ((value & mask) + mask + 1) : value; }
/** * Gets the size of a Pointer in bits * * @return the size of the Pointer */ public final int size() { return getRuntime().findType(NativeType.ADDRESS).size(); }