Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 284459
b: refs/heads/master
c: beba006
h: refs/heads/master
i:
  284457: 304080f
  284455: 8328d9e
v: v3
  • Loading branch information
Artem Bityutskiy committed Jan 13, 2012
1 parent 6f61cdb commit 699b464
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d34315da9146253351146140ea4b277193ee5e5f
refs/heads/master: beba006074e7170d3bc91470c8a6c914730d4c63
38 changes: 20 additions & 18 deletions trunk/fs/ubifs/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,53 +103,55 @@ static const char *get_dent_type(int type)
}
}

static void sprintf_key(const struct ubifs_info *c, const union ubifs_key *key,
char *buffer)
static void snprintf_key(const struct ubifs_info *c, const union ubifs_key *key,
char *buffer, int len)
{
char *p = buffer;
int type = key_type(c, key);

if (c->key_fmt == UBIFS_SIMPLE_KEY_FMT) {
switch (type) {
case UBIFS_INO_KEY:
sprintf(p, "(%lu, %s)", (unsigned long)key_inum(c, key),
get_key_type(type));
len -= snprintf(p, len, "(%lu, %s)",
(unsigned long)key_inum(c, key),
get_key_type(type));
break;
case UBIFS_DENT_KEY:
case UBIFS_XENT_KEY:
sprintf(p, "(%lu, %s, %#08x)",
(unsigned long)key_inum(c, key),
get_key_type(type), key_hash(c, key));
len -= snprintf(p, len, "(%lu, %s, %#08x)",
(unsigned long)key_inum(c, key),
get_key_type(type), key_hash(c, key));
break;
case UBIFS_DATA_KEY:
sprintf(p, "(%lu, %s, %u)",
(unsigned long)key_inum(c, key),
get_key_type(type), key_block(c, key));
len -= snprintf(p, len, "(%lu, %s, %u)",
(unsigned long)key_inum(c, key),
get_key_type(type), key_block(c, key));
break;
case UBIFS_TRUN_KEY:
sprintf(p, "(%lu, %s)",
(unsigned long)key_inum(c, key),
get_key_type(type));
len -= snprintf(p, len, "(%lu, %s)",
(unsigned long)key_inum(c, key),
get_key_type(type));
break;
default:
sprintf(p, "(bad key type: %#08x, %#08x)",
key->u32[0], key->u32[1]);
len -= snprintf(p, len, "(bad key type: %#08x, %#08x)",
key->u32[0], key->u32[1]);
}
} else
sprintf(p, "bad key format %d", c->key_fmt);
len -= snprintf(p, len, "bad key format %d", c->key_fmt);
ubifs_assert(len > 0);
}

const char *dbg_key_str0(const struct ubifs_info *c, const union ubifs_key *key)
{
/* dbg_lock must be held */
sprintf_key(c, key, dbg_key_buf0);
snprintf_key(c, key, dbg_key_buf0, sizeof(dbg_key_buf0) - 1);
return dbg_key_buf0;
}

const char *dbg_key_str1(const struct ubifs_info *c, const union ubifs_key *key)
{
/* dbg_lock must be held */
sprintf_key(c, key, dbg_key_buf1);
snprintf_key(c, key, dbg_key_buf1, sizeof(dbg_key_buf1) - 1);
return dbg_key_buf1;
}

Expand Down

0 comments on commit 699b464

Please sign in to comment.