[klibc] [git patch] klibc bzero, mount fixes + random stuff

maximilian attems max at stro.at
Fri Aug 24 16:31:24 PDT 2007


On Fri, 24 Aug 2007, H. Peter Anvin wrote:

> Please implement bzero() as memset(x, 0, y); instead of open-coding it
> as a zero loop.
> strcspn/strpbrk/strspn: use "" quotes for files in usr/klibc; but
> <string.h> comes from usr/include and should be in <>.

done.
 
> Also, I would appreciate it if you would add [klibc] to the checkin
> descriptions.

ok, rebased with aboves changes + another cpio cleanup, please pull
git pull git://brane.itp.tuwien.ac.at/~mattems/klibc.git maks

shortlog:
maximilian attems (10):
      [klibc] mount: add nodev, noexec and nosuid options
      [klibc] mount: add -n option
      [klibc] cpio: small cleanups
      [klibc] readlink: s/link/link_name/
      [klibc] kinit, mknod: s/(major|minor)/\1_num/
      [klibc] strcspn, strpbrk, strspn include string.h
      [klibc] resume, kill: axe unused envp usage
      [klibc] devname.c: include kinit.h
      [klibc] add bzero()
      [klibc] cpio: preprocessor cleanups

diffstat:
 usr/include/string.h      |    1 
 usr/kinit/devname.c       |    2 
 usr/kinit/do_mounts_md.c  |   18 +++----
 usr/kinit/name_to_dev.c   |   16 +++---
 usr/kinit/resume/resume.c |    2 
 usr/klibc/Kbuild          |    2 
 usr/klibc/bzero.c         |    6 ++
 usr/klibc/strcspn.c       |    2 
 usr/klibc/strpbrk.c       |    2 
 usr/klibc/strspn.c        |    2 
 usr/utils/cpio.c          |   89 ++++++++++--------------------------
 usr/utils/kill.c          |    2 
 usr/utils/mknod.c         |    8 +--
 usr/utils/mount_main.c    |    7 ++
 usr/utils/mount_opts.c    |    3 +
 usr/utils/readlink.c      |   10 ++--
 16 files changed, 79 insertions(+), 93 deletions(-)

thanks

-- 
maks

log:

commit 599d5ba480ec63bdd32d6d55a572e7a0ac6e08d4
Author: maximilian attems <max at stro.at>
Date:   Sat Aug 25 01:05:34 2007 +0200

    [klibc] cpio: preprocessor cleanups
    
    * kill useless macro FILE_SYSTEM_PREFIX_LEN
    * use symlink() directly
    * a compiler which doesn't support long long needs to be shot
      kick __GNUC__ protection around
    * remove compat defines against old stat.h
    
    Signed-off-by: maximilian attems <max at stro.at>

diff --git a/usr/utils/cpio.c b/usr/utils/cpio.c
index db626a3..8acfe6f 100644
--- a/usr/utils/cpio.c
+++ b/usr/utils/cpio.c
@@ -43,16 +43,6 @@
 #  define ISSLASH(C) ((C) == DIRECTORY_SEPARATOR)
 # endif
 
-# ifndef FILE_SYSTEM_PREFIX_LEN
-#  define FILE_SYSTEM_PREFIX_LEN(Filename) 0
-# endif
-
-#ifndef SYMLINK_USES_UMASK
-# define UMASKED_SYMLINK(name1,name2,mode)    symlink(name1,name2)
-#else
-# define UMASKED_SYMLINK(name1,name2,mode)    umasked_symlink(name1,name2,mode)
-#endif				/* SYMLINK_USES_UMASK */
-
 /* Return 1 if an array of N objects, each of size S, cannot exist due
    to size arithmetic overflow.  S must be positive and N must be
    nonnegative.  This is a macro, not an inline function, so that it
@@ -110,16 +100,10 @@ struct new_cpio_header {
 };
 
 /* Total number of bytes read and written for all files.  
-   Now that many tape drives hold more than 4Gb we need more than 32
-   bits to hold input_bytes and output_bytes.  But it's not worth
-   the trouble of adding special multi-precision arithmetic if the 
-   compiler doesn't support 64 bit ints since input_bytes and
-   output_bytes are only used to print the number of blocks copied.  */
-#ifdef __GNUC__
+ * Now that many tape drives hold more than 4Gb we need more than 32
+ *  bits to hold input_bytes and output_bytes.
+ */
 long long input_bytes, output_bytes;
