From: Suzuki Takashi <suzuki.takashi@gmail.com>
To: linux-mtd@lists.infradead.org
Subject: Re: [PATCH 4/4] util/jffs2reader better output formats
Date: Sat, 22 Oct 2005 14:34:25 +0900 [thread overview]
Message-ID: <4359cf69.67e8a797.2ae9.ffffa9e5@mx.gmail.com> (raw)
In-Reply-To: <b1c6420f0510142013u634116eag4f360a6a2e7f8432@mail.gmail.com>
On Sat, 15 Oct 2005 12:13:46 +0900, I wrote:
> This is the 4th patch for util/jffs2reader.c.
> It is not a bug fix and makes some improvements.
>
> Please review and apply if it is ok.
The patch without quoted-printable encoding and extra linebreaks.
Thanks.
--- jffs2reader.c.catfile 2005-10-10 18:22:02.000000000 +0900
+++ jffs2reader.c 2005-10-10 19:31:21.000000000 +0900
@@ -320,6 +320,7 @@ void printdir(char *o, size_t size, stru
char *filetime;
time_t age;
struct jffs2_raw_inode *ri;
+ struct dir *od = d;
if (!path)
return;
@@ -369,7 +370,7 @@ void printdir(char *o, size_t size, stru
age = je32_to_cpu (ri->ctime);
filetime = ctime(&age);
age = time(NULL) - je32_to_cpu (ri->ctime);
- printf("%s %-4d %-8d %-8d ", mode_string(jemode_to_cpu (ri->mode)),
+ printf("%s %-4d %-5d %-5d ", mode_string(jemode_to_cpu (ri->mode)),
1, je16_to_cpu (ri->uid), je16_to_cpu (ri->gid));
if ( d->type==DT_BLK || d->type==DT_CHR ) {
dev_t rdev;
@@ -382,9 +383,14 @@ void printdir(char *o, size_t size, stru
d->name[d->nsize]='\0';
if (age < 3600L * 24 * 365 / 2 && age > -15 * 60) {
/* hh:mm if less than 6 months old */
- printf("%6.6s %5.5s %s/%s%c", filetime + 4, filetime + 11, path, d->name, m);
+ printf("%6.6s %5.5s ", filetime + 4, filetime + 11);
} else {
- printf("%6.6s %4.4s %s/%s%c", filetime + 4, filetime + 20, path, d->name, m);
+ printf("%6.6s %4.4s ", filetime + 4, filetime + 20);
+ }
+ if (*path == '\0') {
+ printf ("%s%c", d->name, m);
+ } else {
+ printf ("%s/%s%c", path, d->name, m);
}
if (d->type == DT_LNK) {
char symbuf[1024];
@@ -395,19 +401,32 @@ void printdir(char *o, size_t size, stru
}
printf("\n");
- if (d->type == DT_DIR && recurse) {
- char *tmp;
- tmp = malloc(BUFSIZ);
- if (!tmp) {
- fprintf(stderr, "memory exhausted\n");
- exit(EXIT_FAILURE);
+ d = d->next;
+ }
+
+ if (recurse) {
+ d = od;
+ while (d != NULL) {
+ if (d->type == DT_DIR) {
+ char *tmp;
+ tmp = malloc(BUFSIZ);
+ if (!tmp) {
+ fprintf(stderr, "memory exhausted\n");
+ exit(EXIT_FAILURE);
+ }
+ printf ("\n");
+ if (*path == '\0') {
+ strcpy (tmp, d->name);
+ } else {
+ sprintf(tmp, "%s/%s", path, d->name);
+ }
+ printf("%s/\n", tmp);
+ lsdir(o, size, tmp, recurse); /* Go recursive */
+ free(tmp);
}
- sprintf(tmp, "%s/%s", path, d->name);
- lsdir(o, size, tmp, recurse); /* Go recursive */
- free(tmp);
- }
- d = d->next;
+ d = d->next;
+ }
}
}
@@ -1032,7 +1051,7 @@ int main(int argc, char **argv)
}
if (!dir && !file)
- lsdir(buf, st.st_size, "/", 1);
+ lsdir(buf, st.st_size, "", recurse);
free(buf);
--
Suzuki Takashi
prev parent reply other threads:[~2005-10-22 5:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-10-15 3:13 [PATCH 4/4] util/jffs2reader better output formats Suzuki Takashi
2005-10-22 5:34 ` Suzuki Takashi [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4359cf69.67e8a797.2ae9.ffffa9e5@mx.gmail.com \
--to=suzuki.takashi@gmail.com \
--cc=linux-mtd@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.