[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 011/100] vvfat: always create . and .. entries at fir
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 011/100] vvfat: always create . and .. entries at first and in that order |
Date: |
Fri, 7 Jul 2017 19:07:26 +0200 |
From: Hervé Poussineau <address@hidden>
readdir() doesn't always return . and .. entries at first and in that order.
This leads to not creating them at first in the directory, which raises some
errors on file system checking utilities like MS-DOS Scandisk.
Specification: "FAT: General overview of on-disk format" v1.03, page 25
Fixes: https://bugs.launchpad.net/qemu/+bug/1599539
Signed-off-by: Hervé Poussineau <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/vvfat.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/block/vvfat.c b/block/vvfat.c
index 676cacb..0c6d0f4 100644
--- a/block/vvfat.c
+++ b/block/vvfat.c
@@ -727,6 +727,12 @@ static int read_directory(BDRVVVFATState* s, int
mapping_index)
i = mapping->info.dir.first_dir_index =
first_cluster == 0 ? 0 : s->directory.next;
+ if (first_cluster != 0) {
+ /* create the top entries of a subdirectory */
+ (void)create_short_and_long_name(s, i, ".", 1);
+ (void)create_short_and_long_name(s, i, "..", 1);
+ }
+
/* actually read the directory, and allocate the mappings */
while((entry=readdir(dir))) {
unsigned int length=strlen(dirname)+2+strlen(entry->d_name);
@@ -748,8 +754,11 @@ static int read_directory(BDRVVVFATState* s, int
mapping_index)
}
/* create directory entry for this file */
- direntry=create_short_and_long_name(s, i, entry->d_name,
- is_dot || is_dotdot);
+ if (!is_dot && !is_dotdot) {
+ direntry = create_short_and_long_name(s, i, entry->d_name, 0);
+ } else {
+ direntry = array_get(&(s->directory), is_dot ? i : i + 1);
+ }
direntry->attributes=(S_ISDIR(st.st_mode)?0x10:0x20);
direntry->reserved[0]=direntry->reserved[1]=0;
direntry->ctime=fat_datetime(st.st_ctime,1);
--
1.8.3.1
- [Qemu-block] [PULL 000/100] Block layer patches, Kevin Wolf, 2017/07/07
- [Qemu-block] [PULL 003/100] block: Simplify use of BDRV_BLOCK_RAW, Kevin Wolf, 2017/07/07
- [Qemu-block] [PULL 004/100] blkdebug: Support .bdrv_co_get_block_status, Kevin Wolf, 2017/07/07
- [Qemu-block] [PULL 002/100] block: Guarantee that *file is set on bdrv_get_block_status(), Kevin Wolf, 2017/07/07
- [Qemu-block] [PULL 001/100] qemu-io: Don't die on second open, Kevin Wolf, 2017/07/07
- [Qemu-block] [PULL 005/100] vvfat: fix qemu-img map and qemu-img convert, Kevin Wolf, 2017/07/07
- [Qemu-block] [PULL 007/100] vvfat: fix typos, Kevin Wolf, 2017/07/07
- [Qemu-block] [PULL 008/100] vvfat: rename useless enumeration values, Kevin Wolf, 2017/07/07
- [Qemu-block] [PULL 010/100] vvfat: fix field names in FAT12/FAT16 and FAT32 boot sectors, Kevin Wolf, 2017/07/07
- [Qemu-block] [PULL 011/100] vvfat: always create . and .. entries at first and in that order,
Kevin Wolf <=
- [Qemu-block] [PULL 012/100] vvfat: correctly create long names for non-ASCII filenames, Kevin Wolf, 2017/07/07
- [Qemu-block] [PULL 009/100] vvfat: introduce offset_to_bootsector, offset_to_fat and offset_to_root_dir, Kevin Wolf, 2017/07/07
- [Qemu-block] [PULL 013/100] vvfat: correctly create base short names for non-ASCII filenames, Kevin Wolf, 2017/07/07
- [Qemu-block] [PULL 014/100] vvfat: correctly generate numeric-tail of short file names, Kevin Wolf, 2017/07/07
- [Qemu-block] [PULL 015/100] vvfat: limit number of entries in root directory in FAT12/FAT16, Kevin Wolf, 2017/07/07
- [Qemu-block] [PULL 016/100] vvfat: handle KANJI lead byte 0xe5, Kevin Wolf, 2017/07/07
- [Qemu-block] [PULL 006/100] vvfat: replace tabs by 8 spaces, Kevin Wolf, 2017/07/07
- [Qemu-block] [PULL 018/100] qemu-img: drop -e and -6 options from the 'create' & 'convert' commands, Kevin Wolf, 2017/07/07
- [Qemu-block] [PULL 020/100] blockjob: Track job ratelimits via bytes, not sectors, Kevin Wolf, 2017/07/07
- [Qemu-block] [PULL 017/100] vvfat: change OEM name to 'MSWIN4.1', Kevin Wolf, 2017/07/07