I have few message on device boot about missing files or directories:
[ 3.052514] init: write_file: Unable to open '/proc/cpu/alignment': No such file or directory
[ 4.931333] init: write_file: Unable to open '/proc/sys/vm/min_free_order_shift': No such file or directory
I've founded out that init process tries to write values to these files via command
write /proc/cpu/alignment 4
Documentation says that write can create new file if it doesn't exist. But in result I can't find this file. Seams it wasn't created. Even more, there is no folder which should contain this file.
So can write command create a folder if it doesn't exist?
Filesystem under '/proc' is special in sence that all of its files are "created" by the kernel, and user cannot create files there.
This is pseudo-filesystem: its files are not stored on hard disk, but exist only in RAM and reflect system properties. Writing into this files changes properties in a special way. You cannot create new properties there.
Related
I'm using xamarin forms to develop an Android app. I can save a file via
var fileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), $"appsettiings.txt");
var data = JsonConvert.SerializeObject(this);
File.WriteAllText(fileName, data);
When I debug I can see that the file should be stored at
/data/user/0/<applicationame>/files/.local/share/appsettiings.txt
I like to see if the file is actually saved and what the content is. I opened the Android device monitor but the data folder was 'empty'. From some other SO case I took that I should but myself in root-mode by executing
C:\Program Files (x86)\Android\android-sdk\platform-tools>adb root
Now the data folder contains data and I can drill down up to the files folder, but that one seems to be empty.
When I run the app again and check in code if the file exists, it actually does.
Any further suggestions how to get access to that file from any tooling. I want to delete that file and run the app again.
You can use adb pull to copy the file to local machine and look at it content like this:
adb root
adb pull /data/user/0/<applicationame>/files/.local/share/appsettiings.txt [LOCAL_FOLDER]
then you can use adb shell then rm -f to remove it, like this:
adb shell
su
rm -f /data/user/0/<applicationame>/files/.local/share/appsettiings.txt
Since the file you are requesting is inside /data folder, you need to have the corresponding root priviliege to get it, so you need to do adb root before the adb pull command, and you need to do su before removing the file.
If I am not mistaken, if you save a file with your approach, it should exist, as you already proofed with the .Exists method.
I am not quite sure, are you just trying to read the content out of the file? Or do you want to access it from outside of the application?
If your desire is to just read the content, you could access it with
string content= File.ReadAllText(your file path);
and set a breakpoint (F9) on the next line.
I want to download all files from /data/data/foo folder to my pc. I am using adb to connect with my phone.
cd /data/data/foo
ls -R
.:
cache
databases
files
lib
shared_prefs
./cache:
./databases:
errors.db
errors.db-journal
logs.db
logs.db-journal
./files:
cache_state.info
./shared_prefs:
LANG_CODE.xml
PPP.xml
CADD
.xml
To download files I am using:
adb pull "/data/data/foo" %USERPROFILE%/foo
And here's response:
pull: building file list...
skipping special file 'lib'
pull: /data/data/foo/files/cache_state.info -> C:\Users\root/foo/files/cache_state.info
pull: /data/data/foo/shared_prefs/CADD
.xml -> C:\Users\root/foo/shared_prefs/CADD
.xml
cannot create 'C:\Users\root\foo\shared_prefs\CADD
.xml': No such file or directory
And in fact, only this is copied:
foo/files/cache_state.info
foo/shared_prefs
What I am doing wrong here?
The problem:
What you're doing is right (the command is correct), but the problem comes from the nature of the task you're trying to achieve.
You're trying to copy files from a unix device (an ext filesystem) into your windows pc (with NTFS filesystem). This usually works fine but there are cases when it doesn't: different filesystems have different rules as to which filenames are valid, and if a filename is valid in the source but not in the destination, there's no way to copy it preserving it's name.
From the error I understand you have a file named CADD
.xml (with line break included in the name) that is valid in your android device but will give an error when trying to copy it into your windows filesystem (see Which file systems support newlines in file names?).
Possible solutions:
Copy the files one by one and set a different destination name for the file causing trouble (CADD\n.xml -> CADD.xml)
Get some ext filesystem (either create it in your disk or mount from an external disk) and copy the files there
Copy the file into the ext filesystem used by your in-windows bash shell (see How to Access Your Ubuntu Bash Files in Windows )
I'm trying to create a partition called "subdata" under "/data". But it's failing.
The steps I tried and the failure results are mentioned below.
File dir =new File(/data/subdata/");
boolean success = dir.mkdir();
Here, the "success" value is found "false".
File dir= context.getDir("/data/subdata",Context.MODE_WORLD_READABLE);
Here, I get "java.lang.IllegalArgumentException: File app_/data/subdata/ contains a path separator"
Please, help me in creating this subfolder under /data/ partition.
I solved my need in the below manner.
As I mentioned in the question that, if I create the sub folder manually, I'm able to read and write to that subfolder in the /data.
So, I created this subfolder through init.rc (as I mentioned, I have the build code also). As I'm more fluent in Linux than in Android, I fixed it through init.rc. Now I'm able to read/write to that folder through my android code.
I'm looking at android's source code and i'm trying to add file to the data partition in build time. For that i need to add file to the userdata partition.
Moreover, i need to find where the the permissions for the files in the data directory are determined, in order to give the file the permissions i want.
For that i need to see where in the source code is the userdata partition mounted, because i guess that the permissions are given there as well.
I've looked at init.rc but the only thing i saw is:
mkdir /data 0771 system system
But there doesn't seem to be any mount for user data..
Does someone knows where does this happen?
You can just use PRODUCT_COPY_FILES for example:
PRODUCT_COPY_FILES += device/repo/your_file.so:data/folder/your_file.so
...plenty of examples here, in my device repo... just copy it to data though, instead of system: https://github.com/sudosurootdev/device_lge_g2-common/blob/kk44/g2.mk
More examples: https://github.com/sudosurootdev/vendor_lge/blob/kk44/ls980/ls980-vendor-blobs.mk
NOTE: Just don't add it to an Android.mk file. Use another *.mk file either under an Android.mk which calls all subdir makefiles or call the file specifically from another:
include device/repo/your_file.mk
Now, if it needs it's own directory under data, you will want to add it in the init.rc like you posted.
I'm trying to test the Expansion Pack Files (OBB) In Android following the guide here:
http://developer.android.com/google/play/expansion-files.html
I'm in the step where I need to test my app on my Nexus 4.
I generated my .obb file with jobb and adb-pushed it in the device in this location:
/mnt/shell/emulated/0/Android/obb/my.package/main.1.my.package.obb
When the app run it doesn't find the file.
Method:
Helpers.doesFileExist(context, fileName, xf.mFileSize, false)
return false for my file.
I debugged and found out it is looking for the file in:
/storage/emulated/0/Android/obb/my.package/main.1.my.package.obb
Specifically this is the path returned by:
Helpers.generateSaveFileName(c, fileName)
The /storage/emulated/0, returned by Environment.getExternalStorageDirectory() doesn't exist browsing the device with adb shell.
But it DOES at runtime, inside the app, I also checked what it contains: it contains almost the same things I found in /mnt/shell/emulated/0, it contains the Android/obb dir, which is empty.
How I found out the path /mnt/shell/emulated/0/Android/obb/my.package/main.1.my.package.obb where I placed my obb file:
$ adb shell
$ ls -ld sdcard
lrwxrwxrwx root root 2013-10-16 17:34 sdcard -> /storage/emulated/legacy
$ ls -ld /storage/emulated/legacy
lrwxrwxrwx root root 2013-10-16 17:34 legacy -> /mnt/shell/emulated/0
And inside that I already found the Android/obb directory, empty.
So the question is: where should I put my obb file for it to be in the right position at runtime?
I did everything said there:
created a draft application in the Market to get the public key
generated a random array of 20 byte (salt)
integrated play_licensing/library and play_apk_expansion/download_library
wrote my Service / Receiver
did the check using the Helpers etc.. exactly like the documentation say.
I suppose everything works but I can't just yet release on Play Store! I need to test locally and I'll have the need to change my obb file pretty often in this initial phase of development.
I can't test on the Emulator because I use 3D and device camera.
Since Android 4.2 multi users support have been added.
To support that Android mount an emulated disk for each users acting as a sandbox layer around the actual filesystem: this let Android handle gracefully either sharing of files between users either personal files.
Long story short:
/storage/emulated
is the emulated filesystem.
if you enter that directory from adb shell you may see a
/storage/emulated/obb
directory. Sometimes it doesn't show up, for some reason (see below for what to do if this happen)
It's not in /Android/obb but that's the right directory where to place your app package / obb file!
If you don't see that directory try looking in:
/mnt/shell/emulated/obb
You should be able to put your file there.
It will be correctly picked up at runtime ending at the
/storage/emulated/0/Android/obb/my.package/main.1.my.package.obb
path.
I think the Android documentation should explain this.
(I answer my own question because I found out how to solve it while writing it.)
For me the correct location is : mnt/sdcard/Android/obb/nameofyourpackage/
NOT "/mnt/shell"