diff options
| author | Miguel <m.i@gmx.at> | 2018-10-15 16:29:50 +0200 |
|---|---|---|
| committer | Miguel <m.i@gmx.at> | 2018-10-15 16:29:50 +0200 |
| commit | e3a8099343aac9d94f411638ad84632d4b620132 (patch) | |
| tree | f0a1f73ab106c17b25fd8a5264a66b6b48e55e48 /fs/mount.c | |
| parent | f35d2124c36f8d39a953b76620e081b79c2faffd (diff) | |
cleanup sys/ etc
Diffstat (limited to 'fs/mount.c')
| -rw-r--r-- | fs/mount.c | 28 |
1 files changed, 23 insertions, 5 deletions
@@ -49,6 +49,7 @@ static uint32_t check_match(char *p1, char *p2) c++; p1++; p2++; + if(*p1=='/')return c; } } @@ -71,9 +72,9 @@ static char* get_mount_for_path(char *path,mount *mnt) for(int i=0;i<mounts_count;i++) { mount *m=&mounts[i]; - uint32_t len=check_match(path,m->path); + uint32_t len=check_match(path+1,(m->path)+1); - if(len>best_len)//&&len==strlen(m->path)) + if(len>best_len&&path[len-1]=='/')//&&len==strlen(m->path)) { best=i; best_len=len; @@ -89,8 +90,25 @@ fd mount_file_open(char *path) mount m; char buf[256]; if(path[0]!='/'){ - // TODO: use environemnet PWD var! - sprintf(buf,"/home/miguel/%s",path); + + // we extract the PWD env variable! + // TODO: this is ugly! + char **env1=VMEM_USER_ENV+1024*2; + + int i=0; + while(1) + { + if(env1[i]==0)kpanic("unable to extract PWD!"); + if(!strcmp_l("PWD=",env1[i],4)) + { + sprintf(buf,"%s/%s",env1[i]+4,path); + klog("absolute path exracted: %s",buf); + break; + } + i++; + } + + } else { @@ -101,7 +119,7 @@ fd mount_file_open(char *path) return m.mount_file_open(&m,p); } -int mount_read_dir (char *path, fs_dirent *dirs, uint32_t *pos) +int mount_read_dir (char *path, struct dirent *dirs, uint32_t *pos) { mount m; char *p=get_mount_for_path(path,&m); |
