SerCeMan / jnr-fuse

FUSE implementation in Java using Java Native Runtime (JNR)
MIT License
361 stars 87 forks source link

-bash: cd : mydirectory: Input/output error #178

Open syed72 opened 1 year ago

syed72 commented 1 year ago

I am trying to mount and use hdfs using jnr-fuse. but iam getting below error.

-bash: cd: mydirectory: Input/output error

public class HdfsFuseWrapper extends FuseStubFS{

@Override public int getxattr(String path, String name, Pointer value, @size_t long size) { try { // Get the extended attribute from HDFS System.out.println("getxpath:"+path+" "+name); org.apache.hadoop.fs.FileStatus fileStatus = fileSystem.getFileStatus(new Path(path)); // String attrValue = fileStatus.getExtendedAttribute(name); System.out.println("prin::"+fileStatus.toString()); String attrValue = "abc"; if (attrValue == null) { return -ErrorCodes.ENODATA(); // No data available error }

    // Convert the attribute value to bytes
    byte[] attrBytes = attrValue.getBytes();

    if (attrBytes.length > size) {
        return -ErrorCodes.ERANGE(); // Insufficient buffer error
    }

    // Copy the attribute value to the buffer
    value.put(0, attrBytes, 0, attrBytes.length);

    return attrBytes.length; // Return the length of the attribute value
} catch (Exception e) {
    return -ErrorCodes.ENOENT(); // File not found error
}

}

@Override public int getattr(String path, FileStat stat) { try { // Get the file status from HDFS org.apache.hadoop.fs.FileStatus fileStatus = fileSystem.getFileStatus(new Path(path)); System.out.println("permis:"+fileStatus.getPermission()); // Set the file attributes in the stat structure stat.st_mode.set(fileStatus.getPermission().toShort()); stat.st_nlink.set(1); // Number of hard links stat.st_size.set(fileStatus.getLen());

        stat.st_atim.tv_sec.set(fileStatus.getAccessTime()/1000L);
        stat.st_mtim.tv_sec.set(fileStatus.getModificationTime()/1000L);
        //stat.st_mtime.set(fileStatus.getModificationTime() / 1000L); // Convert milliseconds to seconds
        //stat.st_ctime.set(fileStatus.getModificationTime() / 1000L);
        //stat.st_atime.set(fileStatus.getAccessTime() / 1000L);

        return 0; // Success
    } catch (Exception e) {
        return -ErrorCodes.ENOENT(); // File not found error
    }
}

}

can someone help on this please?

syed72 commented 1 year ago

Mounting - HdfsFuseWrapper wrapper = new HdfsFuseWrapper(hdfsUri); wrapper.mount(Paths.get(mountPoint), true, true);

-- I tried changing permissions of mounted point in that machine. but not use.

Tried all the options, also checked the net no help from anywhere