Skip to contentSkip to conversation

libfsimage: make pygrub work on ufs

PATCH In review Christoph Egger 2 participants 5 messages Jun 9, 2008 – Jun 10, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libfsimage: make pygrub work on ufs

Hi!

Attached patch makes pygrub work on ufs.

Signature · 12 lines
AMD Saxony, Dresden, Germany
Operating System Research Center

Legal Information:
AMD Saxony Limited Liability Company & Co. KG
Sitz (Geschäftsanschrift):
   Wilschdorfer Landstr. 101, 01109 Dresden, Deutschland
Registergericht Dresden: HRA 4896
vertretungsberechtigter Komplementär:
   AMD Saxony LLC (Sitz Wilmington, Delaware, USA)
Geschäftsführer der AMD Saxony LLC:
   Dr. Hans-R. Deppe, Thomas McCoy
tools/libfsimage/ufs/fsys_ufs.c +4 -2
diff -r b320cfe1f10f tools/libfsimage/ufs/fsys_ufs.c
@@ -32,8 +32,9 @@
 #define SUPERBLOCK ((struct fs *)(FSYS_BUF + 0x2000))
 #define	INODE ((struct icommon *)(FSYS_BUF + 0x1000))
 #define DIRENT (FSYS_BUF + 0x4000)
+#define MAXBSIZE ((FSYS_BUFLEN - 0x4000) / 2)
 #define INDIRBLK1 ((grub_daddr32_t *)(FSYS_BUF + 0x4000)) /* 2+ indir blk */
-#define	INDIRBLK0 ((grub_daddr32_t *)(FSYS_BUF+ 0x6000))  /* 1st indirect blk */
+#define	INDIRBLK0 ((grub_daddr32_t *)(FSYS_BUF+ 0x4000 + MAXBSIZE))  /* 1st indirect blk */
 
 #define	indirblk0 (*fsig_int1(ffi))
 #define	indirblk1 (*fsig_int2(ffi))
