Skip to content

Commit a916fc7

Browse files
committed
Skip device if parent is a file and not a dir
1 parent 3b99f4a commit a916fc7

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Diff for: genext2fs.c

+10
Original file line numberDiff line numberDiff line change
@@ -2629,6 +2629,8 @@ add2fs_from_file(filesystem *fs, uint32 this_nod, FILE * fh, uint32 fs_timestamp
26292629
size_t len;
26302630
struct stat st;
26312631
int nbargs, lineno = 0;
2632+
nod_info *ni;
2633+
inode *pnode;
26322634

26332635
fstat(fileno(fh), &st);
26342636
ctime = fs_timestamp;
@@ -2684,6 +2686,14 @@ add2fs_from_file(filesystem *fs, uint32 this_nod, FILE * fh, uint32 fs_timestamp
26842686
{
26852687
error_msg("device table line %d skipped: can't find directory '%s' to create '%s''", lineno, dir, name);
26862688
continue;
2689+
} else {
2690+
pnode = get_nod(fs, nod, &ni);
2691+
if((pnode->i_mode & FM_IFMT) != FM_IFDIR) {
2692+
error_msg("device table line %d skipped: parent '%s' is not a directory so won't create '%s''", lineno, dir, name);
2693+
put_nod(ni);
2694+
continue;
2695+
}
2696+
put_nod(ni);
26872697
}
26882698
}
26892699
else

0 commit comments

Comments
 (0)