-#else
-long input_bytes, output_bytes;
-#endif
 
 /* Allocate N bytes of memory dynamically, with error checking.  */
 
@@ -709,7 +693,7 @@ copyin_regular_file(struct new_cpio_header *file_hdr, int in_file_des)
 
 static char *base_name(char const *name)
 {
-	char const *base = name + FILE_SYSTEM_PREFIX_LEN(name);
+	char const *base = name;
 	char const *p;
 
 	for (p = base; *p; p++) {
@@ -856,9 +840,9 @@ static void copyin_link(struct new_cpio_header *file_hdr, int in_file_des)
 	tape_buffered_read(link_name, in_file_des, file_hdr->c_filesize);
 	tape_skip_padding(in_file_des, file_hdr->c_filesize);
 
-	res = UMASKED_SYMLINK(link_name, file_hdr->c_name, file_hdr->c_mode);
+	res = symlink(link_name, file_hdr->c_name);
 	if (res < 0) {
-		fprintf(stderr, "%s: UMASKED_SYMLINK %s: %s\n",
+		fprintf(stderr, "%s: symlink %s: %s\n",
 			progname, file_hdr->c_name, strerror(errno));
 		free(link_name);
 		return;
@@ -890,20 +874,14 @@ static void copyin_file(struct new_cpio_header *file_hdr, int in_file_des)
 
 	case S_IFCHR:
 	case S_IFBLK:
-#ifdef S_IFSOCK
 	case S_IFSOCK:
-#endif
-#ifdef S_IFIFO
 	case S_IFIFO:
-#endif
 		copyin_device(file_hdr);
 		break;
 
-#ifdef S_IFLNK
 	case S_IFLNK:
 		copyin_link(file_hdr, in_file_des);
 		break;
-#endif
 
 	default:
 		fprintf(stderr, "%s: %s: unknown file type\n",

commit 7db15307925a4f502b4e77b6942d144cb82092a1
Author: maximilian attems <max at stro.at>
Date:   Sat Aug 25 01:22:27 2007 +0200

    [klibc] add bzero()
    
    bzero() contra memset() saves an argument,
    which is about 4 bytes per call on x86.
    
    "In fact, one could argue for making memset() an inline function which
    collapses to bzero if the middle argument is zero." -hpa
    left for a later exercise.
    
    Signed-off-by: maximilian attems <max at stro.at>

diff --git a/usr/include/string.h b/usr/include/string.h
index 1a6072c..ae8270e 100644
--- a/usr/include/string.h
+++ b/usr/include/string.h
@@ -17,6 +17,7 @@ __extern void *memmove(void *, const void *, size_t);
 __extern void *memset(void *, int, size_t);
 __extern void *memmem(const void *, size_t, const void *, size_t);
 __extern void memswap(void *, void *, size_t);
+__extern void bzero(void *, size_t);
 __extern int strcasecmp(const char *, const char *);
 __extern int strncasecmp(const char *, const char *, size_t);
 __extern char *strcat(char *, const char *);
diff --git a/usr/klibc/Kbuild b/usr/klibc/Kbuild
index ad72116..c8eabf9 100644
--- a/usr/klibc/Kbuild
+++ b/usr/klibc/Kbuild
@@ -30,7 +30,7 @@ klib-y := vsnprintf.o snprintf.o vsprintf.o sprintf.o \
 	  brk.o sbrk.o malloc.o realloc.o calloc.o \
 	  mmap.o shm_open.o shm_unlink.o \
 	  memcpy.o memcmp.o memset.o memccpy.o memmem.o memswap.o \
-	  memmove.o memchr.o memrchr.o \
+	  memmove.o memchr.o memrchr.o bzero.o \
 	  strcasecmp.o strncasecmp.o strndup.o strerror.o strsignal.o \
 	  strcat.o strchr.o strcmp.o strcpy.o strdup.o strlen.o strnlen.o \
 	  strncat.o strlcpy.o strlcat.o \
diff --git a/usr/klibc/bzero.c b/usr/klibc/bzero.c
new file mode 100644
index 0000000..aa1c1ff
--- /dev/null
+++ b/usr/klibc/bzero.c
@@ -0,0 +1,6 @@
+#include <string.h>
+
+void bzero(void *dst, size_t n)
+{
+	memset(dst, 0, n);
+}

commit 167d24ad9209ba6a8a3f20663da5c79780674b52
Author: maximilian attems <max at stro.at>
Date:   Fri Aug 24 23:09:03 2007 +0200

    [klibc] devname.c: include kinit.h
    
    include the header file that prototypes bdevname()
    
    Signed-off-by: maximilian attems <max at stro.at>

diff --git a/usr/kinit/devname.c b/usr/kinit/devname.c
index aeb2135..03f360e 100644
--- a/usr/kinit/devname.c
+++ b/usr/kinit/devname.c
@@ -6,6 +6,8 @@
 #include <sys/types.h>
 #include <sys/sysmacros.h>
 
+#include "kinit.h"
+
 /*
  * Print the name of a block device.
  */

commit 11190d343e57061e21d18f61c3893c597f61ab8b
Author: maximilian attems <max at stro.at>
Date:   Fri Aug 24 22:45:46 2007 +0200

    [klibc] resume, kill: axe unused envp usage
    
    makes main() more familiar ;)
    
    Signed-off-by: maximlian attems <max at stro.at>

diff --git a/usr/kinit/resume/resume.c b/usr/kinit/resume/resume.c
index 80099f9..2138078 100644
--- a/usr/kinit/resume/resume.c
+++ b/usr/kinit/resume/resume.c
@@ -15,7 +15,7 @@ static __noreturn usage(void)
 	exit(1);
 }
 
-int main(int argc, char *argv[], char *envp[])
+int main(int argc, char *argv[])
 {
 	progname = argv[0];
 	if (argc < 2 || argc > 3)
diff --git a/usr/utils/kill.c b/usr/utils/kill.c
index 8e68faa..188f1b5 100644
--- a/usr/utils/kill.c
+++ b/usr/utils/kill.c
@@ -10,7 +10,7 @@ static __noreturn usage(void)
 	fprintf(stderr, "Usage: %s pid\n", progname);
 	exit(1);
 }
-int main(int argc, char *argv[], char *envp[])
+int main(int argc, char *argv[])
 {
 	long pid;
 	char *endp;

commit f0b3f1ebf1a9a7c138c106cd802cad3b782a4bac
Author: maximilian attems <max at stro.at>
Date:   Sat Aug 25 01:17:41 2007 +0200

    [klibc] strcspn, strpbrk, strspn include string.h
    
    include the header file that prototype their function.
    
    Signed-off-by: maximilian attems <max at stro.at>

diff --git a/usr/klibc/strcspn.c b/usr/klibc/strcspn.c
index bb3ac72..35fd38c 100644
--- a/usr/klibc/strcspn.c
+++ b/usr/klibc/strcspn.c
@@ -2,6 +2,8 @@
  * strcspn
  */
 
+#include <string.h>
+
 #include "strxspn.h"
 
 size_t strcspn(const char *s, const char *reject)
diff --git a/usr/klibc/strpbrk.c b/usr/klibc/strpbrk.c
index ba53d02..300dbba 100644
--- a/usr/klibc/strpbrk.c
+++ b/usr/klibc/strpbrk.c
@@ -2,6 +2,8 @@
  * strpbrk
  */
 
+#include <string.h>
+
 #include "strxspn.h"
 
 char *strpbrk(const char *s, const char *accept)
diff --git a/usr/klibc/strspn.c b/usr/klibc/strspn.c
index 1222ce4..828fa2b 100644
--- a/usr/klibc/strspn.c
+++ b/usr/klibc/strspn.c
@@ -2,6 +2,8 @@
  * strspn
  */
 
+#include <string.h>
+
 #include "strxspn.h"
 
 size_t strspn(const char *s, const char *accept)

commit 1ee3e42f1a672cd14f749d3f93fd56abd5abfd9b
Author: maximilian attems <max at stro.at>
Date:   Fri Aug 24 22:31:38 2007 +0200

    [klibc] kinit, mknod: s/(major|minor)/\1_num/
    
    don't shadow major(), minor()
    
    Signed-off-by: maximilian attems <max at stro.at>

diff --git a/usr/kinit/do_mounts_md.c b/usr/kinit/do_mounts_md.c
index 696ffbd..6d4facc 100644
--- a/usr/kinit/do_mounts_md.c
+++ b/usr/kinit/do_mounts_md.c
@@ -142,7 +142,7 @@ static int mdp_major(void)
  */
 static int md_setup(char *str)
 {
-	int minor, level, factor, fault, partitioned = 0;
+	int minor_num, level, factor, fault, partitioned = 0;
 	char *pername = "";
 	char *str1;
 	int ent;
@@ -151,28 +151,28 @@ static int md_setup(char *str)
 		partitioned = 1;
 		str++;
 	}
-	if (get_option(&str, &minor) != 2) {	/* MD Number */
+	if (get_option(&str, &minor_num) != 2) {	/* MD Number */
 		fprintf(stderr, "md: Too few arguments supplied to md=.\n");
 		return 0;
 	}
 	str1 = str;
-	if (minor >= MAX_MD_DEVS) {
+	if (minor_num >= MAX_MD_DEVS) {
 		fprintf(stderr, "md: md=%d, Minor device number too high.\n",
-			minor);
+			minor_num);
 		return 0;
 	}
 	for (ent = 0; ent < md_setup_ents; ent++)
-		if (md_setup_args[ent].minor == minor &&
+		if (md_setup_args[ent].minor == minor_num &&
 		    md_setup_args[ent].partitioned == partitioned) {
 			fprintf(stderr,
 				"md: md=%s%d, Specified more than once. "
 				"Replacing previous definition.\n",
-				partitioned ? "d" : "", minor);
+				partitioned ? "d" : "", minor_num);
 			break;
 		}
 	if (ent >= MAX_MD_DEVS) {
 		fprintf(stderr, "md: md=%s%d - too many md initialisations\n",
-			partitioned ? "d" : "", minor);
+			partitioned ? "d" : "", minor_num);
 		return 0;
 	}
 	if (ent >= md_setup_ents)
@@ -204,10 +204,10 @@ static int md_setup(char *str)
 	}
 
 	fprintf(stderr, "md: Will configure md%s%d (%s) from %s, below.\n",
-		partitioned?"_d":"", minor, pername, str);
+		partitioned?"_d":"", minor_num, pername, str);
 	md_setup_args[ent].device_names = str;
 	md_setup_args[ent].partitioned = partitioned;
-	md_setup_args[ent].minor = minor;
+	md_setup_args[ent].minor = minor_num;
 
 	return 1;
 }
diff --git a/usr/kinit/name_to_dev.c b/usr/kinit/name_to_dev.c
index 593bc12..e5ad1cc 100644
--- a/usr/kinit/name_to_dev.c
+++ b/usr/kinit/name_to_dev.c
@@ -20,7 +20,7 @@ static dev_t try_name(char *name, int part)
 	char path[BUF_SZ];
 	char buf[BUF_SZ];
 	int range;
-	unsigned int major, minor;
+	unsigned int major_num, minor_num;
 	dev_t res;
 	char *s;
 	int len;
@@ -37,13 +37,13 @@ static dev_t try_name(char *name, int part)
 	if (len <= 0 || len == BUF_SZ || buf[len - 1] != '\n')
 		goto fail;
 	buf[len - 1] = '\0';
-	major = strtoul(buf, &s, 10);
+	major_num = strtoul(buf, &s, 10);
 	if (*s != ':')
 		goto fail;
-	minor = strtoul(s + 1, &s, 10);
+	minor_num = strtoul(s + 1, &s, 10);
 	if (*s)
 		goto fail;
-	res = makedev(major, minor);
+	res = makedev(major_num, minor_num);
 
 	/* if it's there and we are not looking for a partition - that's it */
 	if (!part)
@@ -105,7 +105,7 @@ static inline dev_t name_to_dev_t_real(const char *name)
 	int len;
 	const char *devname;
 	char *cptr, *e1, *e2;
-	int major, minor;
+	int major_num, minor_num;
 
 
 	if (name[0] == '/') {
@@ -124,10 +124,10 @@ static inline dev_t name_to_dev_t_real(const char *name)
 		    cptr[1] != '\0') {
 			/* Colon-separated decimal device number */
 			*cptr = '\0';
-			major = strtoul(devname+5, &e1, 10);
-			minor = strtoul(cptr+1, &e2, 10);
+			major_num = strtoul(devname+5, &e1, 10);
+			minor_num = strtoul(cptr+1, &e2, 10);
 			if (!*e1 && !*e2)
-				return makedev(major, minor);
+				return makedev(major_num, minor_num);
 			*cptr = ':';
 		} else {
 			/* Hexadecimal device number */
diff --git a/usr/utils/mknod.c b/usr/utils/mknod.c
index 3145450..89f0da4 100644
--- a/usr/utils/mknod.c
+++ b/usr/utils/mknod.c
@@ -13,7 +13,7 @@ static __noreturn usage(void)
 int main(int argc, char *argv[])
 {
 	char *name, *type, typec, *endp;
-	unsigned int major, minor;
+	unsigned int major_num, minor_num;
 	mode_t mode;
 	dev_t dev;
 
@@ -49,13 +49,13 @@ int main(int argc, char *argv[])
 		if (!argv[0] || !argv[1])
 			usage();
 
-		major = strtol(*argv++, &endp, 0);
+		major_num = strtol(*argv++, &endp, 0);
 		if (*endp != '\0')
 			usage();
-		minor = strtol(*argv++, &endp, 0);
+		minor_num = strtol(*argv++, &endp, 0);
 		if (*endp != '\0')
 			usage();
-		dev = makedev(major, minor);
+		dev = makedev(major_num, minor_num);
 	}
 
 	if (*argv)

commit e9b0cfa6659a2d59471c3fd677e5d389b4dc8445
Author: maximilian attems <max at stro.at>
Date:   Fri Aug 24 22:28:08 2007 +0200

    [klibc] readlink: s/link/link_name/
    
    don't shadow link() with this char*
    
    Signed-off-by: maximilian attems <max at stro.at>

diff --git a/usr/utils/readlink.c b/usr/utils/readlink.c
index 00c2a1e..50c1a34 100644
--- a/usr/utils/readlink.c
+++ b/usr/utils/readlink.c
@@ -13,7 +13,7 @@ static __noreturn usage(void)
 
 int main(int argc, char *argv[])
 {
-	char *name, *link = NULL;
+	char *name, *link_name = NULL;
 	size_t max_siz = 128;
 
 	progname = *argv++;
@@ -22,17 +22,17 @@ int main(int argc, char *argv[])
 	if (!name)
 		usage();
 
-	link = malloc(max_siz);
-	if (!link) {
+	link_name = malloc(max_siz);
+	if (!link_name) {
 		perror("malloc");
 		exit(1);
 	}
 
-	if (readlink(name, link, max_siz) == -1) {
+	if (readlink(name, link_name, max_siz) == -1) {
 		perror("readlink");
 		exit(1);
 	}
-	printf("%s\n", link);
+	printf("%s\n", link_name);
 
 	exit(0);
 }

commit 2354ed83324636b796431c8f1152eb01f6f3c61b
Author: maximilian attems <max at stro.at>
Date:   Fri Aug 24 22:26:13 2007 +0200

    [klibc] cpio: small cleanups
    
    * declare bunch of function as static
    * axe unused xrealloc()
    
    Signed-off-by: maximilian attems <max at stro.at>

diff --git a/usr/utils/cpio.c b/usr/utils/cpio.c
index a41f40a..db626a3 100644
--- a/usr/utils/cpio.c
+++ b/usr/utils/cpio.c
@@ -123,7 +123,7 @@ long input_bytes, output_bytes;
 
 /* Allocate N bytes of memory dynamically, with error checking.  */
 
-void *xmalloc(size_t n)
+static void *xmalloc(size_t n)
 {
 	void *p;
 	if (xalloc_oversized(n, 1) || (!(p = malloc(n)) && n != 0)) {
@@ -134,22 +134,9 @@ void *xmalloc(size_t n)
 /*   return xnmalloc_inline (n, 1); */
 }
 
-/* Change the size of an allocated block of memory P to N bytes,
-   with error checking.  */
-
-void *xrealloc(void *p, size_t n)
-{
-	if (xalloc_oversized(n, 1) || (!(p = realloc(p, n)) && n != 0)) {
-		fprintf(stderr, "%s: memory exhausted\n", progname);
-		exit(1);
-	}
-	return p;
-/*   return xnrealloc_inline (p, n, 1); */
-}
-
 /* Clone STRING.  */
 
-char *xstrdup(char const *string)
+static char *xstrdup(char const *string)
 {
 	size_t s = strlen(string) + 1;
 	return memcpy(xmalloc(s), string, s);
@@ -187,7 +174,7 @@ static void tape_fill_input_buffer(int in_des, int num_bytes)
    must always be a multiple of 4 helps us (and our callers)
    insure this.  */
 
-void disk_empty_output_buffer(int out_des)
+static void disk_empty_output_buffer(int out_des)
 {
 	int bytes_written;
 
@@ -206,7 +193,7 @@ void disk_empty_output_buffer(int out_des)
 /* Copy NUM_BYTES of buffer IN_BUF to `out_buff', which may be partly full.
    When `out_buff' fills up, flush it to file descriptor OUT_DES.  */
 
-void disk_buffered_write(char *in_buf, int out_des, long num_bytes)
+static void disk_buffered_write(char *in_buf, int out_des, long num_bytes)
 {
 	register long bytes_left = num_bytes;	/* Bytes needing to be copied.  */
 	register long space_left;	/* Room left in output buffer.  */
@@ -235,7 +222,7 @@ void disk_buffered_write(char *in_buf, int out_des, long num_bytes)
    OUT_DES is the file descriptor for output;
    NUM_BYTES is the number of bytes to copy.  */
 
-void copy_files_tape_to_disk(int in_des, int out_des, long num_bytes)
+static void copy_files_tape_to_disk(int in_des, int out_des, long num_bytes)
 {
 	long size;
 
@@ -251,7 +238,7 @@ void copy_files_tape_to_disk(int in_des, int out_des, long num_bytes)
 }
 
 /* if IN_BUF is NULL, Skip the next NUM_BYTES bytes of file descriptor IN_DES. */
-void tape_buffered_read(char *in_buf, int in_des, long num_bytes)
+static void tape_buffered_read(char *in_buf, int in_des, long num_bytes)
 {
 	register long bytes_left = num_bytes;	/* Bytes needing to be copied.  */
 	register long space_left;	/* Bytes to copy from input buffer.  */
@@ -282,7 +269,7 @@ struct deferment {
 	struct new_cpio_header header;
 };
 
-struct deferment *create_deferment(struct new_cpio_header *file_hdr)
+static struct deferment *create_deferment(struct new_cpio_header *file_hdr)
 {
 	struct deferment *d;
 	d = (struct deferment *)xmalloc(sizeof(struct deferment));
@@ -292,13 +279,13 @@ struct deferment *create_deferment(struct new_cpio_header *file_hdr)
 	return d;
 }
 
-void free_deferment(struct deferment *d)
+static void free_deferment(struct deferment *d)
 {
 	free(d->header.c_name);
 	free(d);
 }
 
-int link_to_name(char *link_name, char *link_target)
+static int link_to_name(char *link_name, char *link_target)
 {
 	int res = link(link_target, link_name);
 	return res;
@@ -352,7 +339,7 @@ static void hash_insert(struct inode_val *new_value)
 
 /* Associate FILE_NAME with the inode NODE_NUM.  (Insert into hash table.)  */
 
-void
+static void
 add_inode(unsigned long node_num, char *file_name, unsigned long major_num,
 	  unsigned long minor_num)
 {
@@ -399,7 +386,7 @@ add_inode(unsigned long node_num, char *file_name, unsigned long major_num,
 	hash_num++;
 }
 
-char *find_inode_file(unsigned long node_num, unsigned long major_num,
+static char *find_inode_file(unsigned long node_num, unsigned long major_num,
 		      unsigned long minor_num)
 {
 	int start;		/* Initial hash location.  */
@@ -439,7 +426,7 @@ char *find_inode_file(unsigned long node_num, unsigned long major_num,
    numbers is found, try and create another link to it using
    link_to_name, and return 0 for success and -1 for failure.  */
 
-int
+static int
 link_to_maj_min_ino(char *file_name, int st_dev_maj, int st_dev_min, int st_ino)
 {
 	int link_res;
@@ -457,7 +444,7 @@ link_to_maj_min_ino(char *file_name, int st_dev_maj, int st_dev_min, int st_ino)
 static void copyin_regular_file(struct new_cpio_header *file_hdr,
 				int in_file_des);
 
-void warn_junk_bytes(long bytes_skipped)
+static void warn_junk_bytes(long bytes_skipped)
 {
 	fprintf(stderr, "%s: warning: skipped %ld byte(s) of junk\n",
 		progname, bytes_skipped);
@@ -578,7 +565,7 @@ static void create_defered_links(struct new_cpio_header *file_hdr)
    we are done reading the whole archive.  Write out all of these
    empty links that are still on the deferments list.  */
 
-static void create_final_defers()
+static void create_final_defers(void)
 {
 	struct deferment *d;
 	int link_res;
@@ -720,7 +707,7 @@ copyin_regular_file(struct new_cpio_header *file_hdr, int in_file_des)
    NAME has no file name components because it is all slashes, return
    NAME if it is empty, the address of its last slash otherwise.  */
 
-char *base_name(char const *name)
+static char *base_name(char const *name)
 {
 	char const *base = name + FILE_SYSTEM_PREFIX_LEN(name);
 	char const *p;
@@ -752,7 +739,7 @@ char *base_name(char const *name)
    value returned by base_name.  Act like strlen (NAME), except omit
    redundant trailing slashes.  */
 
-size_t base_len(char const *name)
+static size_t base_len(char const *name)
 {
 	size_t len;
 
@@ -769,7 +756,7 @@ size_t base_len(char const *name)
    the Unix rename and rmdir system calls return an "Invalid argument" error
    when given a path that ends in "/" (except for the root directory).  */
 
-bool strip_trailing_slashes(char *path)
+static bool strip_trailing_slashes(char *path)
 {
 	char *base = base_name(path);
 	char *base_lim = base + base_len(base);
@@ -930,7 +917,7 @@ static void copyin_file(struct new_cpio_header *file_hdr, int in_file_des)
    file descriptor IN_DES, except for the magic number, which is
    already filled in.  */
 
-void read_in_new_ascii(struct new_cpio_header *file_hdr, int in_des)
+static void read_in_new_ascii(struct new_cpio_header *file_hdr, int in_des)
 {
 	char ascii_header[112];
 
@@ -963,7 +950,7 @@ void read_in_new_ascii(struct new_cpio_header *file_hdr, int in_des)
 /* Read the header, including the name of the file, from file
    descriptor IN_DES into FILE_HDR.  */
 
-void read_in_header(struct new_cpio_header *file_hdr, int in_des)
+static void read_in_header(struct new_cpio_header *file_hdr, int in_des)
 {
 	long bytes_skipped = 0;	/* Bytes of junk found before magic number.  */
 
@@ -991,7 +978,7 @@ void read_in_header(struct new_cpio_header *file_hdr, int in_des)
 /* Read the collection from standard input and create files
    in the file system.  */
 
-void process_copy_in()
+static void process_copy_in(void)
 {
 	char done = false;	/* True if trailer reached.  */
 	struct new_cpio_header file_hdr;	/* Output header information.  */
@@ -1033,7 +1020,7 @@ void process_copy_in()
    initialize all variables associated with the input and output
    buffers.  */
 
-void initialize_buffers()
+static void initialize_buffers(void)
 {
 	int in_buf_size, out_buf_size;
 

commit 3484fcf9eca3a1335a4c6ad1615ceb05a33e9e8a
Author: maximilian attems <max at stro.at>
Date:   Wed Aug 22 09:30:20 2007 +0200

    [klibc] mount: add -n option
    klibc mount ignores mtab anyway.
    so there is nothing special to be done.
    
    Signed-off-by: maximilian attems <max at stro.at>

diff --git a/usr/utils/mount_main.c b/usr/utils/mount_main.c
index e8e22cd..fd62000 100644
--- a/usr/utils/mount_main.c
+++ b/usr/utils/mount_main.c
@@ -64,10 +64,13 @@ int main(int argc, char *argv[])
 	rwflag = MS_VERBOSE;
 
 	do {
-		c = getopt(argc, argv, "o:rt:w");
+		c = getopt(argc, argv, "no:rt:w");
 		if (c == EOF)
 			break;
 		switch (c) {
+		case 'n':
+			/* no mtab writing */
+			break;
 		case 'o':
 			rwflag = parse_mount_options(optarg, rwflag, &extra);
 			break;
@@ -96,7 +99,7 @@ int main(int argc, char *argv[])
 
 	if (optind + 2 != argc || type == NULL) {
 		fprintf(stderr, "Usage: %s [-r] [-w] [-o options] [-t type] "
-			"device directory\n", progname);
+			"[-n] device directory\n", progname);
 		exit(1);
 	}
 

commit 5bb1a30d8d029f97ba58fb2eea6c519a72247694
Author: maximilian attems <max at stro.at>
Date:   Wed Aug 22 09:24:46 2007 +0200

    [klibc] mount: add nodev, noexec and nosuid options
    
    options are used by init of initramfs-tools.
    
    Signed-off-by: maximilian attems <max at stro.at>

diff --git a/usr/utils/mount_opts.c b/usr/utils/mount_opts.c
index 98f58cf..05d1729 100644
--- a/usr/utils/mount_opts.c
+++ b/usr/utils/mount_opts.c
@@ -21,6 +21,9 @@ static const struct mount_opts options[] = {
 	{"dirsync", MS_DIRSYNC, MS_DIRSYNC, 0},
 	{"exec", MS_NOEXEC, 0, MS_NOEXEC},
 	{"move", MS_TYPE, MS_MOVE, 0},
+	{"nodev", MS_NODEV, MS_NODEV, 0},
+	{"noexec", MS_NOEXEC, MS_NOEXEC, 0},
+	{"nosuid", MS_NOSUID, MS_NOSUID, 0},
 	{"recurse", MS_REC, MS_REC, 0},
 	{"remount", MS_TYPE, MS_REMOUNT, 0},
 	{"ro", MS_RDONLY, MS_RDONLY, 0},



 
> The warnings you get come from these declarations:
> 
> static __inline__ int getpagesize(void)
> {
>         extern unsigned int __page_size;
>         return __page_size;
> }
> 
> -Wnested outlaws these kinds of constructs.  There is a __nowarn__
> keyword being added in gcc 4.3 or 4.4 to shut up these kinds of
> warnings, but the only other way to deal with this is to export
> __page_size and __page_shift into the global namespace, which kind of
> defeats the purpose of an accessor function.
> 
> 	-hpa
-- 
maks



More information about the klibc mailing list