Skip to contentSkip to conversation

reiserfs module for pygrub

PATCH In review aq 2 participants 2 messages May 18, 2005 – May 23, 2005

lore
Share & tools
lore

aq

author
#0 lore raw

PATCH 1/1 reiserfs module for pygrub

hello,

here is a patch to add reiserfs (version 2,3) support to pygrub in -unstable (against cset 1.1434)

list of changes:
- update tools/pygrub/README about packages needed to compile pygrub
- tools/pygrub/setup.py to support reiserfs module
- toolspygrub/src/fsys/reiserfs/ directory with 2 files __init__.py and reisermodule.c to provide reiserfs support to pygrub.

$ diffstat reiser_pygrub.patch 
 README                         |   16 +
 setup.py                       |   10 -
 src/fsys/reiser/__init__.py    |   39 ++++
 src/fsys/reiser/reisermodule.c |  345 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 407 insertions(+), 3 deletions(-)
Signature · 2 lines
regards,
aq

===== tools/pygrub/README 1.1 vs edited =====

tools/pygrub/README +15 -1
@@ -1 +1,15 @@
-Compiling this needs RPM e2fsprogs-devel installed.
\ No newline at end of file
+pygrub is a grub-like bootloader for xen. This tool is to use to boot domU images.
+
+To compile pygrub, you will need the following packages installed:
+
+1) Libraries of ext2fs, which is the following package (depend on your Linux distribution):
+	- e2fslibs-dev on Debian based distributions (Debian, Ubuntu, Linspire, Libranet, Xandros, etc...)
+	- e2fsprogs-devel on RedHat, Fedora Core
+	- libext2fs2-devel on Mandriva/Mandrake
+	- e2fsprogs on Gentoo
+
+2) Libraries of reiserfs, which is the following package (depend on your Linux distribution):
+	- libreiserfs-dev on Debian based distributions (Debian, Ubuntu, Xandros, Libranet, Xandros, etc...)
+	- progsreiserfs-devel on RedHat, Fedora Core
+	- progreiserfs on Gentoo
+

===== tools/pygrub/setup.py 1.2 vs edited =====

tools/pygrub/setup.py +8 -2
@@ -9,6 +9,11 @@ ext2 = Extension("grub.fsys.ext2._pyext2
                  libraries = ["ext2fs"],
                  sources = ["src/fsys/ext2/ext2module.c"])
 
+reiser = Extension("grub.fsys.reiser._pyreiser",
+                 extra_compile_args = extra_compile_args,
+                 libraries = ["reiserfs"],
+                 sources = ["src/fsys/reiser/reisermodule.c"])
+
 setup(name='pygrub',
       version='0.1',
       description='Boot loader that looks a lot like grub for Xen',
@@ -19,7 +24,8 @@ setup(name='pygrub',
       scripts = ["src/pygrub"],
       packages=['grub',
                 'grub.fsys',
-                'grub.fsys.ext2'],
-      ext_modules = [ext2]
+                'grub.fsys.ext2',
+                'grub.fsys.reiser'],
+      ext_modules = [ext2, reiser]
       )
                

===== tools/pygrub/src/fsys/reiser/__init__.py 1.1 vs edited =====

tools/pygrub/src/fsys/reiser/__init__.py +39 -0
@@ -0,0 +1,39 @@
+# 
+# Copyright (C) 2005 Nguyen Anh Quynh <[email protected]>
+#
+# This software may be freely redistributed under the terms of the GNU
+# general public license.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+
+from grub.fsys import register_fstype, FileSystemType
+from _pyreiser import *
+
+import os
+
+FSMAGIC2 = 'ReIsEr2'
+FSMAGIC3 = 'ReIsEr3'
+
+class ReiserFileSystemType(FileSystemType):
+    def __init__(self):
+        FileSystemType.__init__(self)
+        self.name = "reiser"
+
+    def sniff_magic(self, fn, offset = 0):
+        fd = os.open(fn, os.O_RDONLY)
+        os.lseek(fd, 0x10000, 0)
+        buf = os.read(fd, 0x40)
+        if len(buf) == 0x40 and (buf[0x34:0x3B] in [FSMAGIC2, FSMAGIC3]) :
+            return True
+        return False
+
+    def open_fs(self, fn, offset = 0):
+        if not self.sniff_magic(fn, offset):
+            raise ValueError, "Not an reiserfs filesystem"
+        return ReiserFs(fn)
+
+register_fstype(ReiserFileSystemType())
+

===== tools/pygrub/src/fsys/reiser/reisermodule.c 1.1 vs edited =====

tools/pygrub/src/fsys/reiser/reisermodule.c +345 -0

345 lines not on this page · raw message

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

#1 lore raw

(As I catch up on mail... sorry about the lag)

Quoted 2 lines · aq

here is a patch to add reiserfs (version 2,3) support to pygrub in -unstable (against cset 1.1434)

This looks good to me in general. I agree with Ian that we probably want to detect at build-time which filesystem libraries are available instead of requiring everyone building to install everything. See the patch that I have sitting ready to hit send on for how makes sense to me for libext2fs. Doing the same for reiserfs should be fairly trivial.

Jeremy