--- cramfs-1.1.orig/cramfsck.c +++ cramfs-1.1/cramfsck.c @@ -65,7 +65,8 @@ #define FSCK_LIBRARY 128 /* Shared library error */ #define PAD_SIZE 512 -#define PAGE_CACHE_SIZE (4096) + +#define PAGE_CACHE_SIZE page_size static const char *progname = "cramfsck"; @@ -92,9 +93,11 @@ static unsigned long read_buffer_block = ~0UL; /* Uncompressing data structures... */ -static char outbuffer[PAGE_CACHE_SIZE*2]; +static char *outbuffer; static z_stream stream; +static size_t page_size; + /* Prototypes */ static void expand_fs(char *, struct cramfs_inode *); #endif /* INCLUDE_FS_TESTS */ @@ -661,9 +664,15 @@ int start = 0; size_t length; + page_size = sysconf(_SC_PAGESIZE); + if (argc) progname = argv[0]; + outbuffer = malloc(page_size * 2); + if (!outbuffer) + die(FSCK_ERROR, 1, "failed to allocate outbuffer"); + /* command line options */ while ((c = getopt(argc, argv, "hx:v")) != EOF) { switch (c) { --- cramfs-1.1.orig/debian/changelog +++ cramfs-1.1/debian/changelog @@ -0,0 +1,84 @@ +cramfs (1.1-6ubuntu1) xenial; urgency=medium + + * Bump debhelper level to 5. + + -- Matthias Klose Tue, 05 Apr 2016 15:03:03 +0200 + +cramfs (1.1-6build4) quantal; urgency=low + + * Rebuild for new armel compiler default of ARMv5t. + + -- Colin Watson Mon, 01 Oct 2012 20:57:09 +0100 + +cramfs (1.1-6build3) lucid; urgency=low + + * rebuild rest of main for armel armv7/thumb2 optimization; + UbuntuSpec:mobile-lucid-arm-gcc-v7-thumb2 + + -- Alexander Sack Fri, 05 Mar 2010 04:06:32 +0100 + +cramfs (1.1-6build2) karmic; urgency=low + + * No-change rebuild to gain FORTIFY defaults. + + -- Kees Cook Sat, 09 May 2009 10:10:03 -0700 + +cramfs (1.1-6build1) gutsy; urgency=low + + * No-change upload to enable stack protector. + + -- Kees Cook Tue, 14 Aug 2007 11:02:43 -0700 + +cramfs (1.1-6) unstable; urgency=low + + * Setting maintainer to Debian Kernel Team + + -- Francesco Paolo Lovergine Wed, 23 Jun 2004 21:18:34 +0200 + +cramfs (1.1-5) unstable; urgency=low + + * Clarified partial write error. + * Build-depend on debhelper >= 3 (closes: #235934). + * Get page size from sysconf(3). + + -- Herbert Xu Wed, 3 Mar 2004 20:56:38 +1100 + +cramfs (1.1-4) unstable; urgency=low + + * Do make oldconfig in kernel tree. + * Hardcoded page size for ia64. + * Added mkcramfs option to set block size (dann frazier, closes: #166420). + * Documented options in mkcramfs manual page (closes: #166417). + + -- Herbert Xu Sun, 27 Oct 2002 19:31:25 +1100 + +cramfs (1.1-3) unstable; urgency=low + + * Ignore errors with make symlinks. + * Fixed some 32-isms in mkcramfs. + + -- Herbert Xu Wed, 27 Feb 2002 19:05:08 +1100 + +cramfs (1.1-2) unstable; urgency=low + + * Fall back to 4096 if get_page_cache_size fails (closes: #135644). + + -- Herbert Xu Tue, 26 Feb 2002 19:42:50 +1100 + +cramfs (1.1-1) unstable; urgency=low + + * New upstream release. + * Depend on kernel-source-2.4.17 explicitly (closes: #135644). + + -- Herbert Xu Mon, 25 Feb 2002 21:00:33 +1100 + +cramfs (1.0-1) unstable; urgency=low + + * Initial release. + * Merged the following patches from kernel-source: + - Work around tmpfs symlink size bug in mkcramfs. + - Use the real PAGE_CACHE_SIZE in mkcramfs/cramfsck. + * Added missing stdarg.h inclusion to cramfsck.c. + + -- Herbert Xu Fri, 22 Feb 2002 21:11:25 +1100 + --- cramfs-1.1.orig/debian/compat +++ cramfs-1.1/debian/compat @@ -0,0 +1 @@ +5 --- cramfs-1.1.orig/debian/control +++ cramfs-1.1/debian/control @@ -0,0 +1,23 @@ +Source: cramfs +Section: utils +Priority: optional +Maintainer: Debian kernel team +Uploaders: Francesco Paolo Lovergine +Standards-Version: 3.6.1 +Build-Depends: debhelper (>= 3), libz-dev + +Package: cramfsprogs +Architecture: any +Depends: ${shlibs:Depends} +Replaces: mkcramfs +Conflicts: mkcramfs +Provides: mkcramfs +Section: utils +Priority: optional +Description: Tools for CramFs (Compressed ROM File System) + This package contains tools that let you construct a CramFs + (Compressed ROM File System) image from the contents of a given directory, as + well as checking a constructed CramFs image and extracting its contents. + . + Cram file systems are used for Debian INITRD images. + --- cramfs-1.1.orig/debian/copyright +++ cramfs-1.1/debian/copyright @@ -0,0 +1,12 @@ +cramfs was packaged by Herbert Xu on +Fri, 22 Feb 2002 21:26:10 +1100. + +It was downloaded from http://sourceforge.net/projects/cramfs/. + +Copyright: + +Copyright (c) 2000-2002 Transmeta Corporation + +The license can be found in /usr/share/common-licenses/GPL-2. + +$Id: copyright,v 1.1 2002/02/22 11:02:03 herbert Exp $ --- cramfs-1.1.orig/debian/cramfsck.8 +++ cramfs-1.1/debian/cramfsck.8 @@ -0,0 +1,46 @@ +.TH CRAMFSCK 8 "2002 January 1st" "KERNEL SOURCE" "Debian GNU/Linux Manual" +.SH NAME +cramfsck \- check a compressed ROM file system +.SH SYNOPSIS +.B cramfsck +.RB [ -hv ] +.RB [ -x +.IR dir ] +.I file +.SH DESCRIPTION +This manual page documents briefly the +.B cramfsck +command. +This manual page was written for the +.B Debian GNU/Linux +distribution (but may be used by others), because the original +program does not have a manual page. +.PP +.B cramfsck +checks the consistency of a +.B CramFs +file system given by +.IR file . +Unlike other file system checkers, it does not attempt to repair a broken +file system. This is not a deficiency as +.B CramFs +is not subject to the kind of corruption that a writable file system may +endure. +.PP +.B cramfsck +is also able to extract the contents of the file system. +.SH OPTIONS +.TP +.B -h +Give a brief help message. +.TP +.B -v +Turn on verbose mode. +.TP +.BI "-x " dir +In addition to checking the given file system, extract its contents into +.IR dir . +.SH AUTHOR +.B cramfsck +is written by Linus Torvalds and Daniel Quinlan. Manual page added by +Herbert Xu. --- cramfs-1.1.orig/debian/cramfsprogs.dirs +++ cramfs-1.1/debian/cramfsprogs.dirs @@ -0,0 +1,2 @@ +usr/sbin +usr/share/man/man8 --- cramfs-1.1.orig/debian/cramfsprogs.docs +++ cramfs-1.1/debian/cramfsprogs.docs @@ -0,0 +1,2 @@ +NOTES +README --- cramfs-1.1.orig/debian/mkcramfs.8 +++ cramfs-1.1/debian/mkcramfs.8 @@ -0,0 +1,81 @@ +.TH MKCRAMFS 8 "2001 February 22th" "KERNEL SOURCE" "Debian GNU/Linux Manual" +.SH NAME +mkcramfs \- make a compressed ROM file system + +.SH SYNOPSIS +.B mkcramfs +.RB [ -h ] +.RB [ -b +.IR blksize ] +.RB [ -e +.IR edition ] +.RB [ -i +.IR file ] +.RB [ -n +.IR name ] +.I dirname outfile + +.SH "DESCRIPTION" +This manual page documents briefly the +.B mkcramfs +command. +This manual page was written for the +.B Debian GNU/Linux +distribution (but may be used by others), because the original +program does not have a manual page. +.PP +.B mkcramfs +constructs a +.B CramFs +from the contents of +.IR dirname . +The image of the resulting file system is placed in +.IR outfile . + +.SH OPTIONS +.TP +.B -h +Give a brief help message. + +.TP +.B -E +Make all warnings errors (non-zero exit status). + +.TP +.B -b \fIblksize +Set the block size of the generated file system. + +.TP +.B -e \fIedition +Set the edition number (part of fsid). + +.TP +.B -i \fIfile +Insert a file image into the filesystem (requires Linux >= 2.4.0). + +.TP +.B -n \fIname +Set the name of the +.B CramFs +filesystem. + +.TP +.B -p +Pad by 512 bytes for boot code. + +.TP +.B -s +Sort directory entries (old option, ignored). + +.TP +.B -v +Turn on verbose mode. + +.TP +.B -z +Make explicit holes (requires Linux >= 2.3.39). + +.SH AUTHOR +.B mkcramfs +is written by Linus Torvalds and Daniel Quinlan. Manual page added by +Herbert Xu. --- cramfs-1.1.orig/debian/rules +++ cramfs-1.1/debian/rules @@ -0,0 +1,54 @@ +#!/usr/bin/make -f +# +# debian/rules for kernel-source. +# +# GNU copyright 1997 to 1999 by Joey Hess. +# Copyright (c) 1999-2002 Herbert Xu +# +# $Id: rules,v 1.6 2004/03/03 10:26:04 herbert Exp $ + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +build: + dh_testdir + + $(MAKE) CFLAGS="-g -O2 -Wall" + +clean: + dh_testdir + dh_testroot + + $(MAKE) clean + + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + cp cramfsck mkcramfs debian/cramfsprogs/usr/sbin + +# Build architecture-independent files here. +binary-indep: build install + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + dh_installdocs + dh_installman debian/*.8 + dh_installchangelogs + dh_strip + dh_compress + dh_fixperms + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install --- cramfs-1.1.orig/mkcramfs.c +++ cramfs-1.1/mkcramfs.c @@ -35,6 +35,7 @@ #include #include #include +#include /* Exit codes used by mkfs-type programs */ #define MKFS_OK 0 /* No errors */ @@ -44,9 +45,6 @@ /* The kernel only supports PAD_SIZE of 0 and 512. */ #define PAD_SIZE 512 -/* The kernel assumes PAGE_CACHE_SIZE as block size. */ -#define PAGE_CACHE_SIZE (4096) - /* * The longest filename component to allow for in the input directory tree. * ext2fs (and many others) allow up to 255 bytes. A couple of filesystems @@ -69,10 +67,10 @@ */ #define MAXFSLEN ((((1 << CRAMFS_OFFSET_WIDTH) - 1) << 2) /* offset */ \ + (1 << CRAMFS_SIZE_WIDTH) - 1 /* filesize */ \ - + (1 << CRAMFS_SIZE_WIDTH) * 4 / PAGE_CACHE_SIZE /* block pointers */ ) + + (1 << CRAMFS_SIZE_WIDTH) * 4 / blksize /* block pointers */ ) static const char *progname = "mkcramfs"; -static unsigned int blksize = PAGE_CACHE_SIZE; +static unsigned int blksize; static long total_blocks = 0, total_nodes = 1; /* pre-count the root node */ static int image_length = 0; @@ -123,9 +121,10 @@ { FILE *stream = status ? stderr : stdout; - fprintf(stream, "usage: %s [-h] [-e edition] [-i file] [-n name] dirname outfile\n" + fprintf(stream, "usage: %s [-h] [-b blksize] [-e edition] [-i file] [-n name] dirname outfile\n" " -h print this help\n" " -E make all warnings errors (non-zero exit status)\n" + " -b blksize blocksize to use\n" " -e edition set edition number (part of fsid)\n" " -i file insert a file image into the filesystem (requires >= 2.4.0)\n" " -n name set name of cramfs filesystem\n" @@ -335,14 +334,17 @@ } } } else if (S_ISLNK(st.st_mode)) { + int len; entry->uncompressed = malloc(entry->size); if (!entry->uncompressed) { die(MKFS_ERROR, 1, "malloc failed"); } - if (readlink(path, entry->uncompressed, entry->size) < 0) { + len = readlink(path, entry->uncompressed, entry->size); + if (len < 0) { warn_skip = 1; continue; } + entry->size = len; } else if (S_ISFIFO(st.st_mode) || S_ISSOCK(st.st_mode)) { /* maybe we should skip sockets */ entry->size = 0; @@ -693,19 +695,28 @@ int c; /* for getopt */ char *ep; /* for strtoul */ + blksize = sysconf(_SC_PAGESIZE); total_blocks = 0; if (argc) progname = argv[0]; /* command line options */ - while ((c = getopt(argc, argv, "hEe:i:n:psvz")) != EOF) { + while ((c = getopt(argc, argv, "hEb:e:i:n:psvz")) != EOF) { switch (c) { case 'h': usage(MKFS_OK); case 'E': opt_errors = 1; break; + case 'b': + errno = 0; + blksize = strtoul(optarg, &ep, 10); + if (errno || optarg[0] == '\0' || *ep != '\0') + usage(MKFS_USAGE); + if (blksize < 512 || (blksize & (blksize - 1))) + die(MKFS_ERROR, 0, "invalid blocksize: %u", blksize); + break; case 'e': errno = 0; opt_edition = strtoul(optarg, &ep, 10); @@ -768,8 +779,8 @@ if (fslen_ub > MAXFSLEN) { fprintf(stderr, - "warning: estimate of required size (upper bound) is %LdMB, but maximum image size is %uMB, we might die prematurely\n", - fslen_ub >> 20, + "warning: estimate of required size (upper bound) is %jdMB, but maximum image size is %uMB, we might die prematurely\n", + (intmax_t) (fslen_ub >> 20), MAXFSLEN >> 20); fslen_ub = MAXFSLEN; } @@ -807,18 +818,18 @@ } offset = write_directory_structure(root_entry->child, rom_image, offset); - printf("Directory data: %d bytes\n", offset); + printf("Directory data: %zd bytes\n", offset); offset = write_data(root_entry, rom_image, offset); /* We always write a multiple of blksize bytes, so that losetup works. */ offset = ((offset - 1) | (blksize - 1)) + 1; - printf("Everything: %d kilobytes\n", offset >> 10); + printf("Everything: %zd kilobytes\n", offset >> 10); /* Write the superblock now that we can fill in all of the fields. */ write_superblock(root_entry, rom_image+opt_pad, offset); - printf("Super block: %d bytes\n", sizeof(struct cramfs_super)); + printf("Super block: %zd bytes\n", sizeof(struct cramfs_super)); /* Put the checksum in. */ crc = crc32(0L, Z_NULL, 0); @@ -836,7 +847,7 @@ die(MKFS_ERROR, 1, "write failed"); } if (offset != written) { - die(MKFS_ERROR, 0, "ROM image write failed (wrote %d of %d bytes)", written, offset); + die(MKFS_ERROR, 0, "ROM image write failed (wrote %d of %d bytes): No space left on device?", written, offset); } /* (These warnings used to come at the start, but they scroll off the