Comments (7)
What about translating /home/xxx
to /mnt/c/Users/%username%/AppData/Local/lxss/home/xxx
, and /{etc,usr,xxx}
to /mnt/c/Users/%username%/AppData/Local/lxss/rootfs/{etc,usr,xxx}
?
Just a sample used by myself:
diff --git a/caller/wrun.c b/caller/wrun.c
index ed99a21..43179e3 100644
--- a/caller/wrun.c
+++ b/caller/wrun.c
@@ -128,6 +128,23 @@ static char* agetcwd()
sz *= 2; if (sz > MY_DYNAMIC_PATH_MAX) sz = MY_DYNAMIC_PATH_MAX;
buf = xrealloc(buf, sz);
}
+
+ if (strncmp(buf, "/home/", 6) == 0) {
+ const char* rootdir = "/mnt/c/Users/goreliu/AppData/Local/lxss";
+ char* newbuf = xmalloc(sz + strlen(rootdir));
+ strcpy(newbuf, rootdir);
+ strcat(newbuf, buf);
+ free(buf);
+ buf = newbuf;
+ } else if (strncmp(buf, "/mnt/", 5) != 0) {
+ const char* rootdir = "/mnt/c/Users/goreliu/AppData/Local/lxss/rootfs";
+ char* newbuf = xmalloc(sz + strlen(rootdir));
+ strcpy(newbuf, rootdir);
+ strcat(newbuf, buf);
+ free(buf);
+ buf = newbuf;
+ }
+
return buf;
}
I don't know how to find the %username% in WSL, maybe outbash.exe
can write it to ~/.config/cbwin/outbash_username
.
from cbwin.
A default path (%USERPROFILE%
) can be explicitly required by adding an extra param ':' before the command.
For example you can try:
wrun : notepad
(or wstart : notepad
to not wait for notepad termination)
':' is a little weird, the reason for it is that I originally wanted to use ~ like bash.exe, but ~ is expanded by bash, so I switched to ':' which is forbidden in Windows paths but otherwise a normal character in parameters as parsed by bash.
I probably won't add an automatic fallback to %USERPROFILE%
, because this would be dangerous if you shoot something like wcmd rd /S /Q toto
.
from cbwin.
Commit e7a048e documents the ':' param.
from cbwin.
We are not supposed to write in those directories from Win32.
from cbwin.
quote from stackoverflow
New files that are created via Windows Explorer are possibly not appearing in bash because they are missing special LXSS NTFS attributes.
When LXSS creates files in the LXSS root, it attaches additional information to them via NTFS attributes to store things that cannot be represented by the standard NTFS attributes, such as Linux file permissions. If these are missing, it the files don't show up.
This is supported by the fact that if you make a file in bash, and then make a copy of it with Windows Explorer, it appears in bash. This is presumably because all of the special LXSS attributes were duplicated with the file.
The LXSS filesystem layer also appears to cache the file system, so the directory entries in bash will not reflect the actual state of the file system if files are added or deleted until all bash terminals are stopped (which ends the LXSS session in the LXSS service and hence clears the cache).
So this is only good for reading files.
from cbwin.
@poma I can create a file in WSL and read or edit it with Windows software, like this:
goreliu@MY-PC:~
$ n ahk # cp ~/.templete/ahk.ahk .
goreliu@MY-PC:~
$ np ahk.ahk # wstart c:/mine/app/notepad++/notepad++.exe ahk.ahk
I didn't meet any problems. I don't want to create files in /mnt/xx because I can't use chmod there, every file is 0777.
from cbwin.
Only reading files from Win32 should cause no problem as long as they are not written in a concurrent WSL session.
The result of writing files there from Win32 depends on a lot of factors, and to simplify shall not considered reliable -- and even in situations where there currently are a set of conditions that gave you good results in the finite number of tests you did, by principle of how we have been told the architecture of WSL is we should consider that the precise conditions are susceptible to change in new builds. For example, the content of the file observed from WSL might already be stall under some sequences of operations, and if WSL caching is changed in VolFs those exact "safe" and "unsafe" sequences of operations will change.
from cbwin.
Related Issues (20)
- Default command handler HOT 10
- some win32 console programs "sometimes" do line feed instead of new line, but a workaround seems possible HOT 1
- a cmd-like behavior distinguishing between console / GUI target programs might be useful HOT 1
- backgrounded & force redirected caller => SIGTTIN
- Use double quotes to prevent word splitting may be better HOT 12
- Problem with arguments containing the character "&" HOT 1
- wcmd cmd no longer laggy, but eats characters HOT 1
- Let cbwin in session mode launch multiple wcmd instances in parallel HOT 11
- sockets for redirections are not using any security HOT 6
- wstart /mnt/c/windows does not work HOT 7
- Not work inside zsh HOT 14
- behavior of environment variable inconsistent in regards to case sensitivity HOT 1
- No terminal support HOT 6
- Vagrant output doesn't wrap correctly HOT 4
- interactive win32 console programs are broken (input and output) HOT 5
- Native Windows support for launching Windows applications HOT 1
- Some inputted characters skipped in Docker interactive terminal HOT 1
- Starting parameters for bash.exe
- Can't remove cbwin from my pc HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cbwin.