Skip to content

Commit ad20b95

Browse files
author
Mike Miller
committed
Merge branch 'zhaofengli-master' into current_WIP
Merge upstream PR ish-app#1812
2 parents aa29fcd + 89a7129 commit ad20b95

File tree

3 files changed

+39
-22
lines changed

3 files changed

+39
-22
lines changed

deps/aports/main/x86/index.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
APKINDEX-v3.14-2022-05-20.tar.gz
1+
APKINDEX-v3.14-2022-05-22.tar.gz

iSH-AOK.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2397,7 +2397,7 @@
23972397
baseConfigurationReference = BB0B85A42586F1CB00208600 /* ProjectDebug.xcconfig */;
23982398
buildSettings = {
23992399
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
2400-
CURRENT_PROJECT_VERSION = 369;
2400+
CURRENT_PROJECT_VERSION = 370;
24012401
};
24022402
name = "Debug-ApplePleaseFixFB19282108";
24032403
};
@@ -2407,7 +2407,7 @@
24072407
buildSettings = {
24082408
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
24092409
SWIFT_COMPILATION_MODE = wholemodule;
2410-
CURRENT_PROJECT_VERSION = 369;
2410+
CURRENT_PROJECT_VERSION = 370;
24112411
};
24122412
name = Release;
24132413
};
@@ -2452,7 +2452,7 @@
24522452
baseConfigurationReference = BB28C7532689522C00BDC834 /* ProjectDebugLinux.xcconfig */;
24532453
buildSettings = {
24542454
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
2455-
CURRENT_PROJECT_VERSION = 369;
2455+
CURRENT_PROJECT_VERSION = 370;
24562456
};
24572457
name = DebugLinux;
24582458
};
@@ -2735,7 +2735,7 @@
27352735
buildSettings = {
27362736
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
27372737
SWIFT_COMPILATION_MODE = wholemodule;
2738-
CURRENT_PROJECT_VERSION = 369;
2738+
CURRENT_PROJECT_VERSION = 370;
27392739
};
27402740
name = ReleaseLinux;
27412741
};

linux/fakefs.c

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,10 @@ struct fakefs_super {
2020

2121
// free with __putname
2222
static char *dentry_name(struct dentry *dentry) {
23-
/* I know this sucks, but __dentry_path isn't public for some reason */
24-
struct vfsmount fake_mnt = {};
25-
struct path root = {.dentry = dentry->d_sb->s_root, .mnt = &fake_mnt};
26-
struct path new_path = {.dentry = dentry, .mnt = &fake_mnt};
2723
char *name = __getname();
2824
if (name == NULL)
2925
return ERR_PTR(-ENOMEM);
30-
char *path = __d_path(&new_path, &root, name, PATH_MAX);
26+
char *path = dentry_path_raw(dentry, name, PATH_MAX);
3127
if (IS_ERR(path))
3228
return path;
3329
BUG_ON(path[0] != '/');
@@ -170,12 +166,12 @@ static int fakefs_rename(struct user_namespace *mnt_userns, struct inode *from_d
170166
struct fakefs_super *info = from_dir->i_sb->s_fs_info;
171167

172168
char *from_path = dentry_name(from_dentry);
173-
if (from_path == NULL)
174-
return -ENOMEM;
169+
if (IS_ERR(from_path))
170+
return PTR_ERR(from_path);
175171
char *to_path = dentry_name(to_dentry);
176-
if (to_path == NULL) {
172+
if (IS_ERR(to_path)) {
177173
__putname(from_path);
178-
return -ENOMEM;
174+
return PTR_ERR(to_path);
179175
}
180176

181177
db_begin(&info->db);
@@ -199,12 +195,12 @@ static int fakefs_link(struct dentry *from, struct inode *ino, struct dentry *to
199195
struct inode *inode;
200196

201197
char *from_path = dentry_name(from);
202-
if (from_path == NULL)
203-
return -ENOMEM;
198+
if (IS_ERR(from_path))
199+
return PTR_ERR(from_path);
204200
char *to_path = dentry_name(to);
205-
if (to_path == NULL) {
201+
if (IS_ERR(to_path)) {
206202
__putname(from_path);
207-
return -ENOMEM;
203+
return PTR_ERR(to_path);
208204
}
209205

210206
db_begin(&info->db);
@@ -229,8 +225,8 @@ static int fakefs_link(struct dentry *from, struct inode *ino, struct dentry *to
229225
static int unlink_common(struct inode *dir, struct dentry *dentry, int is_dir) {
230226
struct fakefs_super *info = dir->i_sb->s_fs_info;
231227
char *path = dentry_name(dentry);
232-
if (path == NULL)
233-
return -ENOMEM;
228+
if (IS_ERR(path))
229+
return PTR_ERR(path);
234230

235231
db_begin(&info->db);
236232
path_unlink(&info->db, path);
@@ -369,6 +365,8 @@ static const struct inode_operations fakefs_link_iops = {
369365
#define FILE_DIR(file) ((file)->private_data)
370366

371367
static int fakefs_iterate(struct file *file, struct dir_context *ctx) {
368+
struct fakefs_super *info = file->f_inode->i_sb->s_fs_info;
369+
372370
if (FILE_DIR(file) == NULL) {
373371
int err = host_dup_opendir(INODE_FD(file->f_inode), &FILE_DIR(file));
374372
if (err < 0)
@@ -382,14 +380,33 @@ static int fakefs_iterate(struct file *file, struct dir_context *ctx) {
382380
res = host_seekdir(dir, ctx->pos - 1);
383381
if (res < 0)
384382
return res;
383+
384+
char *dir_path = dentry_name(file->f_path.dentry);
385+
if (IS_ERR(dir_path))
386+
return PTR_ERR(dir_path);
387+
size_t dir_path_len = strlen(dir_path);
388+
389+
385390
struct host_dirent ent;
386391
for (;;) {
387392
res = host_readdir(dir, &ent);
388393
if (res <= 0)
389394
break;
390395
ctx->pos = host_telldir(dir) + 1;
391-
// TODO fix inode numbers!!!!!
392-
ent.ino = 0;
396+
// Get the inode number by constructing the file path and looking it up in the database
397+
if (strcmp(ent.name, ".") == 0) {
398+
ent.ino = file->f_inode->i_ino;
399+
} else if (strcmp(ent.name, "..") == 0) {
400+
ent.ino = d_inode(file->f_path.dentry->d_parent)->i_ino;
401+
} else {
402+
db_begin(&info->db);
403+
if (dir_path_len + 1 + strlen(ent.name) + 1 > PATH_MAX)
404+
continue; // a
405+
dir_path[dir_path_len] = '/';
406+
strcpy(&dir_path[dir_path_len + 1], ent.name);
407+
ent.ino = path_get_inode(&info->db, dir_path);
408+
db_commit(&info->db);
409+
}
393410
if (!dir_emit(ctx, ent.name, strlen(ent.name), ent.ino, ent.type))
394411
break;
395412
}

0 commit comments

Comments
 (0)