yashsingh1/xdaforums huggingface dataset:
[Magisk] 白い熊:
With these changes it works fine! Fully mounts LUKS volumes, checks them, no problem identified. Don't forget to replace the binary with the proper version - and fix the install script so that it moves it to /system/xbin/ on install of the module - I did by hand.

On to check the “-e” and then maybe the App permissions...

---------- Post added at 03:21 AM ---------- Previous post was at 02:50 AM ----------

OK - I just had to go back and recheck your code to see, if I'm not misunderstanding it, I thought maybe “-e” does what I'm asking, but it's a different functionality.

So, what we have currently: with “-b” you go through the list of mountpoints, even for from_to and delete the “Android” subdirs.

I'd like to introduce a switch, let's say “-z” that would be an optional argument to from_to. With “-z” from_to would mount the pairs like the regular from_to does but would also record the “-z” to the mount log.

Then, when “-b” would go through the mount log, if the from_to line would have “-z” it wouldn't delete the “Android” subdirectory. This way if for some reason you need the “Android” dir in the mount, you can ensure by hand that it will not be automatically deleted.
[Magisk] Rasilon:
I copied the sample config file, altered it for the name of my sd card, and ran fbind -mb. This was the result:

$ fbind -mb

/system/xbin/fbind[8]: source: /magisk/fbind/core.sh: No such file or directory
/system/xbin/fbind[10]: toolkit: not found

And now it just sits there doing nothing, never did get the prompt back. Any ideas?
[Magisk] 白い熊:
You're using the 9.9. version right? It's flawed. In sits there in e loop.

Try with 9.5. And you need to edit the config for your case—you're not gonna have the same directory structure in your user case…

---------- Post added at 06:35 AM ---------- Previous post was at 06:33 AM ----------

What do you get with:

ls -l /magisk/fbind/
[Magisk] 白い熊:
@VR25, so I did it in awk - now, hopefully, we have a solution for the permissions on access for each application in MM and should be the same for Nougat - I need someone here to check that on Nougat you also have the file /data/system/packages.xml

What you need to do:

- add a config item, for instance “perms” to config.sys that will have an Android app's system name as a parameter, so there will be lines like:

perms com.ubisoft.rayman.fiestarun

perms com.spotify.music

perms com.amazon.kindle

... and so on

- then build a loop into core.sh that will iterate through these parameters and on each run modify the original /data/system/packages.xml with the following script:

awk -v prog="^""$NAME" 'BEGIN { RS = "<package name="" ; FS = "</perms>" } ; NR == 1 ; $1 ~ prog { print RS $1 "<item name="android.permission.WRITE_MEDIA_STORAGE" granted="true" flags="0" />\n" FS $2 } ; NR != 1 && $1 !~ prog && $2 == "" { print RS $1 } ; NR != 1 && $1 !~ prog && $2 != "" { print RS $1 ; for (i = 2; i <= NF; i++) print FS $i }' /data/system/packages.xml > tmp.xml

I'm attaching a zip of the script, in case html formatting here would modify the escaped items as sometimes happens.

Anyhow - the “$NAME” above is the item where you will substitute the package name parameters, so it needs to be in a “for NAME in...“ loop. Obviously the tmp.xml from the first run has to serve as the source, instead of the /data/system/packages.xml for the second run and so on. I'm sure you get the picture.

On the phone this script runs smooth, does the substitution for one run in a fraction of a second, so good to go there even in case of many apps to gain access.

- Then the resultant final xml needs to be bindmounted over /data/system/packages.xml

- You need to implement this to happen right after boot - not waiting for the bindmounts themselves - I've found out this /data/system/packages.xml files gets rebuilt every boot and read by the system early on - so you need to just wait for the existence of the xml file - so that it is built, then run the substitution loop, bindmount it, and hopefully it will happen soon enough to be picked up by the system. We have to test it, if it actually works. But it would solve all access issues for apps and remove the necessity for an Xposed module and so...
[Magisk] Captain_Throwback:
[MENTION=5228676]VR25[/MENTION]

It seems that it is possible to bind mount folders for the secondary user as long as I include that setup information in the primary user's config.txt. The problem is, is that it won't bind mount folders to multiple locations in the same config file. For example, I can't state intsd_path for my secondary user storage at the bottom of the file, after the primary storage bind mounts, because the path gets changed for all of the bind mounts, not just the ones AFTER I specify a new intsd_path. Can the config file be read in order, so that the initial specified bind mounts happen for the default storage path (or previously specified path) and then any after a new variable declaration use that updated path? I think that's the multiuser support that I need from the module. Magisk and my device do seem to support the bind mounts for the secondary user just fine after adding intsd_path - just fbind doesn't appear to support multiple locations.
[Magisk] zorroxx:
Hi

