Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 255052
b: refs/heads/master
c: ae380ce
h: refs/heads/master
v: v3
  • Loading branch information
Artem Bityutskiy authored and Artem Bityutskiy committed Jul 4, 2011
1 parent 33ef412 commit 2f1f9e0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 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: 549c999a768a7a144c60a0faa58f34c48f39112b
refs/heads/master: ae380ce04731579f45f27b3a84d7d8d8ee1f9b1b
18 changes: 13 additions & 5 deletions trunk/fs/ubifs/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -2815,8 +2815,8 @@ static struct dentry *dfs_rootdir;
int dbg_debugfs_init(void)
{
dfs_rootdir = debugfs_create_dir("ubifs", NULL);
if (IS_ERR(dfs_rootdir)) {
int err = PTR_ERR(dfs_rootdir);
if (IS_ERR_OR_NULL(dfs_rootdir)) {
int err = dfs_rootdir ? PTR_ERR(dfs_rootdir) : -ENODEV;
ubifs_err("cannot create \"ubifs\" debugfs directory, "
"error %d\n", err);
return err;
Expand Down Expand Up @@ -2880,12 +2880,20 @@ static const struct file_operations dfs_fops = {
*/
int dbg_debugfs_init_fs(struct ubifs_info *c)
{
int err;
int err, n;
const char *fname;
struct dentry *dent;
struct ubifs_debug_info *d = c->dbg;

sprintf(d->dfs_dir_name, "ubi%d_%d", c->vi.ubi_num, c->vi.vol_id);
n = snprintf(d->dfs_dir_name, UBIFS_DFS_DIR_LEN + 1, UBIFS_DFS_DIR_NAME,
c->vi.ubi_num, c->vi.vol_id);
if (n == UBIFS_DFS_DIR_LEN) {
/* The array size is too small */
fname = UBIFS_DFS_DIR_NAME;
dent = ERR_PTR(-EINVAL);
goto out;
}

fname = d->dfs_dir_name;
dent = debugfs_create_dir(fname, dfs_rootdir);
if (IS_ERR_OR_NULL(dent))
Expand Down Expand Up @@ -2916,7 +2924,7 @@ int dbg_debugfs_init_fs(struct ubifs_info *c)
debugfs_remove_recursive(d->dfs_dir);
out:
err = dent ? PTR_ERR(dent) : -ENODEV;
ubifs_err("cannot create \"%s\" debugfs directory, error %d\n",
ubifs_err("cannot create \"%s\" debugfs filr or directory, error %d\n",
fname, err);
return err;
}
Expand Down
11 changes: 9 additions & 2 deletions trunk/fs/ubifs/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ typedef int (*dbg_znode_callback)(struct ubifs_info *c,

#include <linux/random.h>

/*
* The UBIFS debugfs directory name pattern and maximum name length (3 for "ubi"
* + 1 for "_" and plus 2x2 for 2 UBI numbers and 1 for the trailing zero byte.
*/
#define UBIFS_DFS_DIR_NAME "ubi%d_%d"
#define UBIFS_DFS_DIR_LEN (3 + 1 + 2*2 + 1)

/**
* ubifs_debug_info - per-FS debugging information.
* @old_zroot: old index root - used by 'dbg_check_old_index()'
Expand Down Expand Up @@ -84,7 +91,7 @@ struct ubifs_debug_info {
long long saved_free;
int saved_idx_gc_cnt;

char dfs_dir_name[100];
char dfs_dir_name[UBIFS_DFS_DIR_LEN + 1];
struct dentry *dfs_dir;
struct dentry *dfs_dump_lprops;
struct dentry *dfs_dump_budg;
Expand Down Expand Up @@ -313,7 +320,7 @@ void dbg_debugfs_exit_fs(struct ubifs_info *c);

/* Use "if (0)" to make compiler check arguments even if debugging is off */
#define ubifs_assert(expr) do { \
if (0 && (expr)) \
if (0) \
printk(KERN_CRIT "UBIFS assert failed in %s at %u (pid %d)\n", \
__func__, __LINE__, current->pid); \
} while (0)
Expand Down

0 comments on commit 2f1f9e0

Please sign in to comment.