I am trying to add a set of attributes at creation time as in the following example. This code creates a new file on a POSIX file system with specific permissions ("rw-rw-r--") in mounted CIFS share.
public static void main(String[] args) {
Path new_path = Paths.get("/mnt/test/new_file.txt");
System.out.println(new_path.getFileSystem().supportedFileAttributeViews().contains("posix"));
Set<PosixFilePermission> perms = PosixFilePermissions.fromString("rw-rw-r--");
FileAttribute<Set<PosixFilePermission>> attr = PosixFilePermissions.asFileAttribute(perms);
try {
Files.createFile(new_path, attr);
} catch (IOException e) {
System.err.println(e);
}
}
After run the simple code, the file was created but the permissions for it looks
rwxrwSrwx 1 root root 0 May 5 2014 new_file.txt
instead of what I needed (look in the code 'rw-rw-r--')
Can someone help me with that issue?