Do I need to create .fbind directory first on external SD card? or is it internal SD card?

For example if I have only the line below in the config.txt

"from_to DCIM .fbind/DCIM"

and then run "setup $intsd/fbind/config.txt", will everything work? Are .fbind and DCIM directories automatically created on external SD card?

Why do we need .fbind? Why not the directory directly?

Do I need to specify what $intsd when I run setup command or the command already knows the path?

How do I know when it is working? What to look for?

When it works, using example above will DCIM directory on internal SD has all the files?

Is DCIM mounted on external SD? or is it the other way around?

Thanks
[Magisk] VR25:
First of all, I would sincerely thank you a lot if you read the reference THOROUGHLY before installing & playing with fbind. What you've done there can be dangerous... just letting you know! ;)

The correct setup is "from_to Android/obb/GAME Android/obb/GAME"

As for the second -- "obbf GAME"

As you may have noticed by now, both do the exact same thing. There's a reason why the second method exists, though -- and I assume you don't need to ask.

[MENTION=4237286]白い熊[/MENTION], I've been disconnected for a while. Couldn't finish the permissions part (post-fs-data.sh). I fixed the kill switch exceptions, busybox, cryptsetup & other major issues, though. Also, from 9/10 to 16, there were massive changes & optimizations almost everywhere. Check the changelog on post #2. I like how you put together the awk puzzle's pieces -- thanks!

Ok, now I see were the issue is. Will fix that in the next version. Thanks for the report!

[MENTION=1033939]zorroxx[/MENTION], I'm asking myself where you saw that "setup" command... it's "fbind -mb" which moves data to extsd & binds corresponding folders afterwards.

- All directories are created automatically.

- .fbind (notice the dot) hides duplicate media. You can use any other folder name, but don't forget the dot -- else, you'll end up with a messed up gallery.

- You don't need to specify intsd_path unless you have bind issues (read the debugging section of the README if that's the case).

- You know it's working when source & destination folders have the same contents.
[Magisk] Captain_Throwback:
[MENTION=5228676]VR25[/MENTION]

I just updated to 9/16, but now the bind mounts aren't working again. And the _fbind folder appears empty in my file manager. Any idea what the issue could be?

EDIT: It seems to be an issue with permissions, but not sure why. Something with the new folder?

EDIT 2: I do see the files there if I navigate to /data/media/0/_fbind, along with a debug log. I don't see anything in the folder when navigating to /sdcard/_fbind, though.

EDIT 3: Log attached.
[Magisk] khnoizer:
I don't see anything in both folders, but I saw the usual files at /data/_fbind.

I also want to know if this module works only on marshmallow or nougat and above, or something like that, as I was successfully bind my folders on nougat, but not on lollipop. Thank you.
[Magisk] VR25:
[MENTION=1162986]Captain_Throwback[/MENTION], the issue has been fixed!

Also, I forgot to mention that the new fbind_dir is data/_fbind. There shouldn't be an issue seeing /sdcard/_fbind and its contents, though -- as it was supposed to be bind-mounted there automatically. Will see what went wrong.

[MENTION=7730963]khnoizer[/MENTION], I didn't test fbind on Lollipop, but it should work as long as you specify the correct extsd_path. If I remember righ, it's /mnt/media_rw/sdcard1, as opposed to the regular /mnt/media_rw/XXXX-XXXX. So, you should add extsd_path /mnt/media_rw/sdcard1 to your config file. As per Marshmallow, there are no doubts that it works. Depending on your device/ROM, You might need the "Marshmallow SD Fix" Xposed module, though (for now).
[Magisk] VR25:
[MENTION=4237286]白い熊[/MENTION], I put together the awk part. You have to test and see...

Now, [MENTION=1162986]Captain_Throwback[/MENTION], 白い熊, do you know of any way to know who the current user is besides "whoami" on Android? That one won't work. I'm thinking on implementing separate config & log for each user. That would be the best thing to do for multi-user support.
[Magisk] Captain_Throwback:
Why won't "whoami" work? When I ran it for each user, I get output that indicates which user account I'm on. The prefix "u0" indicates user zero for the primary user, and "u11" (or whatever user number it is) for secondary users. Or is that not just something that'll work from a script perspective?
[Magisk] 白い熊:
touch tmp.file; ls -l tmp.file | awk '{ print $3 ":" $4}'; rm tmp.file

---------- Post added at 05:57 PM ---------- Previous post was at 05:55 PM ----------

I think a separate config/log is a good idea.
[Magisk] VR25:
"Or is that not just something that'll work from a script perspective?" Yup, that's it. fbind scripts will always report the user as root (obviously) -- that's the issue. 白い熊, your code is a great alternative to whoami, but it leads us to the same dead end in this context. We need something to identify which user is currently logged in (from a script running as root). I went lightly through /data/system contents to see if I could find a file/directory that would give me the "bingo moment", but... I ended up with the "nope moment." I wonder where the StatusBar/SystemUI gets the current user name from... :rolleyes:
[Magisk] Captain_Throwback:
I see.

Well I don't think SystemUI is necessarily using a root shell to determine the current user. At this point, an update that fixes bind mounting in general would be fine. 9/16 just doesn't work for me.
[Magisk] VR25:
Thought I fixed that earlier today. Tested just now (again) and it's working...
[Magisk] Captain_Throwback:
I'm not showing any new update in Magisk Manager...

EDIT: Downloaded again through the Manager and now the bind mounts are working. /sdcard/_fbind still shows empty, though.

EDIT 2: As far as multiuser support, I just need to be able to specify a secondary user intsd path so I can bind mount those folders too. Whether or not that user is logged on/active doesn't really matter.
[Magisk] VR25:
I'll just disable that bind-mount to /data/media/0 then.

Now, while the solution discussed earlier doesn't surface, I propose using bind_mnt [TARGET mount_point] (same syntax as in "mount -o bind [TARGET mount_point"). That'll do it for you and it's in the 9/16 build already.

You can use the built-in $extsd variable, but in place of $intsd, there must be the full path to the secondary user's media folder (for now) -- I assume yours is /data/media/11. Also, you have to move data manually (for now).

So, the config line bind_mnt $extsd/FOLDER /data/media/11/FOLDER should work.

TARGET & mount_point directories are created automatically.
[Magisk] Captain_Throwback:
bind_mnt doesn't seem to be working. My config.txt has these lines:

bind_mnt $extsd/Download /data/media/11/Download
bind_mnt $extsd/MagiskManager /data/media/11/MagiskManager

But no sign of that in the debug log.
[Magisk] VR25:
My bad! I just fixed that (available in the repo as well).

chlog
[Magisk] der_Kief:
[MENTION=535343]all[/MENTION] [MENTION=5228676]VR25[/MENTION]

anyone get this to work an a Huawei P9 Lite with Stock EMUI ROM ?

Tried different tools like Foldermount app and App2SD and also this magisk module but on my P9 Lite with EMUI 5 i cannot get this to work.

There must be something special with EMUI as with my other devices i own there are no problems at all.

Any hints ?
[Magisk] 白い熊:
[MENTION=5228676]VR25[/MENTION], it's not working, either doesn't bindmount over /data/system/packages.xml or something else—there's nothing in the debug log, just that due to cryptsetup it's not continuing.

I have to inspect your code later to see what's up, but there's definitely more issues as mentioned above: /data/_fbind doesn't get bindmounted to /sdcard/_fbind
[Magisk] Captain_Throwback:
Excellent! Now it's working :)

Finally have my folders bind mounted for both primary and secondary users. Great work.
[Magisk] koko115:
I lose my config. Where i find config to bind after today update ?
[Magisk] 白い熊:
It gets deleted by this update—you need copy it from a backup…
[Magisk] khnoizer:
Sorry, but it still doesn't work on lollipop after I specified that path.

Maybe I should mention that I'm using Xiaomi Redmi 3 (ido) with MIUI 9 (5.1) if that could help, also here is the config and log file. Thank you.
[Magisk] 白い熊:
OK [MENTION=5228676]VR25[/MENTION]:

Line 22 of post-fs-data.sh has a do instead of then, should be

if [ ! -f $modXML ]; then

Also, when you grep for perm before, you should really grep for ^perm

Anyhow it still wasn't mounting anything so I added the following lines before the if on the seventeenth line:

TTT="$modXML".tt
echo 1 > $TTT
echo "`ls -l $modXML`" >> $TTT
echo "`ls -l $config_file`" >> $TTT
echo "`grep -v '#' $config_file | grep -q 'perm '`" >> $TTT

and then added the following after the fi loop end on the thirty-fifth line:

echo 2 >> $TTT

Now, after boot the /data/_fbind/.packages.xml.tt file contains:

1

2

