I'm not quite sure what we should do here. You are right that root user will likely never see os.access(W_OK) as False because root's a privileged user so the perms don't matter.
Also, it seems that in containers we fail to resize up at cc_resizefs line 197 on ENOENT so generally trying to account for is_container checks below in the os.access and stat.S_ISBLK
conditionals feel like wasted logic. We could just check mode values instead of os.access like this:
os.stat(devpath).st_mode & (stat.S_IROTH | stat.S_IRGRP| stat.S_IRUSR)
I know there must be a better way here.
But ultimately, do you know if there are device files that would be read only for root?
I'm not quite sure what we should do here. You are right that root user will likely never see os.access(W_OK) as False because root's a privileged user so the perms don't matter.
Also, it seems that in containers we fail to resize up at cc_resizefs line 197 on ENOENT so generally trying to account for is_container checks below in the os.access and stat.S_ISBLK
conditionals feel like wasted logic. We could just check mode values instead of os.access like this:
os.stat( devpath) .st_mode & (stat.S_IROTH | stat.S_IRGRP| stat.S_IRUSR)
I know there must be a better way here.
But ultimately, do you know if there are device files that would be read only for root?