WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] - pygrub/README provides information on packages needed

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] - pygrub/README provides information on packages needed to compile pygrub
From: BitKeeper Bot <riel@xxxxxxxxxxx>
Date: Wed, 25 May 2005 22:22:44 +0000
Delivery-date: Wed, 25 May 2005 23:01:35 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: Xen Development List <xen-devel@xxxxxxxxxxxxxxxxxxx>
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
ChangeSet 1.1559, 2005/05/25 23:22:44+01:00, kaf24@xxxxxxxxxxxxxxxxxxxx

        - pygrub/README provides information on packages needed to compile 
pygrub
        - support reiserfs {2,3} filesystem
        - dynamically build modules based on which filesystem libraries the
        system has (proposed by Jeremy)
        - pump up pygrub to version 0.2
        
        
        Signed-off-by: Jeremy Katz <katzj@xxxxxxxxxx>
        Signed-off-by: Nguyen Anh Quynh <aquynh@xxxxxxxxx>



 README                         |   16 +
 setup.py                       |   30 ++-
 src/fsys/reiser/__init__.py    |   39 ++++
 src/fsys/reiser/reisermodule.c |  345 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 420 insertions(+), 10 deletions(-)


diff -Nru a/tools/pygrub/README b/tools/pygrub/README
--- a/tools/pygrub/README       2005-05-25 19:02:16 -04:00
+++ b/tools/pygrub/README       2005-05-25 19:02:16 -04:00
@@ -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
+       - progreiserfs on Gentoo
+
diff -Nru a/tools/pygrub/setup.py b/tools/pygrub/setup.py
--- a/tools/pygrub/setup.py     2005-05-25 19:02:16 -04:00
+++ b/tools/pygrub/setup.py     2005-05-25 19:02:16 -04:00
@@ -3,14 +3,27 @@
 
 extra_compile_args  = [ "-fno-strict-aliasing", "-Wall", "-Werror" ]
 
-# in a perfect world, we'd figure out the fsys modules dynamically
-ext2 = Extension("grub.fsys.ext2._pyext2",
-                 extra_compile_args = extra_compile_args,
-                 libraries = ["ext2fs"],
-                 sources = ["src/fsys/ext2/ext2module.c"])
+fsys_mods = []
+fsys_pkgs = []
+
+if os.path.exists("/usr/include/ext2fs/ext2_fs.h"):
+    ext2 = Extension("grub.fsys.ext2._pyext2",
+                     extra_compile_args = extra_compile_args,
+                     libraries = ["ext2fs"],
+                     sources = ["src/fsys/ext2/ext2module.c"])
+    fsys_mods.append(ext2)
+    fsys_pkgs.append("grub.fsys.ext2")
+
+if os.path.exists("/usr/include/reiserfs/reiserfs.h"):
+    reiser = Extension("grub.fsys.reiser._pyreiser",
+                     extra_compile_args = extra_compile_args,
+                     libraries = ["reiserfs"],
+                     sources = ["src/fsys/reiser/reisermodule.c"])
+    fsys_mods.append(reiser)
+    fsys_pkgs.append("grub.fsys.reiser")
 
 setup(name='pygrub',
-      version='0.1',
+      version='0.2',
       description='Boot loader that looks a lot like grub for Xen',
       author='Jeremy Katz',
       author_email='katzj@xxxxxxxxxx',
@@ -18,8 +31,7 @@
       package_dir={'grub': 'src'},
       scripts = ["src/pygrub"],
       packages=['grub',
-                'grub.fsys',
-                'grub.fsys.ext2'],
-      ext_modules = [ext2]
+                'grub.fsys'].extend(fsys_pkgs),
+      ext_modules = fsys_mods
       )
                
