[syslinux:master] extlinux: set bsHidden for loop devices

syslinux-bot for H. Peter Anvin hpa at zytor.com
Sat Jun 26 21:27:01 PDT 2010


Commit-ID:  92e6edabf7661a9fa9a7e7985d4fc37bf3cda649
Gitweb:     http://syslinux.zytor.com/commit/92e6edabf7661a9fa9a7e7985d4fc37bf3cda649
Author:     H. Peter Anvin <hpa at zytor.com>
AuthorDate: Sat, 26 Jun 2010 21:22:48 -0700
Committer:  H. Peter Anvin <hpa at zytor.com>
CommitDate: Sat, 26 Jun 2010 21:22:48 -0700

extlinux: set bsHidden for loop devices

If we are on a loop device, set bsHidden based on the loopback device
offset.

Signed-off-by: H. Peter Anvin <hpa at zytor.com>


---
 extlinux/main.c           |   13 ++++++++-----
 libinstaller/linuxioctl.h |    7 +++++++
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/extlinux/main.c b/extlinux/main.c
index 884a025..68e6457 100644
--- a/extlinux/main.c
+++ b/extlinux/main.c
@@ -57,11 +57,6 @@ typedef uint64_t u64;
 # define dprintf(...) ((void)0)
 #endif
 
-#if defined(__linux__) && !defined(BLKGETSIZE64)
-/* This takes a u64, but the size field says size_t.  Someone screwed big. */
-# define BLKGETSIZE64 _IOR(0x12,114,size_t)
-#endif
-
 #ifndef EXT2_SUPER_OFFSET
 #define EXT2_SUPER_OFFSET 1024
 #endif
@@ -125,6 +120,8 @@ static const struct geometry_table standard_geometries[] = {
 int get_geometry(int devfd, uint64_t totalbytes, struct hd_geometry *geo)
 {
     struct floppy_struct fd_str;
+    struct loop_info li;
+    struct loop_info64 li64;
     const struct geometry_table *gp;
 
     memset(geo, 0, sizeof *geo);
@@ -162,6 +159,12 @@ int get_geometry(int devfd, uint64_t totalbytes, struct hd_geometry *geo)
 		"         (on hard disks, this is usually harmless.)\n",
 		geo->heads, geo->sectors);
 
+    /* If this is a loopback device, try to set the start */
+    if (!ioctl(devfd, LOOP_GET_STATUS64, &li64))
+	geo->start = li64.lo_offset >> SECTOR_SHIFT;
+    else if (!ioctl(devfd, LOOP_GET_STATUS, &li))
+	geo->start = (unsigned int)li.lo_offset >> SECTOR_SHIFT;
+
     return 1;
 }
 
diff --git a/libinstaller/linuxioctl.h b/libinstaller/linuxioctl.h
index e4284df..7ef919a 100644
--- a/libinstaller/linuxioctl.h
+++ b/libinstaller/linuxioctl.h
@@ -37,4 +37,11 @@
 
 #undef statfs
 
+#if defined(__linux__) && !defined(BLKGETSIZE64)
+/* This takes a u64, but the size field says size_t.  Someone screwed big. */
+# define BLKGETSIZE64 _IOR(0x12,114,size_t)
+#endif
+
+#include <linux/loop.h>
+
 #endif /* LIBINSTALLER_LINUXIOCTL_H */



More information about the Syslinux-commits mailing list