* Re: Grub segfaults when trying to access reiser4
2004-07-28 21:45 ` Stefan Schweizer
@ 2004-07-29 11:57 ` Vitaly Fertman
2004-07-29 13:51 ` Stefan Schweizer
0 siblings, 1 reply; 6+ messages in thread
From: Vitaly Fertman @ 2004-07-29 11:57 UTC (permalink / raw)
To: Stefan Schweizer, reiserfs-list
[-- Attachment #1: Type: text/plain, Size: 701 bytes --]
On Thursday 29 July 2004 01:45, Stefan Schweizer wrote:
> Thank you for this patch now I get a little bit nearer, I can see the
> content of directories but I cannot access more than one filesystem
> level (like list /usr/src) or access files. It always segfaults if I
> try to press tab.
>
> grub> kernel (hd0,9
> grub> kernel (hd0,0)/bin/
> Possible files are: [ arch awk basename bash bunzip2
>
> grub> kernel (hd0,0)/bin/bas
> Possible files are: basename bash
>
> grub> kernel (hd0,0)/bin/bas
> Possible files are: basename bash
>
> grub> kernel (hd0,0)/bin/bashSegfault
thy this improved patch (it includes the previous one)
and a bit modified grub patch please.
--
Thanks,
Vitaly Fertman
[-- Attachment #2: reiser4progs_alone.patch --]
[-- Type: text/x-diff, Size: 5052 bytes --]
The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 04/07/29 vitaly@digger.namesys.com 1.2336
# a bug in stand alone mode was fixed:
# - do not unload all nodes on tree_adjust -- there are locked ones.
# --------------------------------------------
# 04/07/29 vitaly@digger.namesys.com 1.2338
# - fixed the bug with initialization object pset on fs openning
# in the stand alone mod
# --------------------------------------------
#
diff -Nru a/include/reiser4/filesystem.h b/include/reiser4/filesystem.h
--- a/include/reiser4/filesystem.h Thu Jul 29 15:25:02 2004
+++ b/include/reiser4/filesystem.h Thu Jul 29 15:25:02 2004
@@ -12,7 +12,11 @@
extern errno_t reiser4_fs_root_key(reiser4_fs_t *fs, reiser4_key_t *key);
+#ifndef ENABLE_STAND_ALONE
extern reiser4_fs_t *reiser4_fs_open(aal_device_t *device, bool_t check);
+#else
+extern reiser4_fs_t *reiser4_fs_open(aal_device_t *device);
+#endif
#ifndef ENABLE_STAND_ALONE
diff -Nru a/include/reiser4/pset.h b/include/reiser4/pset.h
--- a/include/reiser4/pset.h Thu Jul 29 15:25:02 2004
+++ b/include/reiser4/pset.h Thu Jul 29 15:25:02 2004
@@ -12,12 +12,16 @@
extern void reiser4_opset_diff(reiser4_tree_t *tree, reiser4_opset_t *opset);
+extern errno_t reiser4_opset_init(reiser4_tree_t *tree, int check);
+
+#else
+
+extern errno_t reiser4_opset_init(reiser4_tree_t *tree);
+
#endif
extern errno_t reiser4_pset_init(reiser4_tree_t *tree);
extern reiser4_plug_t *reiser4_opset_plug(rid_t member, rid_t id);
-
-extern errno_t reiser4_opset_init(reiser4_tree_t *tree, int check);
#endif
diff -Nru a/libreiser4/filesystem.c b/libreiser4/filesystem.c
--- a/libreiser4/filesystem.c Thu Jul 29 15:25:02 2004
+++ b/libreiser4/filesystem.c Thu Jul 29 15:25:02 2004
@@ -6,14 +6,18 @@
#include <reiser4/libreiser4.h>
/* Opens filesystem on specified device */
-reiser4_fs_t *reiser4_fs_open(aal_device_t *device,
- bool_t check)
-{
+
+#ifndef ENABLE_STAND_ALONE
+reiser4_fs_t *reiser4_fs_open(aal_device_t *device, bool_t check) {
+#else
+reiser4_fs_t *reiser4_fs_open(aal_device_t *device) {
+#endif
+ reiser4_fs_t *fs;
+
#ifndef ENABLE_STAND_ALONE
count_t blocks;
uint32_t blksize;
#endif
- reiser4_fs_t *fs;
aal_assert("umka-148", device != NULL);
@@ -76,10 +80,15 @@
goto error_free_oid;
+#ifndef ENABLE_STAND_ALONE
if (check) {
if (reiser4_opset_init(fs->tree, check))
goto error_free_oid;
}
+#else
+ if (reiser4_opset_init(fs->tree))
+ goto error_free_oid;
+#endif
return fs;
diff -Nru a/libreiser4/pset.c b/libreiser4/pset.c
--- a/libreiser4/pset.c Thu Jul 29 15:25:02 2004
+++ b/libreiser4/pset.c Thu Jul 29 15:25:02 2004
@@ -343,7 +343,11 @@
return 0;
}
+#ifndef ENABLE_STAND_ALONE
errno_t reiser4_opset_init(reiser4_tree_t *tree, int check) {
+#else
+errno_t reiser4_opset_init(reiser4_tree_t *tree) {
+#endif
reiser4_object_t *object;
uint8_t i;
@@ -359,10 +363,11 @@
sizeof(reiser4_plug_t *) * OPSET_LAST);
reiser4_object_close(object);
-
+
+#ifndef ENABLE_STAND_ALONE
/* Check that all 'on-disk' plugins are obtained. */
for (i = 0; i < OPSET_STORE_LAST; i++) {
- /* If root is should not be checked (debugreiserfs),
+ /* If root should not be checked (debugreiserfs),
skip this loop. */
if (!check)
break;
@@ -374,7 +379,6 @@
}
}
-#ifndef ENABLE_STAND_ALONE
/* Set others from the profile. */
for (; i < OPSET_LAST; i++) {
if (!tree->ent.opset[i] && opset_prof[i].prof != INVAL_PID)
diff -Nru a/libreiser4/tree.c b/libreiser4/tree.c
--- a/libreiser4/tree.c Thu Jul 29 15:25:02 2004
+++ b/libreiser4/tree.c Thu Jul 29 15:25:02 2004
@@ -1280,13 +1280,17 @@
/* Allocating unallocated extent item at @place. */
return reiser4_tree_alloc_extent(tree, place);
}
+#endif
static errno_t cb_node_unload(reiser4_tree_t *tree, reiser4_node_t *node) {
+#ifndef ENABLE_STAND_ALONE
count_t free_blocks;
- /* Updating free space counter in format. */
+ /* Updating free space counter in format for the case some blocks were
+ allocated. */
free_blocks = reiser4_alloc_free(tree->fs->alloc);
reiser4_format_set_free(tree->fs->format, free_blocks);
+#endif
/* If node is locked, that is not a leaf or it is used by someone, it
cannot be released, and thus, it does not make the sense to save it
@@ -1294,16 +1298,17 @@
if (reiser4_node_locked(node))
return 0;
+#ifndef ENABLE_STAND_ALONE
/* Okay, node is fully allocated now and ready to be saved to device if
it is dirty. */
if (reiser4_node_isdirty(node) && reiser4_node_sync(node)) {
aal_error("Can't write node %llu.", node->block->nr);
return -EIO;
}
+#endif
/* Unloading node from tree cache. */
return reiser4_tree_unload_node(tree, node);
}
-#endif
/* Entry point for adjsuting tree routines. */
@@ -1325,7 +1330,7 @@
cb_node_unload);
#else
res = reiser4_tree_walk_node(tree, tree->root,
- reiser4_tree_unload_node);
+ cb_node_unload);
#endif
tree->adjusting = 0;
[-- Attachment #3: grub-0.94-reiser4-20040614.diff --]
[-- Type: text/x-diff, Size: 19989 bytes --]
diff -urN --exclude=Makefile.in --exclude=configure --exclude='*.info' --exclude='*.*~' --exclude='*.m4' ./grub-0.94.orig/config.h.in ./grub-0.94/config.h.in
--- ./grub-0.94.orig/config.h.in 2003-10-19 21:27:16.000000000 +0400
+++ ./grub-0.94/config.h.in 2004-01-27 11:32:07.000000000 +0300
@@ -50,6 +50,12 @@
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
+/* Define to 1 if you have the `aal-alone' library (-laal-alone). */
+#undef HAVE_LIBAAL_ALONE
+
+/* Define to 1 if you have the `reiser4-alone' library (-lreiser4-alone). */
+#undef HAVE_LIBREISER4_ALONE
+
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
diff -urN --exclude=Makefile.in --exclude=configure --exclude='*.info' --exclude='*.*~' --exclude='*.m4' ./grub-0.94.orig/configure.ac ./grub-0.94/configure.ac
--- ./grub-0.94.orig/configure.ac 2003-10-19 21:25:30.000000000 +0400
+++ ./grub-0.94/configure.ac 2004-01-27 14:22:54.000000000 +0300
@@ -241,6 +241,77 @@
FSYS_CFLAGS="$FSYS_CFLAGS -DFSYS_REISERFS=1"
fi
+dnl Checking for reiser4
+REISER4_LIBS=""
+REISER4_CFLAGS=""
+
+OLD_LIBS=$LIBS
+OLD_CFLAGS=$CFLAGS
+LIBS=""
+CFLAGS=""
+
+AC_ARG_ENABLE(reiser4,
+ [ --disable-reiser4 disable Reiser4 support in Stage 2])
+
+enable_reiser4_support=yes
+
+AC_CHECK_LIB(aal-alone, aal_mem_init, ,
+ AC_MSG_WARN(
+Reiser4 support is disabled due to inability find libaal-alone with
+memory manager support turned on.)
+ enable_reiser4_support=no
+)
+
+if test x"$enable_reiser4_support" != xno; then
+ AC_CHECK_HEADER(aal/libaal.h, ,
+ AC_MSG_WARN(
+Libaal header files are not found. Reiser4 support is disabled
+ )
+ enable_reiser4_support=no)
+fi
+
+if test x"$enable_reiser4_support" != xno; then
+ AC_CHECK_LIB(reiser4-alone, reiser4_fs_open, ,
+ AC_MSG_WARN(
+Reiser4 support is disabled due to inability find valid libreiser4-alone.)
+ enable_reiser4_support=no,
+ -laal-alone
+ )
+fi
+
+if test x"$enable_reiser4_support" != xno; then
+ AC_CHECK_HEADER(reiser4/libreiser4.h, ,
+ AC_MSG_WARN(
+Reiser4 header files are not found. Reiser4 support is disabled.
+ )
+ enable_reiser4_support=no)
+fi
+
+if test x"$enable_reiser4_support" != xno; then
+ REISER4_CFLAGS="$REISER4_CFLAGS -DFSYS_REISER4=1"
+ REISER4_LIBS=$LIBS
+fi
+
+if test x"$enable_reiser4_support" != xno; then
+ AC_CHECK_LIB(reiser4-alone, __sym40_plug_init,
+ REISER4_CFLAGS="$REISER4_CFLAGS -DENABLE_SYMLINKS=1",
+AC_MSG_WARN(Reiser4 symlinks support is disabled.),
+ -laal-alone
+ )
+fi
+
+LIBS=$OLD_LIBS
+CFLAGS=$OLD_CFLAGS
+
+if test x"$enable_reiser4" != xno; then
+ (test x"$enable_reiser4_support" != xno) &&
+ FSYS_CFLAGS="$FSYS_CFLAGS $REISER4_CFLAGS"
+fi
+
+AC_SUBST(REISER4_LIBS)
+AC_SUBST(REISER4_CFLAGS)
+AM_CONDITIONAL(ENABLE_REISER4_SUPPORT, test x"$enable_reiser4_support" != xno)
+
AC_ARG_ENABLE(vstafs,
[ --disable-vstafs disable VSTa FS support in Stage 2])
diff -urN --exclude=Makefile.in --exclude=configure --exclude='*.info' --exclude='*.*~' --exclude='*.m4' ./grub-0.94.orig/docs/grub.texi ./grub-0.94/docs/grub.texi
--- ./grub-0.94.orig/docs/grub.texi 2004-01-25 18:39:14.000000000 +0300
+++ ./grub-0.94/docs/grub.texi 2004-01-27 11:29:54.000000000 +0300
@@ -277,7 +277,7 @@
Support multiple filesystem types transparently, plus a useful explicit
blocklist notation. The currently supported filesystem types are
@dfn{BSD FFS}, @dfn{DOS FAT16 and FAT32}, @dfn{Minix fs}, @dfn{Linux
-ext2fs}, @dfn{ReiserFS}, @dfn{JFS}, @dfn{XFS}, and @dfn{VSTa
+ext2fs}, @dfn{ReiserFS}, @dfn{Reiser4}, @dfn{JFS}, @dfn{XFS}, and @dfn{VSTa
fs}. @xref{Filesystem}, for more information.
@item Support automatic decompression
@@ -1528,6 +1528,7 @@
@itemx jfs_stage1_5
@itemx minix_stage1_5
@itemx reiserfs_stage1_5
+@itemx reiser4_stage1_5
@itemx vstafs_stage1_5
@itemx xfs_stage1_5
diff -urN --exclude=Makefile.in --exclude=configure --exclude='*.info' --exclude='*.*~' --exclude='*.m4' ./grub-0.94.orig/grub/Makefile.am ./grub-0.94/grub/Makefile.am
--- ./grub-0.94.orig/grub/Makefile.am 2004-01-18 22:34:24.000000000 +0300
+++ ./grub-0.94/grub/Makefile.am 2004-01-27 16:15:50.314761912 +0300
@@ -14,4 +14,4 @@
AM_CFLAGS = $(GRUB_CFLAGS) -fwritable-strings
grub_SOURCES = main.c asmstub.c
-grub_LDADD = ../stage2/libgrub.a ../lib/libcommon.a $(GRUB_LIBS)
+grub_LDADD = ../stage2/libgrub.a ../lib/libcommon.a $(GRUB_LIBS) $(REISER4_LIBS)
diff -urN --exclude=Makefile.in --exclude=configure --exclude='*.info' --exclude='*.*~' --exclude='*.m4' ./grub-0.94.orig/INSTALL ./grub-0.94/INSTALL
--- ./grub-0.94.orig/INSTALL 2003-10-19 21:15:45.000000000 +0400
+++ ./grub-0.94/INSTALL 2004-01-27 11:25:00.000000000 +0300
@@ -207,6 +207,9 @@
`--disable-reiserfs'
Omit the ReiserFS support in Stage 2.
+`--disable-reiser4'
+ Omit the Reiser4 support in Stage 2.
+
`--disable-vstafs'
Omit the VSTa filesystem support in Stage 2.
diff -urN --exclude=Makefile.in --exclude=configure --exclude='*.info' --exclude='*.*~' --exclude='*.m4' ./grub-0.94.orig/stage2/builtins.c ./grub-0.94/stage2/builtins.c
--- ./grub-0.94.orig/stage2/builtins.c 2004-01-11 12:39:22.000000000 +0300
+++ ./grub-0.94/stage2/builtins.c 2004-01-27 11:27:38.000000000 +0300
@@ -3751,6 +3751,7 @@
{"jfs", "/jfs_stage1_5"},
{"minix", "/minix_stage1_5"},
{"reiserfs", "/reiserfs_stage1_5"},
+ {"reiser4", "/reiser4_stage1_5"},
{"vstafs", "/vstafs_stage1_5"},
{"xfs", "/xfs_stage1_5"}
};
diff -urN --exclude=Makefile.in --exclude=configure --exclude='*.info' --exclude='*.*~' --exclude='*.m4' ./grub-0.94.orig/stage2/disk_io.c ./grub-0.94/stage2/disk_io.c
--- ./grub-0.94.orig/stage2/disk_io.c 2003-10-19 19:58:03.000000000 +0400
+++ ./grub-0.94/stage2/disk_io.c 2004-01-27 12:33:21.000000000 +0300
@@ -63,6 +63,9 @@
# ifdef FSYS_REISERFS
{"reiserfs", reiserfs_mount, reiserfs_read, reiserfs_dir, 0, reiserfs_embed},
# endif
+# ifdef FSYS_REISER4
+ {"reiser4", reiser4_mount, reiser4_read, reiser4_dir, 0, reiser4_embed},
+# endif
# ifdef FSYS_VSTAFS
{"vstafs", vstafs_mount, vstafs_read, vstafs_dir, 0, 0},
# endif
diff -urN --exclude=Makefile.in --exclude=configure --exclude='*.info' --exclude='*.*~' --exclude='*.m4' ./grub-0.94.orig/stage2/filesys.h ./grub-0.94/stage2/filesys.h
--- ./grub-0.94.orig/stage2/filesys.h 2003-07-09 15:45:52.000000000 +0400
+++ ./grub-0.94/stage2/filesys.h 2004-01-27 12:29:44.000000000 +0300
@@ -67,6 +67,16 @@
#define FSYS_REISERFS_NUM 0
#endif
+#ifdef FSYS_REISER4
+#define FSYS_REISER4_NUM 1
+int reiser4_mount (void);
+int reiser4_read (char *buf, int len);
+int reiser4_dir (char *dirname);
+int reiser4_embed (int *start_sector, int needed_sectors);
+#else
+#define FSYS_REISER4_NUM 0
+#endif
+
#ifdef FSYS_VSTAFS
#define FSYS_VSTAFS_NUM 1
int vstafs_mount (void);
@@ -108,8 +118,8 @@
#ifndef NUM_FSYS
#define NUM_FSYS \
(FSYS_FFS_NUM + FSYS_FAT_NUM + FSYS_EXT2FS_NUM + FSYS_MINIX_NUM \
- + FSYS_REISERFS_NUM + FSYS_VSTAFS_NUM + FSYS_JFS_NUM + FSYS_XFS_NUM \
- + FSYS_TFTP_NUM)
+ + FSYS_REISERFS_NUM + FSYS_REISER4_NUM + FSYS_VSTAFS_NUM + FSYS_JFS_NUM \
+ + FSYS_XFS_NUM + FSYS_TFTP_NUM)
#endif
/* defines for the block filesystem info area */
diff -urN --exclude=Makefile.in --exclude=configure --exclude='*.info' --exclude='*.*~' --exclude='*.m4' ./grub-0.94.orig/stage2/fsys_reiser4.c ./grub-0.94/stage2/fsys_reiser4.c
--- ./grub-0.94.orig/stage2/fsys_reiser4.c 1970-01-01 03:00:00.000000000 +0300
+++ ./grub-0.94/stage2/fsys_reiser4.c 2004-01-27 12:36:33.000000000 +0300
@@ -0,0 +1,260 @@
+/*
+ * fsys_reiser4.c -- reiser4 filesystem support.
+ * Copyright (C) 2001, 2002, 2003 Hans Reiser.
+ *
+ * GRUB -- GRand Unified Bootloader
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * 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.
+*/
+
+#ifdef FSYS_REISER4
+#include "shared.h"
+#include "filesys.h"
+
+#define ENABLE_STAND_ALONE
+#include <reiser4/libreiser4.h>
+
+static reiser4_fs_t *fs = NULL;
+static aal_device_t *dev = NULL;
+static reiser4_object_t *object = NULL;
+
+/* Read callback of grub specific device. It uses devread() for reading passed
+ @count of device blocks starting from @blk to passed @buff. */
+static errno_t grub_dev_read(aal_device_t *device,
+ void *buff, blk_t blk,
+ count_t count)
+{
+ unsigned int size;
+ unsigned int factor;
+ unsigned int sector;
+
+ /* Calculating actual sector and size in bytes to be read from
+ device. */
+ factor = device->blksize / SECTOR_SIZE;
+ sector = (unsigned int)blk << aal_log2(factor);
+ size = (unsigned int)count * (SECTOR_SIZE * factor);
+
+ /* Reading from the current device */
+ if (!devread(sector, 0, size, buff))
+ return -EIO;
+
+ return 0;
+}
+
+/* Length callback of grub device */
+static count_t grub_dev_len(aal_device_t *device) {
+ unsigned int factor;
+
+ /* Getting partition length in device blocks */
+ factor = device->blksize / SECTOR_SIZE;
+ return (part_length >> aal_log2(factor));
+}
+
+/*
+ Initializing grub device abstraction instance. It will use devread and friends
+ for providing needed functionality.
+*/
+struct aal_device_ops grub_dev_ops = {
+ .read = grub_dev_read,
+ .len = grub_dev_len
+};
+
+/* Initializes reiser4 */
+static int reiser4_init(void) {
+ extern aal_hash_table_t *plugins;
+
+ plugins = NULL;
+
+ /* Initializing memory manager */
+ aal_mem_init((void *)FSYS_BUF, FSYS_BUFLEN);
+
+ /* Initializing device abstraction on current device GRUB uses. */
+ if (!(dev = aal_device_open(&grub_dev_ops, NULL,
+ SECTOR_SIZE, 0)))
+ {
+ return 0;
+ }
+
+ /* Initializing libreiser4 (plugins, etc) */
+ return !libreiser4_init();
+}
+
+#define MEMORY_WATERMARK 8192
+
+/* Memory pressure detect function. */
+static int mpressure_detect(reiser4_tree_t *tree) {
+ return (aal_mem_free() <= MEMORY_WATERMARK);
+}
+
+/* Reiser4 mount() routine */
+int reiser4_mount(void) {
+
+ /* Initialize all reiser4 related stuff first */
+ if (!reiser4_init())
+ return 0;
+
+ /* Open filesystem on @dev. */
+ if (!(fs = reiser4_fs_open(dev)))
+ return 0;
+
+ fs->tree->mpc_func = mpressure_detect;
+
+ object = NULL;
+ return 1;
+}
+
+/* Reiser4 read() handler */
+int reiser4_read(char *buf, int len) {
+ int64_t read;
+
+ if (object == NULL)
+ return 0;
+
+ /* Seet at current position denoted by @filepos */
+ if (objplug(object)->o.object_ops->seek) {
+ plug_call(objplug(object)->o.object_ops,
+ seek, object->ent, filepos);
+ }
+
+ /* Reading current file data starting from @filepos */
+ disk_read_func = disk_read_hook;
+ read = objplug(object)->o.object_ops->read ?
+ plug_call(objplug(object)->o.object_ops, read,
+ object->ent, buf, len) : -EINVAL;
+ disk_read_func = NULL;
+
+ if (read < 0) {
+ errnum = ERR_FSYS_CORRUPT;
+ return 0;
+ }
+
+ filepos += read;
+ return read;
+}
+
+/* Reiser4 file open() routine */
+int reiser4_dir(char *dirname) {
+ char *ch;
+
+ if (fs == NULL)
+ return 0;
+
+ if (object != NULL) {
+ plug_call(objplug(object)->o.object_ops,
+ close, object->ent);
+ aal_free(object);
+ object = NULL;
+ }
+
+ /* Cutting out string after first space character */
+ if ((ch = aal_strchr(dirname, ' ')))
+ *ch = '\0';
+
+ /* This function is also called for getting directory list for
+ maintaining the bash-like completion. */
+#ifndef STAGE1_5
+ if (print_possibilities) {
+ char entry[256];
+ entry_hint_t entry_hint;
+
+ /* Getting last part of name (jsut after last '/') */
+ if (*(dirname + aal_strlen(dirname) - 1) != '/') {
+
+ if (!(ch = aal_strrchr(dirname, '/'))) {
+ errnum = ERR_BAD_FILETYPE;
+ return 0;
+ }
+
+ aal_strncpy(entry, ch + 1, sizeof(entry));
+ *(ch + 1) = '\0';
+ } else {
+ aal_memset(entry, 0, sizeof(entry));
+ }
+
+ /* Open obejct by @dirname */
+ if (!(object = reiser4_semantic_open(fs->tree, dirname,
+ NULL, 1)))
+ {
+ errnum = ERR_FILE_NOT_FOUND;
+ return 0;
+ }
+
+ /* Checking if it is a directory object */
+ if (object->ent->opset.plug[OPSET_OBJ]->id.group != DIR_OBJECT)
+ {
+ /* If not, cutting out last '/' character */
+ if ((ch = aal_strrchr(dirname, '/')))
+ *ch = '\0';
+
+ /* Close current object */
+ plug_call(objplug(object)->o.object_ops,
+ close, object->ent);
+ aal_free(object);
+ return 0;
+ }
+
+ /* Reading the opened directory to build the completion list. */
+ if (objplug(object)->o.object_ops->readdir) {
+ while (plug_call(objplug(object)->o.object_ops, readdir,
+ object->ent, &entry_hint) > 0)
+ {
+ if (substring(entry, entry_hint.name) <= 0) {
+ if (print_possibilities > 0)
+ print_possibilities =
+ -print_possibilities;
+
+ print_a_completion(entry_hint.name);
+ }
+ }
+ }
+ } else {
+#endif
+ /* This is the case when resier4_dir() is called for open the
+ file @dirname, not for building completion list. */
+ if (!(object = reiser4_semantic_open(fs->tree, dirname,
+ NULL, 1)))
+ {
+ errnum = ERR_FILE_NOT_FOUND;
+ return 0;
+ }
+
+ if (object->ent->opset.plug[OPSET_OBJ]->id.group != REG_OBJECT)
+ {
+ errnum = ERR_BAD_FILETYPE;
+ return 0;
+ }
+
+ /* Initializing GRUB global variables @filepos and @filemax. */
+ filepos = 0;
+ filemax = reiser4_object_size(object);
+
+ return 1;
+#ifndef STAGE1_5
+ }
+
+ return 1;
+#endif
+
+ errnum = ERR_FILE_NOT_FOUND;
+ return 0;
+}
+
+/* Returns how many sectors may be used for embeding reiser4_stage1_5 in teh
+ case of installing GRUB to partition instead of MBR. */
+int reiser4_embed (int *start_sector, int needed_sectors) {
+ *start_sector = 1;
+ return needed_sectors <= ((REISER4_MASTER_OFFSET >> SECTOR_BITS) - 1);
+}
+#endif /* FSYS_REISER4 */
diff -urN --exclude=Makefile.in --exclude=configure --exclude='*.info' --exclude='*.*~' --exclude='*.m4' ./grub-0.94.orig/stage2/Makefile.am ./grub-0.94/stage2/Makefile.am
--- ./grub-0.94.orig/stage2/Makefile.am 2003-10-19 20:45:18.000000000 +0400
+++ ./grub-0.94/stage2/Makefile.am 2004-01-27 16:10:53.033955464 +0300
@@ -13,16 +13,24 @@
# For <stage1.h>.
INCLUDES = -I$(top_srcdir)/stage1
+if ENABLE_REISER4_SUPPORT
+REISER4_STAGE1_5 = reiser4_stage1_5
+REISER4_STAGE1_5_EXEC = reiser4_stage1_5.exec
+else
+REISER4_STAGE1_5 =
+REISER4_STAGE1_5_EXEC =
+endif
+
# The library for /sbin/grub.
noinst_LIBRARIES = libgrub.a
libgrub_a_SOURCES = boot.c builtins.c char_io.c cmdline.c common.c \
disk_io.c fsys_ext2fs.c fsys_fat.c fsys_ffs.c fsys_jfs.c \
- fsys_minix.c fsys_reiserfs.c fsys_vstafs.c fsys_xfs.c gunzip.c \
- md5.c serial.c stage2.c terminfo.c tparm.c
+ fsys_minix.c fsys_reiserfs.c fsys_reiser4.c fsys_vstafs.c \
+ fsys_xfs.c gunzip.c md5.c serial.c stage2.c terminfo.c tparm.c
libgrub_a_CFLAGS = $(GRUB_CFLAGS) -I$(top_srcdir)/lib \
-DGRUB_UTIL=1 -DFSYS_EXT2FS=1 -DFSYS_FAT=1 -DFSYS_FFS=1 \
- -DFSYS_JFS=1 -DFSYS_MINIX=1 -DFSYS_REISERFS=1 -DFSYS_VSTAFS=1 \
- -DFSYS_XFS=1 -DUSE_MD5_PASSWORDS=1 \
+ -DFSYS_JFS=1 -DFSYS_MINIX=1 -DFSYS_REISERFS=1 $(REISER4_CFLAGS) \
+ -DFSYS_VSTAFS=1 -DFSYS_XFS=1 -DUSE_MD5_PASSWORDS=1 \
-DSUPPORT_SERIAL=1 -DSUPPORT_HERCULES=1 -fwritable-strings
# Stage 2 and Stage 1.5's.
@@ -32,22 +40,22 @@
if DISKLESS_SUPPORT
pkgdata_DATA = stage2 e2fs_stage1_5 fat_stage1_5 ffs_stage1_5 \
- jfs_stage1_5 minix_stage1_5 reiserfs_stage1_5 vstafs_stage1_5 \
- xfs_stage1_5 nbgrub pxegrub
+ jfs_stage1_5 minix_stage1_5 reiserfs_stage1_5 $(REISER4_STAGE1_5) \
+ vstafs_stage1_5 xfs_stage1_5 nbgrub pxegrub
noinst_DATA = pre_stage2 start nbloader pxeloader diskless
noinst_PROGRAMS = pre_stage2.exec start.exec e2fs_stage1_5.exec \
fat_stage1_5.exec ffs_stage1_5.exec jfs_stage1_5.exec \
- minix_stage1_5.exec reiserfs_stage1_5.exec \
+ minix_stage1_5.exec reiserfs_stage1_5.exec $(REISER4_STAGE1_5_EXEC) \
vstafs_stage1_5.exec xfs_stage1_5.exec nbloader.exec \
pxeloader.exec diskless.exec
else
pkgdata_DATA = stage2 e2fs_stage1_5 fat_stage1_5 ffs_stage1_5 \
- jfs_stage1_5 minix_stage1_5 reiserfs_stage1_5 vstafs_stage1_5 \
- xfs_stage1_5
+ jfs_stage1_5 minix_stage1_5 reiserfs_stage1_5 $(REISER4_STAGE1_5) \
+ vstafs_stage1_5 xfs_stage1_5
noinst_DATA = pre_stage2 start
noinst_PROGRAMS = pre_stage2.exec start.exec e2fs_stage1_5.exec \
fat_stage1_5.exec ffs_stage1_5.exec jfs_stage1_5.exec \
- minix_stage1_5.exec reiserfs_stage1_5.exec \
+ minix_stage1_5.exec reiserfs_stage1_5.exec $(REISER4_STAGE1_5_EXEC) \
vstafs_stage1_5.exec xfs_stage1_5.exec
endif
MOSTLYCLEANFILES = $(noinst_PROGRAMS)
@@ -75,7 +83,7 @@
HERCULES_FLAGS =
endif
-STAGE2_COMPILE = $(STAGE2_CFLAGS) -fno-builtin -nostdinc \
+STAGE2_COMPILE = $(STAGE2_CFLAGS) -fno-builtin \
$(NETBOOT_FLAGS) $(SERIAL_FLAGS) $(HERCULES_FLAGS)
STAGE1_5_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,2000
@@ -85,14 +93,16 @@
pre_stage2_exec_SOURCES = asm.S bios.c boot.c builtins.c char_io.c \
cmdline.c common.c console.c disk_io.c fsys_ext2fs.c \
fsys_fat.c fsys_ffs.c fsys_jfs.c fsys_minix.c fsys_reiserfs.c \
- fsys_vstafs.c fsys_xfs.c gunzip.c hercules.c md5.c serial.c \
- smp-imps.c stage2.c terminfo.c tparm.c
+ fsys_reiser4.c fsys_vstafs.c fsys_xfs.c gunzip.c hercules.c \
+ md5.c serial.c smp-imps.c stage2.c terminfo.c tparm.c
pre_stage2_exec_CFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS)
pre_stage2_exec_CCASFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS)
pre_stage2_exec_LDFLAGS = $(PRE_STAGE2_LINK)
if NETBOOT_SUPPORT
-pre_stage2_exec_LDADD = ../netboot/libdrivers.a
+pre_stage2_exec_LDADD = ../netboot/libdrivers.a $(REISER4_LIBS)
+else
+pre_stage2_exec_LDADD = $(REISER4_LIBS)
endif
if DISKLESS_SUPPORT
@@ -167,6 +177,16 @@
-DNO_BLOCK_FILES=1
reiserfs_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK)
+# For reiser4_stage1_5 target.
+reiser4_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c \
+ disk_io.c stage1_5.c fsys_reiser4.c bios.c
+reiser4_stage1_5_exec_CFLAGS = $(STAGE1_5_COMPILE) $(REISER4_CFLAGS) \
+ -DNO_BLOCK_FILES=1
+reiser4_stage1_5_exec_CCASFLAGS = $(STAGE1_5_COMPILE) $(REISER4_CFLAGS) \
+ -DNO_BLOCK_FILES=1
+reiser4_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK)
+reiser4_stage1_5_exec_LDADD = $(REISER4_LIBS)
+
# For vstafs_stage1_5 target.
vstafs_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c \
disk_io.c stage1_5.c fsys_vstafs.c bios.c
diff -urN --exclude=Makefile.in --exclude=configure --exclude='*.info' --exclude='*.*~' --exclude='*.m4' ./grub-0.94.orig/stage2/shared.h ./grub-0.94/stage2/shared.h
--- ./grub-0.94.orig/stage2/shared.h 2004-01-11 12:39:22.000000000 +0300
+++ ./grub-0.94/stage2/shared.h 2004-01-27 11:41:39.000000000 +0300
@@ -202,9 +202,10 @@
#define STAGE2_ID_FAT_STAGE1_5 3
#define STAGE2_ID_MINIX_STAGE1_5 4
#define STAGE2_ID_REISERFS_STAGE1_5 5
-#define STAGE2_ID_VSTAFS_STAGE1_5 6
-#define STAGE2_ID_JFS_STAGE1_5 7
-#define STAGE2_ID_XFS_STAGE1_5 8
+#define STAGE2_ID_REISER4_STAGE1_5 6
+#define STAGE2_ID_VSTAFS_STAGE1_5 7
+#define STAGE2_ID_JFS_STAGE1_5 8
+#define STAGE2_ID_XFS_STAGE1_5 9
#ifndef STAGE1_5
# define STAGE2_ID STAGE2_ID_STAGE2
@@ -219,6 +220,8 @@
# define STAGE2_ID STAGE2_ID_MINIX_STAGE1_5
# elif defined(FSYS_REISERFS)
# define STAGE2_ID STAGE2_ID_REISERFS_STAGE1_5
+# elif defined(FSYS_REISER4)
+# define STAGE2_ID STAGE2_ID_REISER4_STAGE1_5
# elif defined(FSYS_VSTAFS)
# define STAGE2_ID STAGE2_ID_VSTAFS_STAGE1_5
# elif defined(FSYS_JFS)
^ permalink raw reply [flat|nested] 6+ messages in thread