permission denied writing to LUN/file error as root?

bmg002

Senior Member
Aug 21, 2012
610
213
73
Hope I am putting this in the correct section, but I am looking for some technical help.
I am running the latest global stable rom (8.2.2.0), have the bootloader unlocked and it is rooted.

What I am trying to do is write to the file:
/sys/class/android_usb/android0/f_mass_storage/lun/file

but when I try to echo into the file, I get error 1. Running that through toybox or busybox gives a better error of permission denied. I changed the permissions to 777 on the file (to open it up completely) and same thing. I tried changing the owner of the file to root:root and that was successful, but still couldn't write to that file.

My goal is to re-enable mass storage via a shell script, but writing to that file is part of the process. Any thoughts as I am currently stumped. My best guess is that I need to modify the file /init.usb.rc but that requires making a custom kernel and ROM which is currently beyond my abilities.
 

bmg002

Senior Member
Aug 21, 2012
610
213
73
So, quick update on this... was reading online that I'd need to remove the immutable flag on the file but it seems that file doesn't support chattr or lsattr.
The whole folder path doesn't support lsattr or chattr. Tried from recovery and same thing.

Still thinking about this but I am getting more and more stumped. Any developers or linux experts have any thoughts?
lsattr and chattr both throw the error "not a typewriter". Was thinking that maybe my busybox is out of date... going to try updating it and see if that helps.
 

bmg002

Senior Member
Aug 21, 2012
610
213
73
Update 2 - updating busybox changed the "not a typewriter" error to an invalid ioctl error.
So, from what I can tell, this basically means that lsattr and chattr don't work on the sysfs file system type. And since the file doesn't allow you to add anything to it, mass storage on this phone (with the global stable ROM) is not possible.