@@ -48,7 +49,8 @@ ufs_mount(fsi_file_t *ffi, const char *o
 {
 	if (/*! IS_PC_SLICE_TYPE_SOLARIS(current_slice) || */
 	    !devread(ffi, UFS_SBLOCK, 0, UFS_SBSIZE, (char *)SUPERBLOCK) ||
-	    SUPERBLOCK->fs_magic != UFS_MAGIC)
+	    SUPERBLOCK->fs_magic != UFS_MAGIC ||
+	    MAXBSIZE < SUPERBLOCK->fs_bsize)
 		return 0;
 
 	return 1;

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw

tools/libfsimage/ufs/fsys_ufs.c line 37

Quoted 10 lines · Christoph Egger

Attached patch makes pygrub work on ufs.

tools/libfsimage/ufs/fsys_ufs.c +2 -1
@@ -32,8 +32,9 @@
 #define SUPERBLOCK ((struct fs *)(FSYS_BUF + 0x2000))
 #define	INODE ((struct icommon *)(FSYS_BUF + 0x1000))
 #define DIRENT (FSYS_BUF + 0x4000)
+#define MAXBSIZE ((FSYS_BUFLEN - 0x4000) / 2)
 #define INDIRBLK1 ((grub_daddr32_t *)(FSYS_BUF + 0x4000)) /* 2+ indir blk */
-#define	INDIRBLK0 ((grub_daddr32_t *)(FSYS_BUF+ 0x6000))  /* 1st indirect blk */
+#define	INDIRBLK0 ((grub_daddr32_t *)(FSYS_BUF+ 0x4000 + MAXBSIZE))  /* 1st indirect blk */

This is a no-op, right? I'm not sure why you made this change?

tools/libfsimage/ufs/fsys_ufs.c ufs_mount(fsi_file_t *ffi, const char *o · line 54

Quoted 10 lines
tools/libfsimage/ufs/fsys_ufs.c +2 -1
 #define	indirblk0 (*fsig_int1(ffi))
 #define	indirblk1 (*fsig_int2(ffi))
@@ -48,7 +49,8 @@ ufs_mount(fsi_file_t *ffi, const char *o
 {
 	if (/*! IS_PC_SLICE_TYPE_SOLARIS(current_slice) || */
 	    !devread(ffi, UFS_SBLOCK, 0, UFS_SBSIZE, (char *)SUPERBLOCK) ||
-	    SUPERBLOCK->fs_magic != UFS_MAGIC)
+	    SUPERBLOCK->fs_magic != UFS_MAGIC ||
+	    MAXBSIZE < SUPERBLOCK->fs_bsize)
 		return 0;

And all this does is make the mount checks stricter?

regards
john

#2 lore raw
Quoted 9 lines · On Monday 09 June 2008 17:50:33 John Levon wrote:

tools/libfsimage/ufs/fsys_ufs.c line 36

Quoted 8 lines · Christoph Egger

Attached patch makes pygrub work on ufs.

tools/libfsimage/ufs/fsys_ufs.c +1 -0
@@ -32,8 +32,9 @@
 #define SUPERBLOCK ((struct fs *)(FSYS_BUF + 0x2000))
 #define	INODE ((struct icommon *)(FSYS_BUF + 0x1000))
 #define DIRENT (FSYS_BUF + 0x4000)
+#define MAXBSIZE ((FSYS_BUFLEN - 0x4000) / 2)
 #define INDIRBLK1 ((grub_daddr32_t *)(FSYS_BUF + 0x4000)) /* 2+ indirblk 

*/

Quoted 1 line

Review line 37

Quoted 1 line
(quoted diff) +0 -0
 -#define	INDIRBLK0 ((grub_daddr32_t *)(FSYS_BUF+ 0x6000))  /* 1st 

indirect blk */

Quoted 1 line

Review line 38

Quoted 1 line
(quoted diff) +1 -0
+#define	INDIRBLK0 ((grub_daddr32_t *)(FSYS_BUF+ 0x4000 + MAXBSIZE))  /* 

1st indirect blk */

Quoted 2 lines

This is a no-op, right?

No, FSYS_BUFLEN is used now which wasn't before.

Quoted 1 line

I'm not sure why you made this change?

It deals with differences between UFS implementations such as FFSv1 and FFSv2.

Quoted 4 lines
Quoted 4 lines
tools/libfsimage/ufs/fsys_ufs.c +0 -0
 #define	indirblk0 (*fsig_int1(ffi))
 #define	indirblk1 (*fsig_int2(ffi))
@@ -48,7 +49,8 @@ ufs_mount(fsi_file_t *ffi, const char *o
 {
Quoted 8 lines

tools/libfsimage/ufs/fsys_ufs.c ufs_mount(fsi_file_t *ffi, const char *o · line 54

Quoted 6 lines
tools/libfsimage/ufs/fsys_ufs.c +2 -1
 	if (/*! IS_PC_SLICE_TYPE_SOLARIS(current_slice) || */
 	    !devread(ffi, UFS_SBLOCK, 0, UFS_SBSIZE, (char *)SUPERBLOCK) ||
-	    SUPERBLOCK->fs_magic != UFS_MAGIC)
+	    SUPERBLOCK->fs_magic != UFS_MAGIC ||
+	    MAXBSIZE < SUPERBLOCK->fs_bsize)
 		return 0;

And all this does is make the mount checks stricter?

Right.

Christoph

Signature · 12 lines
AMD Saxony, Dresden, Germany
Operating System Research Center

Legal Information:
AMD Saxony Limited Liability Company & Co. KG
Sitz (Geschäftsanschrift):
   Wilschdorfer Landstr. 101, 01109 Dresden, Deutschland
Registergericht Dresden: HRA 4896
vertretungsberechtigter Komplementär:
   AMD Saxony LLC (Sitz Wilmington, Delaware, USA)
Geschäftsführer der AMD Saxony LLC:
   Dr. Hans-R. Deppe, Thomas McCoy
#3 lore raw
Quoted 7 lines · Christoph Egger
Quoted 6 lines

tools/libfsimage/ufs/fsys_ufs.c line 36

Quoted 6 lines
tools/libfsimage/ufs/fsys_ufs.c +1 -0
@@ -32,8 +32,9 @@
 #define SUPERBLOCK ((struct fs *)(FSYS_BUF + 0x2000))
 #define	INODE ((struct icommon *)(FSYS_BUF + 0x1000))
 #define DIRENT (FSYS_BUF + 0x4000)
+#define MAXBSIZE ((FSYS_BUFLEN - 0x4000) / 2)
 #define INDIRBLK1 ((grub_daddr32_t *)(FSYS_BUF + 0x4000)) /* 2+ indirblk 

*/

Quoted 8 lines
Quoted 1 line

Review line 37

Quoted 1 line
(quoted diff) +0 -0
 -#define	INDIRBLK0 ((grub_daddr32_t *)(FSYS_BUF+ 0x6000))  /* 1st 

indirect blk */

Quoted 1 line

Review line 38

Quoted 1 line
(quoted diff) +1 -0
+#define	INDIRBLK0 ((grub_daddr32_t *)(FSYS_BUF+ 0x4000 + MAXBSIZE))  /* 

1st indirect blk */

Quoted 2 lines

This is a no-op, right?

No, FSYS_BUFLEN is used now which wasn't before.

Ooops, I mis-read the value of FSYS_BUFLEN. So you need this because indirect blocks don't fit in the original space available?

regards
john

#4 lore raw
Quoted 18 lines · On Tuesday 10 June 2008 13:40:57 John Levon wrote:
Quoted 17 lines · Christoph Egger
Quoted 7 lines
Quoted 7 lines
tools/libfsimage/ufs/fsys_ufs.c +1 -0
@@ -32,8 +32,9 @@
 #define SUPERBLOCK ((struct fs *)(FSYS_BUF + 0x2000))
 #define	INODE ((struct icommon *)(FSYS_BUF + 0x1000))
 #define DIRENT (FSYS_BUF + 0x4000)
+#define MAXBSIZE ((FSYS_BUFLEN - 0x4000) / 2)
 #define INDIRBLK1 ((grub_daddr32_t *)(FSYS_BUF + 0x4000)) /* 2+

indirblk

*/

Quoted 1 line
Quoted 1 line

-#define INDIRBLK0 ((grub_daddr32_t *)(FSYS_BUF+ 0x6000)) /* 1st

indirect blk */

Quoted 2 lines
Quoted 2 lines

+#define INDIRBLK0 ((grub_daddr32_t *)(FSYS_BUF+ 0x4000 + MAXBSIZE))
/*

Quoted 8 lines
Quoted 5 lines

1st indirect blk */

Quoted 1 line

This is a no-op, right?

No, FSYS_BUFLEN is used now which wasn't before.

Ooops, I mis-read the value of FSYS_BUFLEN. So you need this because indirect blocks don't fit in the original space available?

Yes. Also to reach alternative/other superblocks. Just imagine, the guest crashed and the filesystem wasn't cleanly unmounted.

Christoph

Signature · 12 lines
AMD Saxony, Dresden, Germany
Operating System Research Center

Legal Information:
AMD Saxony Limited Liability Company & Co. KG
Sitz (Geschäftsanschrift):
   Wilschdorfer Landstr. 101, 01109 Dresden, Deutschland
Registergericht Dresden: HRA 4896
vertretungsberechtigter Komplementär:
   AMD Saxony LLC (Sitz Wilmington, Delaware, USA)
Geschäftsführer der AMD Saxony LLC:
   Dr. Hans-R. Deppe, Thomas McCoy