diff -Nru a/tools/pygrub/src/fsys/reiser/__init__.py 
b/tools/pygrub/src/fsys/reiser/__init__.py
--- /dev/null   Wed Dec 31 16:00:00 196900
+++ b/tools/pygrub/src/fsys/reiser/__init__.py  2005-05-25 19:02:16 -04:00
@@ -0,0 +1,39 @@
+# 
+# Copyright (C) 2005 Nguyen Anh Quynh <aquynh@xxxxxxxxx>
+#
+# 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 a reiserfs filesystem"
+        return ReiserFs(fn)
+
+register_fstype(ReiserFileSystemType())
+
diff -Nru a/tools/pygrub/src/fsys/reiser/reisermodule.c 
b/tools/pygrub/src/fsys/reiser/reisermodule.c
--- /dev/null   Wed Dec 31 16:00:00 196900
+++ b/tools/pygrub/src/fsys/reiser/reisermodule.c       2005-05-25 19:02:16 
-04:00
@@ -0,0 +1,345 @@
+/*
+ * reisermodule.c - simple python binding for libreiserfs{2,3}
+ *
+ * Copyright (C) 2005 Nguyen Anh Quynh <aquynh@xxxxxxxxx>
+ *
+ * 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.
+ */
+
+#include <Python.h>
+
+#include <fcntl.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <dal/file_dal.h>
+#include <reiserfs/reiserfs.h>
+
+#if (PYTHON_API_VERSION >= 1011)
+#define PY_PAD 
0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L,0L
+#else
+#define PY_PAD 0L,0L,0L,0L
+#endif
+
+
+/* global error object */
+PyObject *ReiserError;
+
+typedef struct {
+    PyObject_HEAD
+    reiserfs_fs_t *fs;
+       dal_t *dal;
+} ReiserFs;
+
+typedef struct _ReiserFile ReiserFile;
+struct _ReiserFile {
+    PyObject_HEAD
+    reiserfs_file_t *file;
+};
+
+void file_dal_close(dal_t *dal) {
+
+       if (!dal) return;
+
+       close((int)dal->dev);
+       dal_free(dal);
+}
+
+/* reiser file object */
+
+static PyObject *
+reiser_file_close (ReiserFile *file, PyObject *args)
+{
+    if (file->file != NULL)
+       {
+        reiserfs_file_close(file->file);
+               file->file = NULL;
+       }
+    Py_INCREF(Py_None);
+    return Py_None;
+}
+
+static PyObject *
+reiser_file_read (ReiserFile *file, PyObject *args)
+{
+    int size = 0;
+    size_t n, total = 0;
+    PyObject * buffer = NULL;
+
+    if (file->file == NULL) {
+        PyErr_SetString(PyExc_ValueError, "Cannot read from closed file");
+        return NULL;
+    }
+
+    if (!PyArg_ParseTuple(args, "|i", &size))
+        return NULL;
+
+    buffer = PyString_FromStringAndSize((char *) NULL, (size) ? size : 4096);
+    if (buffer == NULL)
+        return buffer;
+ 
+    while (1) {
+        n = reiserfs_file_read(file->file, PyString_AS_STRING(buffer) + total, 
+                               (size) ? size : 4096);
+        if (n == 0)
+            break;
+
+        total += n;
+
+        if (size && size == total)
+            break;
+
+        if (!size) {
+            _PyString_Resize(&buffer, total + 4096);
+        }
+    }
+
+    _PyString_Resize(&buffer, total);
+    return buffer;
+}
+
+static void
+reiser_file_dealloc (ReiserFile * file)
+{
+    if (file->file != NULL) {
+        reiserfs_file_close(file->file);
+               file->file = NULL;
+       }
+       PyObject_DEL(file);
+}
+
+static struct PyMethodDef ReiserFileMethods[] = {
+       { "close", (PyCFunction) reiser_file_close, METH_VARARGS, NULL },
+       { "read", (PyCFunction) reiser_file_read, METH_VARARGS, NULL },
+       { NULL, NULL, 0, NULL } 
+};
+
+static PyObject *
+reiser_file_getattr (ReiserFile * file, char * name)
+{
+       return Py_FindMethod (ReiserFileMethods, (PyObject *) file, name);
+}
+
+static char ReiserFileType__doc__[] = "This is the reiser filesystem object";
+PyTypeObject ReiserFileType = {
+       PyObject_HEAD_INIT(&PyType_Type)
+       0,                              /* ob_size */
+       "ReiserFile",                   /* tp_name */
+       sizeof(ReiserFile),             /* tp_size */
+       0,                              /* tp_itemsize */

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] - pygrub/README provides information on packages needed to compile pygrub, BitKeeper Bot <=