aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormaximilian attems <max@stro.at>2010-03-23 03:22:42 +0100
committermaximilian attems <max@stro.at>2010-03-23 03:34:52 +0100
commit5f54d9da56b8e29d4fde34189df471ab08a1024e (patch)
tree41220055961f21dce74015e56ec34f9a654bb36f
parenteb13bfbd0acd58bdc0fbef42d367a92d58e1be62 (diff)
downloadklibc-5f54d9da56b8e29d4fde34189df471ab08a1024e.tar.gz
[klibc] kinit: use dprintf on DEBUG
as bonus this cleanes up also some whitespace violations in old DEBUG usage. Signed-off-by: maximilian attems <max@stro.at>
-rw-r--r--usr/kinit/do_mounts.c22
-rw-r--r--usr/kinit/do_mounts_mtd.c4
-rw-r--r--usr/kinit/initrd.c24
-rw-r--r--usr/kinit/kinit.c12
-rw-r--r--usr/kinit/kinit.h10
-rw-r--r--usr/kinit/name_to_dev.c6
-rw-r--r--usr/kinit/nfsroot.c4
-rw-r--r--usr/kinit/ramdisk_load.c12
-rw-r--r--usr/kinit/resume/resumelib.c2
9 files changed, 47 insertions, 49 deletions
diff --git a/usr/kinit/do_mounts.c b/usr/kinit/do_mounts.c
index 3f638708adf4a..0c5ef42572ea9 100644
--- a/usr/kinit/do_mounts.c
+++ b/usr/kinit/do_mounts.c
@@ -33,8 +33,8 @@ const char *mount_block(const char *source, const char *target,
int fd;
if (type) {
- DEBUG(("kinit: trying to mount %s on %s with type %s\n",
- source, target, type));
+ dprintf("kinit: trying to mount %s on %s with type %s\n",
+ source, target, type);
int rv = mount(source, target, type, flags, data);
/* Mount readonly if necessary */
if (rv == -1 && errno == EACCES && !(flags & MS_RDONLY))
@@ -52,16 +52,16 @@ const char *mount_block(const char *source, const char *target,
close(fd);
if (!err && type) {
- DEBUG(("kinit: %s appears to be a %s filesystem\n",
- source, type));
+ dprintf("kinit: %s appears to be a %s filesystem\n",
+ source, type);
type = mount_block(source, target, type, flags, data);
if (type)
return type;
}
}
- DEBUG(("kinit: failed to identify filesystem %s, trying all\n",
- source));
+ dprintf("kinit: failed to identify filesystem %s, trying all\n",
+ source);
fsbytes = readfile("/proc/filesystems", &fslist);
@@ -152,7 +152,7 @@ mount_roots(int argc, char *argv[], const char *root_dev_name)
while (root) {
dev_t root_dev;
- DEBUG(("kinit: trying to mount %s\n", root));
+ dprintf("kinit: trying to mount %s\n", root);
root_dev = name_to_dev_t(root);
ret = mount_root(argc, argv, root_dev, root);
if (!ret)
@@ -171,7 +171,7 @@ mount_root(int argc, char *argv[], dev_t root_dev, const char *root_dev_name)
const char *type = get_arg(argc, argv, "rootfstype=");
if (get_flag(argc, argv, "rw") > get_flag(argc, argv, "ro")) {
- DEBUG(("kinit: mounting root rw\n"));
+ dprintf("kinit: mounting root rw\n");
flags &= ~MS_RDONLY;
}
@@ -207,7 +207,7 @@ int do_mounts(int argc, char *argv[])
const char *load_ramdisk = get_arg(argc, argv, "load_ramdisk=");
dev_t root_dev = 0;
- DEBUG(("kinit: do_mounts\n"));
+ dprintf("kinit: do_mounts\n");
if (root_delay) {
int delay = atoi(root_delay);
@@ -229,10 +229,10 @@ int do_mounts(int argc, char *argv[])
root_dev = (dev_t) rootdev;
}
- DEBUG(("kinit: root_dev = %s\n", bdevname(root_dev)));
+ dprintf("kinit: root_dev = %s\n", bdevname(root_dev));
if (initrd_load(argc, argv, root_dev)) {
- DEBUG(("initrd loaded\n"));
+ dprintf("initrd loaded\n");
return 0;
}
diff --git a/usr/kinit/do_mounts_mtd.c b/usr/kinit/do_mounts_mtd.c
index 7630920488b7a..20d27cace92bc 100644
--- a/usr/kinit/do_mounts_mtd.c
+++ b/usr/kinit/do_mounts_mtd.c
@@ -23,8 +23,8 @@ int mount_mtd_root(int argc, char *argv[], const char *root_dev_name,
if (!type)
type = "jffs2";
- DEBUG(("Trying to mount MTD %s as root (%s filesystem)\n",
- root_dev_name, type));
+ printf("Trying to mount MTD %s as root (%s filesystem)\n",
+ root_dev_name, type);
if (mount(root_dev_name, "/root", type, flags, data)) {
int err = errno;
diff --git a/usr/kinit/initrd.c b/usr/kinit/initrd.c
index 86f8d91ee1829..1c3ec56cb1a93 100644
--- a/usr/kinit/initrd.c
+++ b/usr/kinit/initrd.c
@@ -27,7 +27,7 @@ static int rd_copy_uncompressed(int ffd, int dfd)
off_t bytes;
struct stat st;
- DEBUG(("kinit: uncompressed initrd\n"));
+ dprintf("kinit: uncompressed initrd\n");
if (ffd < 0 || fstat(ffd, &st) || !S_ISREG(st.st_mode) ||
(bytes = st.st_size) == 0)
@@ -37,8 +37,8 @@ static int rd_copy_uncompressed(int ffd, int dfd)
ssize_t blocksize = ((bytes - 1) & (BUF_SIZE - 1)) + 1;
off_t offset = bytes - blocksize;
- DEBUG(("kinit: copying %zd bytes at offset %llu\n",
- blocksize, offset));
+ dprintf("kinit: copying %zd bytes at offset %llu\n",
+ blocksize, offset);
if (xpread(ffd, buffer, blocksize, offset) != blocksize ||
xpwrite(dfd, buffer, blocksize, offset) != blocksize)
@@ -91,13 +91,13 @@ static int run_linuxrc(int argc, char *argv[], dev_t root_dev)
const char *ramdisk_name = "/dev/ram0";
FILE *fp;
- DEBUG(("kinit: mounting initrd\n"));
+ dprintf("kinit: mounting initrd\n");
mkdir("/root", 0700);
if (!mount_block(ramdisk_name, "/root", NULL, MS_VERBOSE, NULL))
return -errno;
/* Write the current "real root device" out to procfs */
- DEBUG(("kinit: real_root_dev = %#x\n", root_dev));
+ dprintf("kinit: real_root_dev = %#x\n", root_dev);
fp = fopen("/proc/sys/kernel/real-root-dev", "w");
fprintf(fp, "%u", root_dev);
fclose(fp);
@@ -121,9 +121,9 @@ static int run_linuxrc(int argc, char *argv[], dev_t root_dev)
execl("/linuxrc", "linuxrc", NULL);
_exit(255);
} else if (pid > 0) {
- DEBUG(("kinit: Waiting for linuxrc to complete...\n"));
+ dprintf("kinit: Waiting for linuxrc to complete...\n");
while (waitpid(pid, NULL, 0) != pid) ;
- DEBUG(("kinit: linuxrc done\n"));
+ dprintf("kinit: linuxrc done\n");
} else {
return -errno;
}
@@ -170,7 +170,7 @@ int initrd_load(int argc, char *argv[], dev_t root_dev)
if (access("/initrd.image", R_OK))
return 0; /* No initrd */
- DEBUG(("kinit: initrd found\n"));
+ dprintf("kinit: initrd found\n");
create_dev("/dev/ram0", Root_RAM0);
@@ -180,24 +180,24 @@ int initrd_load(int argc, char *argv[], dev_t root_dev)
return 0; /* Failed to copy initrd */
}
- DEBUG(("kinit: initrd copied\n"));
+ dprintf("kinit: initrd copied\n");
if (root_dev == Root_MULTI) {
- DEBUG(("kinit: skipping linuxrc: incompatible with multiple roots\n"));
+ dprintf("kinit: skipping linuxrc: incompatible with multiple roots\n");
/* Mounting initrd as ordinary root */
return 0;
}
if (root_dev != Root_RAM0) {
int err;
- DEBUG(("kinit: running linuxrc\n"));
+ dprintf("kinit: running linuxrc\n");
err = run_linuxrc(argc, argv, root_dev);
if (err)
fprintf(stderr, "%s: running linuxrc: %s\n", progname,
strerror(-err));
return 1; /* initrd is root, or run_linuxrc took care of it */
} else {
- DEBUG(("kinit: permament (or pivoting) initrd, not running linuxrc\n"));
+ dprintf("kinit: permament (or pivoting) initrd, not running linuxrc\n");
return 0; /* Mounting initrd as ordinary root */
}
}
diff --git a/usr/kinit/kinit.c b/usr/kinit/kinit.c
index 7c33718dc2f02..4a1f40b97e188 100644
--- a/usr/kinit/kinit.c
+++ b/usr/kinit/kinit.c
@@ -19,7 +19,7 @@ const char *progname = "kinit";
int mnt_procfs;
int mnt_sysfs;
-#ifdef INI_DEBUG
+#ifdef DEBUG
void dump_args(int argc, char *argv[])
{
int i;
@@ -32,10 +32,10 @@ void dump_args(int argc, char *argv[])
if (argv[argc] != NULL) {
printf(" argv[%d]: \"%s\" (SHOULD BE NULL)\n",
- argc, argv[argc]);
+ argc, argv[argc]);
}
}
-#endif
+#endif /* DEBUG */
static int do_ipconfig(int argc, char *argv[])
@@ -50,7 +50,7 @@ static int do_ipconfig(int argc, char *argv[])
args[a++] = (char *)"-i";
args[a++] = (char *)"Linux kinit";
- DEBUG(("Running ipconfig\n"));
+ dprintf("Running ipconfig\n");
for (i = 1; i < argc; i++) {
if (strncmp(argv[i], "ip=", 3) == 0 ||
@@ -173,13 +173,13 @@ static const char *find_init(const char *root, const char *user)
}
if (user)
- DEBUG(("Checking for init: %s\n", user));
+ dprintf("Checking for init: %s\n", user);
if (user && user[0] == '/' && !access(user+1, X_OK)) {
path = user;
} else {
for (p = init_paths; *p; p++) {
- DEBUG(("Checking for init: %s\n", *p));
+ dprintf("Checking for init: %s\n", *p);
if (!access(*p+1, X_OK))
break;
}
diff --git a/usr/kinit/kinit.h b/usr/kinit/kinit.h
index 3a37951f8b32b..c2e67b7232019 100644
--- a/usr/kinit/kinit.h
+++ b/usr/kinit/kinit.h
@@ -48,16 +48,14 @@ ssize_t freadfile(FILE *f, char **pptr);
(void) (&_x == &_y); \
_x > _y ? _x : _y; })
-#define INI_DEBUG
-#undef DEBUG
-#ifdef INI_DEBUG
-#define DEBUG(x) printf x
+#ifdef DEBUG
+# define dprintf printf
#else
-#define DEBUG(x) do { } while (0)
+# define dprintf(...) ((void)0)
#endif
-#ifdef INI_DEBUG
+#ifdef DEBUG
void dump_args(int argc, char *argv[]);
#else
static inline void dump_args(int argc, char *argv[])
diff --git a/usr/kinit/name_to_dev.c b/usr/kinit/name_to_dev.c
index fbe3c2714212b..ab19084861156 100644
--- a/usr/kinit/name_to_dev.c
+++ b/usr/kinit/name_to_dev.c
@@ -65,8 +65,8 @@ static dev_t try_name(char *name, int part)
/* if partition is within range - we got it */
if (part < range) {
- DEBUG(("kinit: try_name %s,%d = %s\n", name, part,
- bdevname(res + part)));
+ dprintf("kinit: try_name %s,%d = %s\n", name, part,
+ bdevname(res + part));
return res + part;
}
@@ -186,7 +186,7 @@ dev_t name_to_dev_t(const char *name)
{
dev_t dev = name_to_dev_t_real(name);
- DEBUG(("kinit: name_to_dev_t(%s) = %s\n", name, bdevname(dev)));
+ dprintf("kinit: name_to_dev_t(%s) = %s\n", name, bdevname(dev));
return dev;
}
diff --git a/usr/kinit/nfsroot.c b/usr/kinit/nfsroot.c
index 221cecd0dcf14..b5ab3bb1b8207 100644
--- a/usr/kinit/nfsroot.c
+++ b/usr/kinit/nfsroot.c
@@ -93,8 +93,8 @@ int mount_nfs_root(int argc, char *argv[], int flags)
nfs_argv[a++] = sub_client(client, root, len);
- DEBUG(("NFS-Root: mounting %s on %s with options \"%s\"\n",
- nfs_argv[a-1], mtpt, opts ? opts : ""));
+ dprintf("NFS-Root: mounting %s on %s with options \"%s\"\n",
+ nfs_argv[a-1], mtpt, opts ? opts : "");
nfs_argv[a++] = mtpt;
nfs_argv[a] = NULL;
diff --git a/usr/kinit/ramdisk_load.c b/usr/kinit/ramdisk_load.c
index 3995e8f17e341..7315008257ac6 100644
--- a/usr/kinit/ramdisk_load.c
+++ b/usr/kinit/ramdisk_load.c
@@ -95,7 +95,7 @@ int load_ramdisk_compressed(const char *devpath, FILE * wfd,
if (ioctl(rfd, BLKGETSIZE64, &ramdisk_size))
ramdisk_size = ~0ULL;
ramdisk_start = 0;
- DEBUG(("New size = %llu\n", ramdisk_size));
+ dprintf("New size = %llu\n", ramdisk_size);
}
do {
ramdisk_left = ramdisk_size - ramdisk_start;
@@ -117,14 +117,14 @@ int load_ramdisk_compressed(const char *devpath, FILE * wfd,
rv = inflate(&zs, Z_SYNC_FLUSH);
} while (rv == Z_OK || rv == Z_BUF_ERROR);
- DEBUG(("kinit: inflate returned %d\n", rv));
+ dprintf("kinit: inflate returned %d\n", rv);
if (rv != Z_STREAM_END)
goto err2;
/* Write the last */
_fwrite(out_buf, BUF_SZ - zs.avail_out, wfd);
- DEBUG(("kinit: writing %d bytes\n", BUF_SZ - zs.avail_out));
+ dprintf("kinit: writing %d bytes\n", BUF_SZ - zs.avail_out);
inflateEnd(&zs);
return 0;
@@ -153,8 +153,8 @@ load_ramdisk_raw(const char *devpath, FILE * wfd, off_t ramdisk_start,
if (ioctl(rfd, BLKGETSIZE64, &ramdisk_size))
ramdisk_size = ~0ULL;
- DEBUG(("start: %llu size: %llu fssize: %llu\n",
- ramdisk_start, ramdisk_size, fssize));
+ dprintf("start: %llu size: %llu fssize: %llu\n",
+ ramdisk_start, ramdisk_size, fssize);
while (fssize) {
@@ -246,7 +246,7 @@ int ramdisk_load(int argc, char *argv[])
return 0;
}
- DEBUG(("kinit: ramdisk is %s, size %llu\n", fstype, fssize));
+ dprintf("kinit: ramdisk is %s, size %llu\n", fstype, fssize);
fprintf(stderr, "Loading ramdisk (%s) ...", is_gzip ? "gzip" : "raw");
diff --git a/usr/kinit/resume/resumelib.c b/usr/kinit/resume/resumelib.c
index 12ef984ca9ca9..5233e7e8e5c8f 100644
--- a/usr/kinit/resume/resumelib.c
+++ b/usr/kinit/resume/resumelib.c
@@ -68,7 +68,7 @@ int resume(const char *resume_file, unsigned long long resume_offset)
if (len >= sizeof device_string)
goto fail_r;
- DEBUG(("kinit: trying to resume from %s\n", resume_file));
+ dprintf("kinit: trying to resume from %s\n", resume_file);
if (write(powerfd, device_string, len) != len)
goto fail_r;