File reiser-unpack of Package trustedgrub
Index: TrustedGRUB-1.1.3/stage2/filesys.h
===================================================================
--- TrustedGRUB-1.1.3.orig/stage2/filesys.h
+++ TrustedGRUB-1.1.3/stage2/filesys.h
@@ -82,6 +82,16 @@ int reiserfs_mount (void);
int reiserfs_read (char *buf, int len);
int reiserfs_dir (char *dirname);
int reiserfs_embed (int *start_sector, int needed_sectors);
+#if defined(__linux__) && defined (GRUB_UTIL)
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <sys/statfs.h>
+#include <fcntl.h>
+/* from <linux/reiserfs_fs.h> */
+#define REISERFS_SUPER_MAGIC 0x52654973
+#define REISERFS_IOC_UNPACK _IOW(0xCD,1,long)
+#endif
#else
#define FSYS_REISERFS_NUM 0
#endif
Index: TrustedGRUB-1.1.3/stage2/builtins.c
===================================================================
--- TrustedGRUB-1.1.3.orig/stage2/builtins.c
+++ TrustedGRUB-1.1.3/stage2/builtins.c
@@ -1879,9 +1879,23 @@ install_func (char *arg, int flags)
#ifdef GRUB_UTIL
else if (grub_memcmp ("--stage2=", arg, sizeof ("--stage2=") - 1) == 0)
{
+ int fd;
stage2_os_file = arg + sizeof ("--stage2=") - 1;
arg = skip_to (0, arg);
nul_terminate (stage2_os_file);
+
+#if defined(__linux__) && defined (FSYS_REISERFS)
+ if ((fd=open(stage2_os_file, O_RDONLY)) >= 0)
+ {
+ struct statfs buf;
+ /* see if the file sits on a reiserfs,
+ and try do defragment it if so. */
+ fstatfs(fd, &buf);
+ if (buf.f_type == REISERFS_SUPER_MAGIC)
+ ioctl (fd, REISERFS_IOC_UNPACK, 1);
+ }
+#endif /* __linux__ && FSYS_REISERFS */
+
}
#endif /* GRUB_UTIL */
else