The three lines between 1 and 2 are empty - WTF? The busybox tools can't be seen this early in the boot or what - I'm not sure what's happening...
[Magisk] Phazonclash:
Galaxy S7 edge + Magisk 14.0

I flashed 2017.9.18.1 and for a reason I can't understand, "/data/_fbind/info/config_example.txt" & "/data/_find/config.txt" are not getting created, at all. Any idea why? Creating config.txt manually doesn't work

For the record, 2017.9.5 worked.
[Magisk] VR25:
[MENTION=5929147]der_Kief[/MENTION], you may want to check the README's debugging section.

[MENTION=4237286]白い熊[/MENTION], I see I made some classic mistakes there, but the main issue is really something else. Perhaps bind mounting packages.xml won't work. We should try symlinking it instead if that's the case. I'll dive more into that later.

It's not lost. The location has changed to /data/_fbind to accommodate new features. You can add the line bind_mnt /data/_fbind $intsd/_fbind to your config file to bind the config directory to /sdcard/_fbind if you want to see it there too.

Ok, I'll look into that. Meanwhile, could you check with a file explorer & confirm whether your external_sd path is really /mnt/media_rw/sdcard1? -- Thanks

Update: nevermind! That's the correct path.

Odd... :rolleyes:

I'll check what went wrong.
[Magisk] der_Kief:
sorry but this doesnt help me. The debug logfile tells me that everthing is OK but folder bindings dont work at all.
[Magisk] 白い熊:
I don't think, at least not currently, it's not running the substitution and mount now—the question is why. Symlinking isn't gonna help, if nothing is substituted and no edited xml is created…

The script itself works as expected now after boot—I've verified it, the output is proper. Now we just need to find out why ls won't run etc.
[Magisk] lekcin18:
hey guys. pardon me for being spoon feed but can someone give me config.txt set only for obb on external.

i read OP but don't understand any of it. thanks
[Magisk] 白い熊:
Only / is mounted when this script executes, no /system, no /data — that's why it fails.

It needs to check for these to be mounted…
[Magisk] VR25:
[MENTION=4237286]白い熊[/MENTION]], I see...

That might suggest Magisk's internal busybox is mounted to /dev/magisk/bin by the manager. In that case, post-fs-data is too early to run the bins from that path. I made some changes to the attached file to test that and other things. It logs to /data/_fbind/perm.log.

Update:

Well, that makes no sense. Regardless, I'm now thinking service.sh may not be too late to get the job done on packages.xml.

post-fs-data, on the other hand seems way too early, I guess... :rolleyes:

Update 2: off-topic -- config_updater.sh might have messed with the config file too much upon the second-last update. I didn't get an empty/messed up/deleted config, though.

Update 3: Attached a modified services.sh to test the above possibility.

Simply run the command echo obb >> /data/_fbind/config.txt (as root, of course).
[Magisk] 白い熊:
[MENTION=5228676]VR25[/MENTION], good idea with sourcing core.sh — with this post-fs “works”, however:

— The xml file gets edited properly.

— Symlinking this early doesn't work—the symlinked source gets renamed to /data/system/packages.xml.crt and a new packages.xml—identical to packages.xml.bkp is created.

— So I tried bindmounting instead—it isn't possible this early, the phone booted up in some “emergency mode”—never seen anything like this. After a reboot it's in a semi-messed up state, some stuff keeps segfaulting etc.

— Need to restore some backup and then I'll test the service.sh version…
[Magisk] Adomb:
Write to me code, plz, for config.

From data/data/com.blizzard.wtcg.hearthstone/files to intsd (data/media/0/data/hearthstone)
[Magisk] 白い熊:
I suggest you don't mess with this—if you don't understand the instructions and can't write a simple line for the mount as per your questions, you will cause a lot of grief to yourself when things go wrong and you won't understand what's happening and complain: “it's not working”, “it deleted my files” or whatever…
[Magisk] Adomb:
Nothing will hurt. Just write me a code, please.

--

example, test >

bind_mnt data/1 intsd_path 1

debug.log. >

Thu Sep 21 01:48:05 UTC 2017

<Config Update>

- Done.

/magisk/fbind/service.sh: /data/_fbind/.config/debug[1]: bind_mnt: not found

<SD Card Information>
[Magisk] yogesh324:
Hi I have a program called hideitpro it stores data in program data/Android dir I bound it to ext sd it worked and when I did a reboot it deleted the folder and I lost all the files in it.. I just checked the script u have made it to auto delete Android dirs it just delete all the Android dirs bound with fbind
[Magisk] 白い熊:
bind_mnt /data/com.blizzard.wtcg.hearthstone/files $intsd/data/hearthstone X

