Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 274969
b: refs/heads/master
c: 92abc47
h: refs/heads/master
i:
  274967: 2515f7f
v: v3
  • Loading branch information
Andres Salomon authored and Artem Bityutskiy committed Oct 19, 2011
1 parent 0209349 commit 2d574ed
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 5 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: 23b1a99b87f3fc9e4242b98b2af3c9bed210f048
refs/heads/master: 92abc475d8de1c29373f6d96ed63d8ecaa199d25
9 changes: 7 additions & 2 deletions trunk/fs/jffs2/compr.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,18 @@ uint16_t jffs2_compress(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
uint32_t *datalen, uint32_t *cdatalen)
{
int ret = JFFS2_COMPR_NONE;
int compr_ret;
int mode, compr_ret;
struct jffs2_compressor *this, *best=NULL;
unsigned char *output_buf = NULL, *tmp_buf;
uint32_t orig_slen, orig_dlen;
uint32_t best_slen=0, best_dlen=0;

switch (jffs2_compression_mode) {
if (c->mount_opts.override_compr)
mode = c->mount_opts.compr;
else
mode = jffs2_compression_mode;

switch (mode) {
case JFFS2_COMPR_MODE_NONE:
break;
case JFFS2_COMPR_MODE_PRIORITY:
Expand Down
2 changes: 1 addition & 1 deletion trunk/fs/jffs2/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ void jffs2_dirty_inode(struct inode *inode, int flags)
jffs2_do_setattr(inode, &iattr);
}

int jffs2_remount_fs (struct super_block *sb, int *flags, char *data)
int jffs2_do_remount_fs(struct super_block *sb, int *flags, char *data)
{
struct jffs2_sb_info *c = JFFS2_SB_INFO(sb);

Expand Down
6 changes: 6 additions & 0 deletions trunk/fs/jffs2/jffs2_fs_sb.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@

struct jffs2_inodirty;

struct jffs2_mount_opts {
bool override_compr;
unsigned int compr;
};

/* A struct for the overall file system control. Pointers to
jffs2_sb_info structs are named `c' in the source code.
Nee jffs_control
Expand Down Expand Up @@ -126,6 +131,7 @@ struct jffs2_sb_info {
#endif

struct jffs2_summary *summary; /* Summary information */
struct jffs2_mount_opts mount_opts;

#ifdef CONFIG_JFFS2_FS_XATTR
#define XATTRINDEX_HASHSIZE (57)
Expand Down
2 changes: 1 addition & 1 deletion trunk/fs/jffs2/os-linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ void jffs2_dirty_inode(struct inode *inode, int flags);
struct inode *jffs2_new_inode (struct inode *dir_i, umode_t mode,
struct jffs2_raw_inode *ri);
int jffs2_statfs (struct dentry *, struct kstatfs *);
int jffs2_remount_fs (struct super_block *, int *, char *);
int jffs2_do_remount_fs(struct super_block *, int *, char *);
int jffs2_do_fill_super(struct super_block *sb, void *data, int silent);
void jffs2_gc_release_inode(struct jffs2_sb_info *c,
struct jffs2_inode_info *f);
Expand Down
97 changes: 97 additions & 0 deletions trunk/fs/jffs2/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
#include <linux/fs.h>
#include <linux/err.h>
#include <linux/mount.h>
#include <linux/parser.h>
#include <linux/jffs2.h>
#include <linux/pagemap.h>
#include <linux/mtd/super.h>
#include <linux/ctype.h>
#include <linux/namei.h>
#include <linux/seq_file.h>
#include <linux/exportfs.h>
#include "compr.h"
#include "nodelist.h"
Expand Down Expand Up @@ -75,6 +77,29 @@ static void jffs2_write_super(struct super_block *sb)
unlock_super(sb);
}

static const char *jffs2_compr_name(unsigned int compr)
{
switch (compr) {
case JFFS2_COMPR_MODE_NONE:
return "none";
default:
/* should never happen; programmer error */
WARN_ON(1);
return "";
}
}

static int jffs2_show_options(struct seq_file *s, struct vfsmount *mnt)
{
struct jffs2_sb_info *c = JFFS2_SB_INFO(mnt->mnt_sb);
struct jffs2_mount_opts *opts = &c->mount_opts;

if (opts->override_compr)
seq_printf(s, ",compr=%s", jffs2_compr_name(opts->compr));

return 0;
}

static int jffs2_sync_fs(struct super_block *sb, int wait)
{
struct jffs2_sb_info *c = JFFS2_SB_INFO(sb);
Expand Down Expand Up @@ -133,6 +158,71 @@ static const struct export_operations jffs2_export_ops = {
.fh_to_parent = jffs2_fh_to_parent,
};

/*
* JFFS2 mount options.
*
* Opt_override_compr: override default compressor
* Opt_err: just end of array marker
*/
enum {
Opt_override_compr,
Opt_err,
};

static const match_table_t tokens = {
{Opt_override_compr, "compr=%s"},
{Opt_err, NULL},
};

static int jffs2_parse_options(struct jffs2_sb_info *c, char *data)
{
substring_t args[MAX_OPT_ARGS];
char *p, *name;

if (!data)
return 0;

while ((p = strsep(&data, ","))) {
int token;

if (!*p)
continue;

token = match_token(p, tokens, args);
switch (token) {
case Opt_override_compr:
name = match_strdup(&args[0]);

if (!name)
return -ENOMEM;
if (!strcmp(name, "none")) {
c->mount_opts.compr = JFFS2_COMPR_MODE_NONE;
c->mount_opts.override_compr = true;
}
kfree(name);
break;
default:
printk(KERN_ERR "JFFS2 Error: unrecognized mount option '%s' or missing value\n",
p);
return -EINVAL;
}
}

return 0;
}

static int jffs2_remount_fs(struct super_block *sb, int *flags, char *data)
{
struct jffs2_sb_info *c = JFFS2_SB_INFO(sb);
int err;

err = jffs2_parse_options(c, data);
if (err)
return -EINVAL;

return jffs2_do_remount_fs(sb, flags, data);
}

static const struct super_operations jffs2_super_operations =
{
.alloc_inode = jffs2_alloc_inode,
Expand All @@ -143,6 +233,7 @@ static const struct super_operations jffs2_super_operations =
.remount_fs = jffs2_remount_fs,
.evict_inode = jffs2_evict_inode,
.dirty_inode = jffs2_dirty_inode,
.show_options = jffs2_show_options,
.sync_fs = jffs2_sync_fs,
};

Expand All @@ -166,6 +257,12 @@ static int jffs2_fill_super(struct super_block *sb, void *data, int silent)
c->os_priv = sb;
sb->s_fs_info = c;

ret = jffs2_parse_options(c, data);
if (ret) {
kfree(c);
return -EINVAL;
}

/* Initialize JFFS2 superblock locks, the further initialization will
* be done later */
mutex_init(&c->alloc_sem);
Expand Down

0 comments on commit 2d574ed

Please sign in to comment.