Java File.setlastmodified() fails on Linux when you are not the file owner
by Chucko from LinuxQuestions.org on (#51MJ9)
I have a Raspberry Pi with an external USB drive formatted with an Ext4 file system mounted at boot time via /etc/fstab using: Code:/dev/sdb1 /mnt/nxx ext4 defaults 0 2A java jar file which uses File.setlastmodified() to set a specific time stamp for a file on the drive by referring to /mnt/nxx/file.name works as desired when the file is owned by the same UID as the user running the java process. But it fails on the Pi if the logged-in user is any other UID.
As with the Pi, an Ubuntu host on the same network, and which mounts the same disk at boot time via fstab using: Code:192.168.x.x:/mnt/nxx /mnt/nxx nfs rw 0 1can successfully set the time-stamp only if the logged-in user has the same UID/GID as the Pi.
However, a Windows-10 host that connects via Samba to the same disk (mapped as N:\ to \\RASPI\root\mnt\) and running the same java code can successfully set the time-stamp for any file regardless of the file owner as claimed by the Pi.
All files in question have 777 permissions. As expected, any user on the Pi or any other host in my home network can successfully modify the file.
My goal is to be able to mount the disk and share it via whatever method so that both the Windows and Linux hosts on my home network can use the java code to successfully manipulate the time-stamps.
Why can Windows-10 successfully manipulate the time-stamp regardless of the user while Linux can not? Is there a way for me to add/configure options in the various fstab mount directives, in smb.conf, or elsewhere to configure the disk so that Linux will behave the same way Windows does?
Any help would be appreciated.


As with the Pi, an Ubuntu host on the same network, and which mounts the same disk at boot time via fstab using: Code:192.168.x.x:/mnt/nxx /mnt/nxx nfs rw 0 1can successfully set the time-stamp only if the logged-in user has the same UID/GID as the Pi.
However, a Windows-10 host that connects via Samba to the same disk (mapped as N:\ to \\RASPI\root\mnt\) and running the same java code can successfully set the time-stamp for any file regardless of the file owner as claimed by the Pi.
All files in question have 777 permissions. As expected, any user on the Pi or any other host in my home network can successfully modify the file.
My goal is to be able to mount the disk and share it via whatever method so that both the Windows and Linux hosts on my home network can use the java code to successfully manipulate the time-stamps.
Why can Windows-10 successfully manipulate the time-stamp regardless of the user while Linux can not? Is there a way for me to add/configure options in the various fstab mount directives, in smb.conf, or elsewhere to configure the disk so that Linux will behave the same way Windows does?
Any help would be appreciated.