]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev: mention that the kernel silently truncates lo_file_name if too long
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 13 Mar 2023 14:28:58 +0000 (23:28 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 14 Mar 2023 09:50:01 +0000 (18:50 +0900)
Resolves the confusion in https://github.com/systemd/systemd/pull/26693#discussion_r1131151335.

src/udev/udev-builtin-blkid.c

index 154cf7000f9ea2aff8a31e0cb1855885745a30ae..2b2205513b11c0ef3b97d0013e2a4be75f8c2049 100644 (file)
@@ -287,12 +287,14 @@ static int read_loopback_backing_inode(
 
         if (isempty((char*) info.lo_file_name) ||
             strnlen((char*) info.lo_file_name, sizeof(info.lo_file_name)-1) == sizeof(info.lo_file_name)-1)
-                /* Don't pick up file name if it is unset or possibly truncated. (Note: we can't really know
-                 * the file file name is truncated if it uses sizeof(info.lo_file_name)-1 as length; it could
-                 * also just mean the string is just that long and wasn't truncated — but the fact is simply
-                 * that we cannot know in that case if it was truncated or not, hence we assume the worst and
-                 * suppress — at least for now. For shorter strings we know for sure it wasn't truncated,
-                 * hence that's always safe.) */
+                /* Don't pick up file name if it is unset or possibly truncated. (Note: the kernel silently
+                 * truncates the string passed from userspace by LOOP_SET_STATUS64 ioctl. See
+                 * loop_set_status_from_info() in drivers/block/loop.c. Hence, we can't really know the file
+                 * name is truncated if it uses sizeof(info.lo_file_name)-1 as length; it could also mean the
+                 * string is just that long and wasn't truncated — but the fact is simply that we cannot know
+                 * in that case if it was truncated or not. Thus, we assume the worst and suppress — at least
+                 * for now. For shorter strings we know for sure it wasn't truncated, hence that's always
+                 * safe.) */
                 fn = NULL;
         else {
                 fn = memdup_suffix0(info.lo_file_name, sizeof(info.lo_file_name));