I don't understand why you want to do this, doesn't look right, why to intsd? You're in for some pain…
[Magisk] VR25:
You should've read the instructions thoroughly & pay more attention to what you do!

***
**DISCLAIMER**
- ALWAYS read the reference prior to installing/updating fbind. While no cats have been harmed in any way, shape or form, I assume no responsibility under anything that might go wrong due to the use/misuse of this module.

***
**CONFIG SYNTAX

**Function + Parameter(s)**
- altpart [block device] [mount point] [filesystem] ["fsck OPTION(s)" (filesystem dependent, optional)] --> auto-mount alternate partition & use it as extsd
- app_data [folder] --> data/data <--> $extsd/.data (needs altpart or LinuxFS formated SD card)
- bind_mnt [TARGET mount_point] --> same as "mount -o bind [TARGET mount_point]"
- cleanup [file/folder] --> auto-remove unwanted files/folders from intsd & extsd -- including by default, unwanted "Android" directories
- cryptsetup=true --> disable Auto-bind service (necessary for opening a LUKS volume)
- extsd_path [path] (i.e., /mnt/media_rw/NAME) --> ignore for default -- /mnt/media_rw/XXXX-XXXX
- from_to [$intsd folder] [$extsd folder] --> great for media folders & extra organization
- intobb_path [path] --> i.e., /storage/emulated/0 (ignore for default -- /data/media/0)
- intsd_path [path] --> i.e., /storage/emulated/0/Android/obb (ignore for default -- /data/media/obb)
- obb --> entire obb
- obbf [app/game folder] --> individual obb
- perm [package_name(s)] --> grant full storage access permission to specified package(s) (WIP)
- target [target folder] --> great for standard paths (i.e., Android/data, TWRP/BACKUPS)

An additional argument to any of the binding functions above excludes additional Android folders from being deleted. For bind_mnt(), it also enables data to be moved with fbind -m.

As you can see, it's there at the end, explicitly stated that a binding function must have an additional argument if the user wants to exclude non-standard Android directories from being removed.

I suggest you try recovering your data with a proper software (i.e., EaseUS Data Recovery Wizard) if it was really important stuff.
[Magisk] VR25:
Not trying to bash you, but... but -- honestly, whatever it is you're trying to do looks kinda scary if you ask me!

Let's do it like this... tell me exactly what you want to accomplish & I'll write your config.txt accordingly. ;)
[Magisk] yogesh324:
Hi I read it and as far as I understand what I did was in config I wrote from_to ProgramData .fbind/ProgramData

What is the additional argument that I should have written can u pls tell me.. I did have backup of it.. I just lost last months files .. I m not blaming u I thought there was something wrong with script
[Magisk] VR25:
[MENTION=2790737]yogesh324[/MENTION], the additional argument can be any string (i.e., the letter X) at the end of the config line.

Since you're binding data from a standard path (intsd/Android/data/YourAPP), you don't need from_to.

Use "target" instead, like so...

target /Android/data/YourAPP X

Notice the additional argument at the end (X). That's what it is.

So, that's the config line you need. ;)
[Magisk] Adomb:
VR25, Hello.

I often make backups in TWRP. External card I haven't. Hearthstone takes a lot of space in a backup. I need to move the folder /data/data/com.blizzard.wtcg.hearthstone/files to the internal card into path, for example, /data/media/0/data/hearthstone, to game files were not included in the backup. Something like that..

Sorry for my bad english.
[Magisk] VR25:
Ok, that's an unusual usage scenario. You need to set things up differently. Here's what you have to do:

0. Force close Hearthstone

1. Dowload the attached file

2. Copy it to the data partition

3. Run the following code as root: source /data/run.txt

That will build your config, backup Hearthstone files to /data/media/0/_hearstone_backup, move /data/data/com.blizzard.wtcg.hearthstone/files to /data/media/0/.app_data/com.blizzard.wtcg.hearthstone, set necessary permissions & bind folders automatically.
[Magisk] JudgeDread11:
I had been using the internal to external function very happily.

Until I recently noticed it isn't there anymore.

I tried doing back, but apparently it had been removed more versions ago then I still have on my device. (Before 10.09.17)

Did the new version have a similar version (I can't figure it out) .

Or can anybody post the latest version which still spots this function?

Thank you :)

Edit:

the 10.09.2017 version still had this functionality (int_extf). I rolled back to this version.

Still would like to know if the new version has a similar option?