⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cramfs.patch

📁 sm86xx rootfs来源包括补丁( GPL )的
💻 PATCH
📖 第 1 页 / 共 3 页
字号:
--- cramfs-1.1.orig/cramfsck.c	2002-02-22 17:00:42.000000000 -0700+++ cramfs-1.1/cramfsck.c	2002-12-21 01:25:17.000000000 -0700@@ -51,10 +51,11 @@ #include <utime.h> #include <sys/ioctl.h> #define _LINUX_STRING_H_-#include <linux/fs.h>-#include <linux/cramfs_fs.h>+#include "linux/cramfs_fs.h" #include <zlib.h> +#define BLKGETSIZE	_IO(0x12,96) /* return device size /512 (long *arg) */+ /* Exit codes used by fsck-type programs */ #define FSCK_OK          0	/* No errors */ #define FSCK_NONDESTRUCT 1	/* File system errors corrected */@@ -75,7 +76,7 @@ static int opt_verbose = 0;	/* 1 = verbose (-v), 2+ = very verbose (-vv) */ #ifdef INCLUDE_FS_TESTS static int opt_extract = 0;		/* extract cramfs (-x) */-static char *extract_dir = "root";	/* extraction directory (-x) */+static char *extract_dir = "/";	/* extraction directory (-x) */ static uid_t euid;			/* effective UID */  /* (cramfs_super + start) <= start_dir < end_dir <= start_data <= end_data */@@ -155,7 +156,7 @@ 	}  	if (*length < sizeof(struct cramfs_super)) {-		die(FSCK_UNCORRECTED, 0, "file length too short");+		die(FSCK_UNCORRECTED, 0, "filesystem smaller than a cramfs superblock!"); 	}  	/* find superblock */@@ -190,7 +191,8 @@ 			die(FSCK_UNCORRECTED, 0, "zero file count"); 		} 		if (*length < super.size) {-			die(FSCK_UNCORRECTED, 0, "file length too short");+			die(FSCK_UNCORRECTED, 0, "file length too short, %lu is smaller than %lu",+				*length, super.size); 		} 		else if (*length > super.size) { 			fprintf(stderr, "warning: file extends past end of filesystem\n");@@ -267,11 +269,11 @@ #ifdef INCLUDE_FS_TESTS static void print_node(char type, struct cramfs_inode *i, char *name) {-	char info[10];+	char info[11];  	if (S_ISCHR(i->mode) || (S_ISBLK(i->mode))) { 		/* major/minor numbers can be as high as 2^12 or 4096 */-		snprintf(info, 10, "%4d,%4d", major(i->size), minor(i->size));+		snprintf(info, 11, "%4d,%4d", major(i->size), minor(i->size)); 	} 	else { 		/* size be as high as 2^24 or 16777216 */@@ -445,8 +447,10 @@ 	} 	/* TODO: Do we need to check end_dir for empty case? */ 	memcpy(newpath, path, pathlen);-	newpath[pathlen] = '/';-	pathlen++;+	if (pathlen > 1) {+	    newpath[pathlen] = '/';+	    pathlen++;+	} 	if (opt_verbose) { 		print_node('d', i, path); 	}--- cramfs-1.1.orig/device_table.txt	1969-12-31 17:00:00.000000000 -0700+++ cramfs-1.1/device_table.txt	2003-01-01 05:13:44.000000000 -0700@@ -0,0 +1,129 @@+# When building a target filesystem, it is desirable to not have to+# become root and then run 'mknod' a thousand times.  Using a device +# table you can create device nodes and directories "on the fly".+#+# This is a sample device table file for use with mkcramfs.  You can+# do all sorts of interesting things with a device table file.  For+# example, if you want to adjust the permissions on a particular file+# you can just add an entry like:+#   /sbin/foobar	f	2755	0	0	-	-	-	-	-+# and (assuming the file /sbin/foobar exists) it will be made setuid+# root (regardless of what its permissions are on the host filesystem.+# Furthermore, you can use a single table entry to create a many device+# minors.  For example, if I wanted to create /dev/hda and /dev/hda[0-15]+# I could just use the following two table entries:+#   /dev/hda	b	640	0	0	3	0	0	0	-+#   /dev/hda	b	640	0	0	3	1	1	1	15+# +# Device table entries take the form of:+# <name>    <type>	<mode>	<uid>	<gid>	<major>	<minor>	<start>	<inc>	<count>+# where name is the file name,  type can be one of: +#	f	A regular file+#	d	Directory+#	c	Character special device file+#	b	Block special device file+#	p	Fifo (named pipe)+# uid is the user id for the target file, gid is the group id for the+# target file.  The rest of the entries (major, minor, etc) apply only +# to device special files.++# Have fun+# -Erik Andersen <andersen@codepoet.org>+#++#<name>		<type>	<mode>	<uid>	<gid>	<major>	<minor>	<start>	<inc>	<count>+/dev		d	755	0	0	-	-	-	-	-+/dev/mem	c	640	0	0	1	1	0	0	-+/dev/kmem	c	640	0	0	1	2	0	0	-+/dev/null	c	640	0	0	1	3	0	0	-+/dev/zero	c	640	0	0	1	5	0	0	-+/dev/random	c	640	0	0	1	8	0	0	-+/dev/urandom	c	640	0	0	1	9	0	0	-+/dev/tty	c	666	0	0	5	0	0	0	-+/dev/tty	c	666	0	0	4	0	0	1	6+/dev/console	c	640	0	0	5	1	0	0	-+/dev/ram	b	640	0	0	1	1	0	0	-+/dev/ram	b	640	0	0	1	0	0	1	4+/dev/loop	b	640	0	0	7	0	0	1	2+/dev/ptmx	c	666	0	0	5	2	0	0	-+#/dev/ttyS	c	640	0	0	4	64	0	1	4+#/dev/psaux	c	640	0	0	10	1	0	0	-+#/dev/rtc	c	640	0	0	10	135	0	0	-++# Adjust permissions on some normal files+#/etc/shadow	f	600	0	0	-	-	-	-	-+#/bin/tinylogin	f	4755	0	0	-	-	-	-	-++# User-mode Linux stuff+/dev/ubda	b	640	0	0	98	0	0	0	-+/dev/ubda	b	640	0	0	98	1	1	1	15++# IDE Devices+/dev/hda	b	640	0	0	3	0	0	0	-+/dev/hda	b	640	0	0	3	1	1	1	15+/dev/hdb	b	640	0	0	3	64	0	0	-+/dev/hdb	b	640	0	0	3	65	1	1	15+#/dev/hdc	b	640	0	0	22	0	0	0	-+#/dev/hdc	b	640	0	0	22	1	1	1	15+#/dev/hdd	b	640	0	0	22	64	0	0	-+#/dev/hdd	b	640	0	0	22	65	1	1	15+#/dev/hde	b	640	0	0	33	0	0	0	-+#/dev/hde	b	640	0	0	33	1	1	1	15+#/dev/hdf	b	640	0	0	33	64	0	0	-+#/dev/hdf	b	640	0	0	33	65	1	1	15+#/dev/hdg	b	640	0	0	34	0	0	0	-+#/dev/hdg	b	640	0	0	34	1	1	1	15+#/dev/hdh	b	640	0	0	34	64	0	0	-+#/dev/hdh	b	640	0	0	34	65	1	1	15++# SCSI Devices+#/dev/sda	b	640	0	0	8	0	0	0	-+#/dev/sda	b	640	0	0	8	1	1	1	15+#/dev/sdb	b	640	0	0	8	16	0	0	-+#/dev/sdb	b	640	0	0	8	17	1	1	15+#/dev/sdc	b	640	0	0	8	32	0	0	-+#/dev/sdc	b	640	0	0	8	33	1	1	15+#/dev/sdd	b	640	0	0	8	48	0	0	-+#/dev/sdd	b	640	0	0	8	49	1	1	15+#/dev/sde	b	640	0	0	8	64	0	0	-+#/dev/sde	b	640	0	0	8	65	1	1	15+#/dev/sdf	b	640	0	0	8	80	0	0	-+#/dev/sdf	b	640	0	0	8	81	1	1	15+#/dev/sdg	b	640	0	0	8	96	0	0	-+#/dev/sdg	b	640	0	0	8	97	1	1	15+#/dev/sdh	b	640	0	0	8	112	0	0	-+#/dev/sdh	b	640	0	0	8	113	1	1	15+#/dev/sg		c	640	0	0	21	0	0	1	15+#/dev/scd	b	640	0	0	11	0	0	1	15+#/dev/st		c	640	0	0	9	0	0	1	8+#/dev/nst	c	640	0	0	9	128	0	1	8+#/dev/st	c	640	0	0	9	32	1	1	4+#/dev/st	c	640	0	0	9	64	1	1	4+#/dev/st	c	640	0	0	9	96	1	1	4++# Floppy disk devices+#/dev/fd		b	640	0	0	2	0	0	1	2+#/dev/fd0d360	b	640	0	0	2	4	0	0	-+#/dev/fd1d360	b	640	0	0	2	5	0	0	-+#/dev/fd0h1200	b	640	0	0	2	8	0	0	-+#/dev/fd1h1200	b	640	0	0	2	9	0	0	-+#/dev/fd0u1440	b	640	0	0	2	28	0	0	-+#/dev/fd1u1440	b	640	0	0	2	29	0	0	-+#/dev/fd0u2880	b	640	0	0	2	32	0	0	-+#/dev/fd1u2880	b	640	0	0	2	33	0	0	-++# All the proprietary cdrom devices in the world+#/dev/aztcd	b	640	0	0	29	0	0	0	-+#/dev/bpcd	b	640	0	0	41	0	0	0	-+#/dev/capi20	c	640	0	0	68	0	0	1	2+#/dev/cdu31a	b	640	0	0	15	0	0	0	-+#/dev/cdu535	b	640	0	0	24	0	0	0	-+#/dev/cm206cd	b	640	0	0	32	0	0	0	-+#/dev/sjcd	b	640	0	0	18	0	0	0	-+#/dev/sonycd	b	640	0	0	15	0	0	0	-+#/dev/gscd	b	640	0	0	16	0	0	0	-+#/dev/sbpcd	b	640	0	0	25	0	0	0	-+#/dev/sbpcd	b	640	0	0	25	0	0	1	4+#/dev/mcd	b	640	0	0	23	0	0	0	-+#/dev/optcd	b	640	0	0	17	0	0	0	-+--- cramfs-1.1.orig/mkcramfs.c	2002-02-20 01:03:32.000000000 -0700+++ cramfs-1.1/mkcramfs.c	2002-12-21 01:25:17.000000000 -0700@@ -1,3 +1,4 @@+/* vi: set sw=8 ts=8: */ /*  * mkcramfs - make a cramfs file system  *@@ -16,12 +17,21 @@  * 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA+ *+ * Added device table support (code taken from mkfs.jffs2.c, credit to+ * Erik Andersen <andersen@codepoet.org>) as well as an option to squash+ * permissions. - Russ Dill <Russ.Dill@asu.edu> September 2002+ *+ * Reworked, cleaned up, and updated for cramfs-1.1, December 2002+ *  - Erik Andersen <andersen@codepoet.org>+ *  */  /*  * If you change the disk format of cramfs, please update fs/cramfs/README.  */ +#define _GNU_SOURCE #include <sys/types.h> #include <stdio.h> #include <sys/stat.h>@@ -33,8 +43,15 @@ #include <errno.h> #include <string.h> #include <stdarg.h>+#include <libgen.h>+#include <ctype.h>+#include <assert.h>+#include <getopt.h> #include <linux/cramfs_fs.h> #include <zlib.h>+#ifdef DMALLOC+#include <dmalloc.h>+#endif  /* Exit codes used by mkfs-type programs */ #define MKFS_OK          0	/* No errors */@@ -71,11 +88,17 @@ 		  + (1 << CRAMFS_SIZE_WIDTH) - 1 /* filesize */ \ 		  + (1 << CRAMFS_SIZE_WIDTH) * 4 / PAGE_CACHE_SIZE /* block pointers */ ) ++/* The kernel assumes PAGE_CACHE_SIZE as block size. */+#define PAGE_CACHE_SIZE (4096)++ static const char *progname = "mkcramfs"; static unsigned int blksize = PAGE_CACHE_SIZE; static long total_blocks = 0, total_nodes = 1; /* pre-count the root node */ static int image_length = 0; + /*  * If opt_holes is set, then mkcramfs can create explicit holes in the  * data, which saves 26 bytes per hole (which is a lot smaller a@@ -91,10 +114,12 @@ static int opt_holes = 0; static int opt_pad = 0; static int opt_verbose = 0;+static int opt_squash = 0; static char *opt_image = NULL; static char *opt_name = NULL;  static int warn_dev, warn_gid, warn_namelen, warn_skip, warn_size, warn_uid;+static const char *const memory_exhausted = "memory exhausted";  /* In-core version of inode / directory entry. */ struct entry {@@ -123,7 +148,7 @@ { 	FILE *stream = status ? stderr : stdout; -	fprintf(stream, "usage: %s [-h] [-e edition] [-i file] [-n name] dirname outfile\n"+	fprintf(stream, "usage: %s [-h] [-e edition] [-i file] [-n name] [-D file] dirname outfile\n" 		" -h         print this help\n" 		" -E         make all warnings errors (non-zero exit status)\n" 		" -e edition set edition number (part of fsid)\n"@@ -133,39 +158,157 @@ 		" -s         sort directory entries (old option, ignored)\n" 		" -v         be more verbose\n" 		" -z         make explicit holes (requires >= 2.3.39)\n"-		" dirname    root of the directory tree to be compressed\n"+		" -D         Use the named FILE as a device table file\n"+		" -q         squash permissions (make everything owned by root)\n"+		" dirname    root of the filesystem to be compressed\n" 		" outfile    output file\n", progname, PAD_SIZE);  	exit(status); } -static void die(int status, int syserr, const char *fmt, ...)+static void verror_msg(const char *s, va_list p)+{+	fflush(stdout);+	fprintf(stderr, "mkcramfs: ");+	vfprintf(stderr, s, p);+}++static void vperror_msg(const char *s, va_list p)+{+	int err = errno;++	if (s == 0)+		s = "";+	verror_msg(s, p);+	if (*s)+		s = ": ";+	fprintf(stderr, "%s%s\n", s, strerror(err));+}++static void perror_msg(const char *s, ...)+{+	va_list p;++	va_start(p, s);+	vperror_msg(s, p);+	va_end(p);+}++static void error_msg_and_die(const char *s, ...)+{+	va_list p;++	va_start(p, s);+	verror_msg(s, p);+	va_end(p);+	putc('\n', stderr);+	exit(MKFS_ERROR);+}++static void perror_msg_and_die(const char *s, ...)+{+	va_list p;++	va_start(p, s);+	vperror_msg(s, p);+	va_end(p);+	exit(MKFS_ERROR);+}+#ifndef DMALLOC+extern char *xstrdup(const char *s)+{+	char *t;++	if (s == NULL)+		return NULL;+	t = strdup(s);+	if (t == NULL)+		error_msg_and_die(memory_exhausted);+	return t;+}++extern void *xmalloc(size_t size)+{+	void *ptr = malloc(size);++	if (ptr == NULL && size != 0)+		error_msg_and_die(memory_exhausted);+	return ptr;+}++extern void *xcalloc(size_t nmemb, size_t size)+{+	void *ptr = calloc(nmemb, size);++	if (ptr == NULL && nmemb != 0 && size != 0)+		error_msg_and_die(memory_exhausted);+	return ptr;+}++extern void *xrealloc(void *ptr, size_t size)+{+	ptr = realloc(ptr, size);+	if (ptr == NULL && size != 0)+		error_msg_and_die(memory_exhausted);+	return ptr;+}+#endif++static FILE *xfopen(const char *path, const char *mode) {-	va_list arg_ptr;-	int save = errno;+	FILE *fp;++	if ((fp = fopen(path, mode)) == NULL)+		perror_msg_and_die("%s", path);+	return fp;+} -	fflush(0);-	va_start(arg_ptr, fmt);-	fprintf(stderr, "%s: ", progname);-	vfprintf(stderr, fmt, arg_ptr);-	if (syserr) {-		fprintf(stderr, ": %s", strerror(save));+extern int xopen(const char *pathname, int flags, mode_t mode)+{+	int ret;+	+	if (flags & O_CREAT)+		ret = open(pathname, flags, mode);+	else+		ret = open(pathname, flags);+	if (ret == -1) {+		perror_msg_and_die("%s", pathname); 	}-	fprintf(stderr, "\n");-	va_end(arg_ptr);-	exit(status);+	return ret; } 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -