Skip to contentSkip to conversation

fs/fat: debug-print file read position during file_fat_read_at()

PATCH In review Andreas Dannenberg 3 participants 4 messages Aug 14, 2018 – Aug 20, 2018 VFAT/FAT/msdos filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs/fat: debug-print file read position during file_fat_read_at()

In order to make the debug print in file_fat_read_at() a tad more useful, show the offset the file is being read at alongside the filename.

---

Small addition but helpful nevertheless as none of the other debug prints embedded into fat.c seems to output this info. Without that addition it would just tell you the same file name a couple of times when reading from an DTB/ITB file for example. With the offset being shown it's easier to correlate/debug the loading process.

Oddly (and I haven't fully debugged this) but in order to really get _any_ of the debug() prints working in fat.c in my particulat setup, in addition to the usual '#define DEBUG' I also had to explicitly define _DEBUG to '1', something that should already be taken care of by log.c...

 fs/fat/fat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/fat/fat.c +1 -1
index 4efe8a3eda..4b722fc5ca 100644
@@ -1095,7 +1095,7 @@ int file_fat_read_at(const char *filename, loff_t pos, void *buffer,
 	if (ret)
 		goto out_free_both;
 
-	debug("reading %s\n", filename);
+	debug("reading %s at pos %llu\n", filename, pos);
 	ret = get_contents(&fsdata, itr->dent, pos, buffer, maxsize, actread);
 
 out_free_both:
Signature · 1 line
2.15.1
#1 lore raw

PATCH 1/1 fs/fat: debug-print file read position during file_fat_read_at()

Quoted 28 lines · Andreas Dannenberg

In order to make the debug print in file_fat_read_at() a tad more useful, show the offset the file is being read at alongside the filename.

---

Small addition but helpful nevertheless as none of the other debug prints embedded into fat.c seems to output this info. Without that addition it would just tell you the same file name a couple of times when reading from an DTB/ITB file for example. With the offset being shown it's easier to correlate/debug the loading process.

Oddly (and I haven't fully debugged this) but in order to really get _any_ of the debug() prints working in fat.c in my particulat setup, in addition to the usual '#define DEBUG' I also had to explicitly define _DEBUG to '1', something that should already be taken care of by log.c...

 fs/fat/fat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/fat/fat.c +0 -0
index 4efe8a3eda..4b722fc5ca 100644

fs/fat/fat.c int file_fat_read_at(const char *filename, loff_t pos, void *buffer, · line 1101

Quoted 8 lines
fs/fat/fat.c +1 -1
@@ -1095,7 +1095,7 @@ int file_fat_read_at(const char *filename, loff_t pos, void *buffer,
 	if (ret)
 		goto out_free_both;
 
-	debug("reading %s\n", filename);
+	debug("reading %s at pos %llu\n", filename, pos);
 	ret = get_contents(&fsdata, itr->dent, pos, buffer, maxsize, actread);
 
 out_free_both:

This seems to duplicate
[PATCH 1/1] fat: provide position in debug message
https://lists.denx.de/pipermail/u-boot/2018-August/337850.html

The only difference is that you print a decimal number instead of a hex number.

Using %llu is consistent with
fs/fat/fat.c:331:
debug("Read position past EOF: %llu\n", pos);

So I will withdraw my patch.

#2 lore raw

PATCH 1/1 fs/fat: debug-print file read position during file_fat_read_at()

Heinrich,

Quoted 35 lines · Heinrich Schuchardt
Quoted 34 lines · Andreas Dannenberg

In order to make the debug print in file_fat_read_at() a tad more useful, show the offset the file is being read at alongside the filename.

---

Small addition but helpful nevertheless as none of the other debug prints embedded into fat.c seems to output this info. Without that addition it would just tell you the same file name a couple of times when reading from an DTB/ITB file for example. With the offset being shown it's easier to correlate/debug the loading process.

Oddly (and I haven't fully debugged this) but in order to really get _any_ of the debug() prints working in fat.c in my particulat setup, in addition to the usual '#define DEBUG' I also had to explicitly define _DEBUG to '1', something that should already be taken care of by log.c...

 fs/fat/fat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/fat/fat.c +1 -1
index 4efe8a3eda..4b722fc5ca 100644
@@ -1095,7 +1095,7 @@ int file_fat_read_at(const char *filename, loff_t pos, void *buffer,
 	if (ret)
 		goto out_free_both;
 
-	debug("reading %s\n", filename);
+	debug("reading %s at pos %llu\n", filename, pos);
 	ret = get_contents(&fsdata, itr->dent, pos, buffer, maxsize, actread);
 
Quoted 6 lines

fs/fat/fat.c int file_fat_read_at(const char *filename, loff_t pos, void *buffer, · line 1101

Quoted 2 lines
fs/fat/fat.c +0 -0
 out_free_both:

This seems to duplicate
[PATCH 1/1] fat: provide position in debug message
https://lists.denx.de/pipermail/u-boot/2018-August/337850.html

Interesting, I had specifically searched for this to be potentially there already, but I searched by prefix "fs/fat" which you used in your earlier patch, however the prefix had changed in your later patch :)

Quoted 7 lines

The only difference is that you print a decimal number instead of a hex number.

Using %llu is consistent with
fs/fat/fat.c:331:
debug("Read position past EOF: %llu\n", pos);

Yes that's exactly why I used decimal. Also when using hex IMHO it would have been better to prefix with 0x to minimize confusion, something that got me into trouble in my early U-Boot days (it's often not clear what is hex and what is dec, but things have since improved on that front).

--
Andreas Dannenberg
Texas Instruments Inc

Quoted 4 lines

So I will withdraw my patch.

#3 lore raw
In reply to Andreas Dannenberg
Quoted 6 lines · Andreas Dannenberg

In order to make the debug print in file_fat_read_at() a tad more useful, show the offset the file is being read at alongside the filename.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180820/f1b20434/attachment.sig>