SD card permissions are not getting changed - android-sdcard

I changed SD card permissions in init.rc as:
mkdir /storage/sdcard1 0700 system system
but it's not getting reflected when I mount the SD card onto the device. It's still showing as 0771.
How can I change default permissions of my external SD card?
Test cases in the below CTS package deals with external storage:
com.android.cts.appsecurity.AppSecurityTests
Since some of the test cases were failing, I made the above change.. But it's still not working.. Please help!

Related

Could it be a problem to run fsck.vfat at each boot on a sd card?

I have a software deployed on several machine in production which is using a sd card (partitionned in FAT 32) to store its data. It runs on cRIO platform with the NI Linux RT 4.14.87
On some machine the sd card suddenly appears as read-only every time the device boots.
I resolved the problem by running a fsck.vfat on the sd card.
fsck.vfat /dev/<deviceName>
We have a proper extinction procedure which is supposed to avoid brutal shutdown which I supposed is the reason for our problem in the first place. But I am wondering if I could also put in place a procedure that run fsck.vfat with the -a option to automatically repair the sd card at each boot before mounting it and start the main software.
Can running this command at each boot induce some problem like prematured wearing on the sd card?

How can I monitor other mount namespace?

I'm developing daemon monitoring SD card directory with using fanotify.
But, all users have their own mount namespace, so daemon can't receive fanotify event though user app writes SD card (same directory with above).
How can I monitor all mount namespace?
Each mount point needs to be manually added by fanotify_mark().
Here is is a good example:

Can I/How do I force micro-SD card to r/w mount?

I have a sandisk 64GB microSD card that I've been using in my phone. It recently started refusing to let me save things to it on the phone and I am currently trying to figure out if it's possible to fix the problem.
I have an SD card slot on my Kubuntu laptop and SD card adapter that I'm using to plug in and attempt to mount the microSD with. The problem is persisting though.
I can mount the card as read-only without a problem and have access to everything on it (which I've now copied off) and everything seems to be intact.
I get problems as soon as I try to mount with write access. Using the following command
sudo mount -o rw,umask=000 /dev/mmcblk0p1 /media/exfat/
I get this output:
'WARN: volume was not unmounted cleanly.
ERROR: fsync failed.'
and it doesn't mount.
If I use sudo mount -o ro,umask=000 /dev/mmcblk0p1 /media/exfat/
I still get this error 'WARN: volume was not unmounted cleanly.'
but it mounts and I have full access.
Does anyone know if this is salvageable or should I just give up now and get a new one?
Any help would be gratefully received.
I had a similar situation but after trying all sorts of things over many minutes of frustration, I discovered there is a tiny 'read-only' switch on the side of the SD card adaptor. Doh.

How to read and write the raw device file of a usb flash drive as non-root

My USB flash drive gets automatically mounted at /media/ME without requiring root intervention.
Now, I can read and write sectors on the drive mounted at /dev/sdX device using open, lseek, read, and write. But I can do this only as root.
Question: Just as the device can get mounted without root intervention, is it also possible to read and write from/to this device without being root?
If it's not possible, I'm willing to show a GUI password dialog for root. But how do I do this from my console program?
Yes
The block device /dev/sdX has standard UNIX permissions - so if it is owned by your user or a group your user is in and the permissions are set correctly then you will be able to write to it.
$ ls -l /dev/sda
brw-rw---T 1 root disk 8, 0 Dec 3 18:27 /dev/sda
So only root and members of the group disk can read or write to my /dev/sda. If I put myself in the disk group I would be able to write to the block device.
You can set-up udev to set the permission of the block devices automagically when they are plugged in.

how can I put write/read protection on the sd card?

In linux, with Linux built in command, how can I put write/read protection on the sd card ? I will put, with command, protection such as user can not write something on the sd card because I have enabled the only read protection via command.
If you know without command, feel free to share
Anyway with software, you can do only it in a filesytem level. If some one format the pendrive, they will get the permission what ever they want to do on it. If there is something at hardware level for making a sdcard readonly, you will get what you asked here.

Resources