mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-03-30 19:15:14 +00:00
uml/hostfs: Propagate dirent.d_type to filldir()
Currently the (optional) d_type member in struct dirent is always DT_UNKNOWN on hostfs, which may confuse buggy software using readdir(). Make sure to propagate its value from the underlying filesystem if it's available there. Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Richard Weinberger <richard@nod.at>
This commit is contained in:
parent
c0b79a90b1
commit
3ee6bd8e8d
3 changed files with 8 additions and 4 deletions
|
@ -67,7 +67,8 @@ extern int access_file(char *path, int r, int w, int x);
|
||||||
extern int open_file(char *path, int r, int w, int append);
|
extern int open_file(char *path, int r, int w, int append);
|
||||||
extern void *open_dir(char *path, int *err_out);
|
extern void *open_dir(char *path, int *err_out);
|
||||||
extern char *read_dir(void *stream, unsigned long long *pos,
|
extern char *read_dir(void *stream, unsigned long long *pos,
|
||||||
unsigned long long *ino_out, int *len_out);
|
unsigned long long *ino_out, int *len_out,
|
||||||
|
unsigned int *type_out);
|
||||||
extern void close_file(void *stream);
|
extern void close_file(void *stream);
|
||||||
extern int replace_file(int oldfd, int fd);
|
extern int replace_file(int oldfd, int fd);
|
||||||
extern void close_dir(void *stream);
|
extern void close_dir(void *stream);
|
||||||
|
|
|
@ -283,6 +283,7 @@ int hostfs_readdir(struct file *file, void *ent, filldir_t filldir)
|
||||||
char *name;
|
char *name;
|
||||||
unsigned long long next, ino;
|
unsigned long long next, ino;
|
||||||
int error, len;
|
int error, len;
|
||||||
|
unsigned int type;
|
||||||
|
|
||||||
name = dentry_name(file->f_path.dentry);
|
name = dentry_name(file->f_path.dentry);
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
|
@ -292,9 +293,9 @@ int hostfs_readdir(struct file *file, void *ent, filldir_t filldir)
|
||||||
if (dir == NULL)
|
if (dir == NULL)
|
||||||
return -error;
|
return -error;
|
||||||
next = file->f_pos;
|
next = file->f_pos;
|
||||||
while ((name = read_dir(dir, &next, &ino, &len)) != NULL) {
|
while ((name = read_dir(dir, &next, &ino, &len, &type)) != NULL) {
|
||||||
error = (*filldir)(ent, name, len, file->f_pos,
|
error = (*filldir)(ent, name, len, file->f_pos,
|
||||||
ino, DT_UNKNOWN);
|
ino, type);
|
||||||
if (error) break;
|
if (error) break;
|
||||||
file->f_pos = next;
|
file->f_pos = next;
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,7 +98,8 @@ void *open_dir(char *path, int *err_out)
|
||||||
}
|
}
|
||||||
|
|
||||||
char *read_dir(void *stream, unsigned long long *pos,
|
char *read_dir(void *stream, unsigned long long *pos,
|
||||||
unsigned long long *ino_out, int *len_out)
|
unsigned long long *ino_out, int *len_out,
|
||||||
|
unsigned int *type_out)
|
||||||
{
|
{
|
||||||
DIR *dir = stream;
|
DIR *dir = stream;
|
||||||
struct dirent *ent;
|
struct dirent *ent;
|
||||||
|
@ -109,6 +110,7 @@ char *read_dir(void *stream, unsigned long long *pos,
|
||||||
return NULL;
|
return NULL;
|
||||||
*len_out = strlen(ent->d_name);
|
*len_out = strlen(ent->d_name);
|
||||||
*ino_out = ent->d_ino;
|
*ino_out = ent->d_ino;
|
||||||
|
*type_out = ent->d_type;
|
||||||
*pos = telldir(dir);
|
*pos = telldir(dir);
|
||||||
return ent->d_name;
|
return ent->d_name;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue