MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / fs / jffs2.org / fs.c
blob6f49a3030d866458d89976cb2b67ad4523e5e591
1 /*
2 * JFFS2 -- Journalling Flash File System, Version 2.
4 * Copyright (C) 2001-2003 Red Hat, Inc.
6 * Created by David Woodhouse <dwmw2@redhat.com>
8 * For licensing information, see the file 'LICENCE' in this directory.
10 * $Id: fs.c,v 1.46 2004/07/13 08:56:54 dwmw2 Exp $
14 #include <linux/version.h>
15 #include <linux/config.h>
16 #include <linux/kernel.h>
17 #include <linux/sched.h>
18 #include <linux/fs.h>
19 #include <linux/list.h>
20 #include <linux/mtd/mtd.h>
21 #include <linux/pagemap.h>
22 #include <linux/slab.h>
23 #include <linux/vfs.h>
24 #include <linux/crc32.h>
25 #include "nodelist.h"
28 static int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)
30 struct jffs2_full_dnode *old_metadata, *new_metadata;
31 struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
32 struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
33 struct jffs2_raw_inode *ri;
34 unsigned short dev;
35 unsigned char *mdata = NULL;
36 int mdatalen = 0;
37 unsigned int ivalid;
38 uint32_t phys_ofs, alloclen;
39 int ret;
40 D1(printk(KERN_DEBUG "jffs2_setattr(): ino #%lu\n", inode->i_ino));
41 ret = inode_change_ok(inode, iattr);
42 if (ret)
43 return ret;
45 /* Special cases - we don't want more than one data node
46 for these types on the medium at any time. So setattr
47 must read the original data associated with the node
48 (i.e. the device numbers or the target name) and write
49 it out again with the appropriate data attached */
50 if (S_ISBLK(inode->i_mode) || S_ISCHR(inode->i_mode)) {
51 /* For these, we don't actually need to read the old node */
52 dev = old_encode_dev(inode->i_rdev);
53 mdata = (char *)&dev;
54 mdatalen = sizeof(dev);
55 D1(printk(KERN_DEBUG "jffs2_setattr(): Writing %d bytes of kdev_t\n", mdatalen));
56 } else if (S_ISLNK(inode->i_mode)) {
57 mdatalen = f->metadata->size;
58 mdata = kmalloc(f->metadata->size, GFP_USER);
59 if (!mdata)
60 return -ENOMEM;
61 ret = jffs2_read_dnode(c, f, f->metadata, mdata, 0, mdatalen);
62 if (ret) {
63 kfree(mdata);
64 return ret;
66 D1(printk(KERN_DEBUG "jffs2_setattr(): Writing %d bytes of symlink target\n", mdatalen));
69 ri = jffs2_alloc_raw_inode();
70 if (!ri) {
71 if (S_ISLNK(inode->i_mode))
72 kfree(mdata);
73 return -ENOMEM;
76 ret = jffs2_reserve_space(c, sizeof(*ri) + mdatalen, &phys_ofs, &alloclen, ALLOC_NORMAL);
77 if (ret) {
78 jffs2_free_raw_inode(ri);
79 if (S_ISLNK(inode->i_mode & S_IFMT))
80 kfree(mdata);
81 return ret;
83 down(&f->sem);
84 ivalid = iattr->ia_valid;
86 ri->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
87 ri->nodetype = cpu_to_je16(JFFS2_NODETYPE_INODE);
88 ri->totlen = cpu_to_je32(sizeof(*ri) + mdatalen);
89 ri->hdr_crc = cpu_to_je32(crc32(0, ri, sizeof(struct jffs2_unknown_node)-4));
91 ri->ino = cpu_to_je32(inode->i_ino);
92 ri->version = cpu_to_je32(++f->highest_version);
94 ri->uid = cpu_to_je16((ivalid & ATTR_UID)?iattr->ia_uid:inode->i_uid);
95 ri->gid = cpu_to_je16((ivalid & ATTR_GID)?iattr->ia_gid:inode->i_gid);
97 if (ivalid & ATTR_MODE)
98 if (iattr->ia_mode & S_ISGID &&
99 !in_group_p(je16_to_cpu(ri->gid)) && !capable(CAP_FSETID))
100 ri->mode = cpu_to_jemode(iattr->ia_mode & ~S_ISGID);
101 else
102 ri->mode = cpu_to_jemode(iattr->ia_mode);
103 else
104 ri->mode = cpu_to_jemode(inode->i_mode);
107 ri->isize = cpu_to_je32((ivalid & ATTR_SIZE)?iattr->ia_size:inode->i_size);
108 ri->atime = cpu_to_je32(I_SEC((ivalid & ATTR_ATIME)?iattr->ia_atime:inode->i_atime));
109 ri->mtime = cpu_to_je32(I_SEC((ivalid & ATTR_MTIME)?iattr->ia_mtime:inode->i_mtime));
110 ri->ctime = cpu_to_je32(I_SEC((ivalid & ATTR_CTIME)?iattr->ia_ctime:inode->i_ctime));
112 ri->offset = cpu_to_je32(0);
113 ri->csize = ri->dsize = cpu_to_je32(mdatalen);
114 ri->compr = JFFS2_COMPR_NONE;
115 if (ivalid & ATTR_SIZE && inode->i_size < iattr->ia_size) {
116 /* It's an extension. Make it a hole node */
117 ri->compr = JFFS2_COMPR_ZERO;
118 ri->dsize = cpu_to_je32(iattr->ia_size - inode->i_size);
119 ri->offset = cpu_to_je32(inode->i_size);
121 ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8));
122 if (mdatalen)
123 ri->data_crc = cpu_to_je32(crc32(0, mdata, mdatalen));
124 else
125 ri->data_crc = cpu_to_je32(0);
127 new_metadata = jffs2_write_dnode(c, f, ri, mdata, mdatalen, phys_ofs, ALLOC_NORMAL);
128 if (S_ISLNK(inode->i_mode))
129 kfree(mdata);
131 if (IS_ERR(new_metadata)) {
132 jffs2_complete_reservation(c);
133 jffs2_free_raw_inode(ri);
134 up(&f->sem);
135 return PTR_ERR(new_metadata);
137 /* It worked. Update the inode */
138 inode->i_atime = ITIME(je32_to_cpu(ri->atime));
139 inode->i_ctime = ITIME(je32_to_cpu(ri->ctime));
140 inode->i_mtime = ITIME(je32_to_cpu(ri->mtime));
141 inode->i_mode = jemode_to_cpu(ri->mode);
142 inode->i_uid = je16_to_cpu(ri->uid);
143 inode->i_gid = je16_to_cpu(ri->gid);
146 old_metadata = f->metadata;
148 if (ivalid & ATTR_SIZE && inode->i_size > iattr->ia_size)
149 jffs2_truncate_fraglist (c, &f->fragtree, iattr->ia_size);
151 if (ivalid & ATTR_SIZE && inode->i_size < iattr->ia_size) {
152 jffs2_add_full_dnode_to_inode(c, f, new_metadata);
153 inode->i_size = iattr->ia_size;
154 f->metadata = NULL;
155 } else {
156 f->metadata = new_metadata;
158 if (old_metadata) {
159 jffs2_mark_node_obsolete(c, old_metadata->raw);
160 jffs2_free_full_dnode(old_metadata);
162 jffs2_free_raw_inode(ri);
164 up(&f->sem);
165 jffs2_complete_reservation(c);
167 /* We have to do the vmtruncate() without f->sem held, since
168 some pages may be locked and waiting for it in readpage().
169 We are protected from a simultaneous write() extending i_size
170 back past iattr->ia_size, because do_truncate() holds the
171 generic inode semaphore. */
172 if (ivalid & ATTR_SIZE && inode->i_size > iattr->ia_size)
173 vmtruncate(inode, iattr->ia_size);
175 return 0;
178 int jffs2_setattr(struct dentry *dentry, struct iattr *iattr)
180 return jffs2_do_setattr(dentry->d_inode, iattr);
183 int jffs2_statfs(struct super_block *sb, struct kstatfs *buf)
185 struct jffs2_sb_info *c = JFFS2_SB_INFO(sb);
186 unsigned long avail;
188 buf->f_type = JFFS2_SUPER_MAGIC;
189 buf->f_bsize = 1 << PAGE_SHIFT;
190 buf->f_blocks = c->flash_size >> PAGE_SHIFT;
191 buf->f_files = 0;
192 buf->f_ffree = 0;
193 buf->f_namelen = JFFS2_MAX_NAME_LEN;
195 spin_lock(&c->erase_completion_lock);
197 avail = c->dirty_size + c->free_size;
198 if (avail > c->sector_size * c->resv_blocks_write)
199 avail -= c->sector_size * c->resv_blocks_write;
200 else
201 avail = 0;
203 buf->f_bavail = buf->f_bfree = avail >> PAGE_SHIFT;
205 D1(jffs2_dump_block_lists(c));
207 spin_unlock(&c->erase_completion_lock);
209 return 0;
213 void jffs2_clear_inode (struct inode *inode)
215 /* We can forget about this inode for now - drop all
216 * the nodelists associated with it, etc.
218 struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
219 struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
221 D1(printk(KERN_DEBUG "jffs2_clear_inode(): ino #%lu mode %o\n", inode->i_ino, inode->i_mode));
223 jffs2_do_clear_inode(c, f);
226 void jffs2_read_inode (struct inode *inode)
228 struct jffs2_inode_info *f;
229 struct jffs2_sb_info *c;
230 struct jffs2_raw_inode latest_node;
231 int ret;
233 D1(printk(KERN_DEBUG "jffs2_read_inode(): inode->i_ino == %lu\n", inode->i_ino));
235 f = JFFS2_INODE_INFO(inode);
236 c = JFFS2_SB_INFO(inode->i_sb);
238 jffs2_init_inode_info(f);
240 ret = jffs2_do_read_inode(c, f, inode->i_ino, &latest_node);
242 if (ret) {
243 make_bad_inode(inode);
244 up(&f->sem);
245 return;
247 inode->i_mode = jemode_to_cpu(latest_node.mode);
248 inode->i_uid = je16_to_cpu(latest_node.uid);
249 inode->i_gid = je16_to_cpu(latest_node.gid);
250 inode->i_size = je32_to_cpu(latest_node.isize);
251 inode->i_atime = ITIME(je32_to_cpu(latest_node.atime));
252 inode->i_mtime = ITIME(je32_to_cpu(latest_node.mtime));
253 inode->i_ctime = ITIME(je32_to_cpu(latest_node.ctime));
255 inode->i_nlink = f->inocache->nlink;
257 inode->i_blksize = PAGE_SIZE;
258 inode->i_blocks = (inode->i_size + 511) >> 9;
260 switch (inode->i_mode & S_IFMT) {
261 jint16_t rdev;
263 case S_IFLNK:
264 inode->i_op = &jffs2_symlink_inode_operations;
265 break;
267 case S_IFDIR:
269 struct jffs2_full_dirent *fd;
271 for (fd=f->dents; fd; fd = fd->next) {
272 if (fd->type == DT_DIR && fd->ino)
273 inode->i_nlink++;
275 /* and '..' */
276 inode->i_nlink++;
277 /* Root dir gets i_nlink 3 for some reason */
278 if (inode->i_ino == 1)
279 inode->i_nlink++;
281 inode->i_op = &jffs2_dir_inode_operations;
282 inode->i_fop = &jffs2_dir_operations;
283 break;
285 case S_IFREG:
286 inode->i_op = &jffs2_file_inode_operations;
287 inode->i_fop = &jffs2_file_operations;
288 inode->i_mapping->a_ops = &jffs2_file_address_operations;
289 inode->i_mapping->nrpages = 0;
290 break;
292 case S_IFBLK:
293 case S_IFCHR:
294 /* Read the device numbers from the media */
295 D1(printk(KERN_DEBUG "Reading device numbers from flash\n"));
296 if (jffs2_read_dnode(c, f, f->metadata, (char *)&rdev, 0, sizeof(rdev)) < 0) {
297 /* Eep */
298 printk(KERN_NOTICE "Read device numbers for inode %lu failed\n", (unsigned long)inode->i_ino);
299 up(&f->sem);
300 jffs2_do_clear_inode(c, f);
301 make_bad_inode(inode);
302 return;
305 case S_IFSOCK:
306 case S_IFIFO:
307 inode->i_op = &jffs2_file_inode_operations;
308 init_special_inode(inode, inode->i_mode,
309 old_decode_dev((je16_to_cpu(rdev))));
310 break;
312 default:
313 printk(KERN_WARNING "jffs2_read_inode(): Bogus imode %o for ino %lu\n", inode->i_mode, (unsigned long)inode->i_ino);
316 up(&f->sem);
318 D1(printk(KERN_DEBUG "jffs2_read_inode() returning\n"));
321 void jffs2_dirty_inode(struct inode *inode)
323 struct iattr iattr;
325 if (!(inode->i_state & I_DIRTY_DATASYNC)) {
326 D2(printk(KERN_DEBUG "jffs2_dirty_inode() not calling setattr() for ino #%lu\n", inode->i_ino));
327 return;
330 D1(printk(KERN_DEBUG "jffs2_dirty_inode() calling setattr() for ino #%lu\n", inode->i_ino));
332 iattr.ia_valid = ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_ATIME|ATTR_MTIME|ATTR_CTIME;
333 iattr.ia_mode = inode->i_mode;
334 iattr.ia_uid = inode->i_uid;
335 iattr.ia_gid = inode->i_gid;
336 iattr.ia_atime = inode->i_atime;
337 iattr.ia_mtime = inode->i_mtime;
338 iattr.ia_ctime = inode->i_ctime;
340 jffs2_do_setattr(inode, &iattr);
343 int jffs2_remount_fs (struct super_block *sb, int *flags, char *data)
345 struct jffs2_sb_info *c = JFFS2_SB_INFO(sb);
347 if (c->flags & JFFS2_SB_FLAG_RO && !(sb->s_flags & MS_RDONLY))
348 return -EROFS;
350 /* We stop if it was running, then restart if it needs to.
351 This also catches the case where it was stopped and this
352 is just a remount to restart it.
353 Flush the writebuffer, if neccecary, else we loose it */
354 if (!(sb->s_flags & MS_RDONLY)) {
355 jffs2_stop_garbage_collect_thread(c);
356 down(&c->alloc_sem);
357 jffs2_flush_wbuf_pad(c);
358 up(&c->alloc_sem);
361 if (!(*flags & MS_RDONLY))
362 jffs2_start_garbage_collect_thread(c);
364 *flags |= MS_NOATIME;
366 return 0;
369 void jffs2_write_super (struct super_block *sb)
371 struct jffs2_sb_info *c = JFFS2_SB_INFO(sb);
372 sb->s_dirt = 0;
374 if (sb->s_flags & MS_RDONLY)
375 return;
377 D1(printk(KERN_DEBUG "jffs2_write_super()\n"));
378 jffs2_garbage_collect_trigger(c);
379 jffs2_erase_pending_blocks(c, 0);
380 jffs2_flush_wbuf_gc(c, 0);
384 /* jffs2_new_inode: allocate a new inode and inocache, add it to the hash,
385 fill in the raw_inode while you're at it. */
386 struct inode *jffs2_new_inode (struct inode *dir_i, int mode, struct jffs2_raw_inode *ri)
388 struct inode *inode;
389 struct super_block *sb = dir_i->i_sb;
390 struct jffs2_sb_info *c;
391 struct jffs2_inode_info *f;
392 int ret;
394 D1(printk(KERN_DEBUG "jffs2_new_inode(): dir_i %ld, mode 0x%x\n", dir_i->i_ino, mode));
396 c = JFFS2_SB_INFO(sb);
398 inode = new_inode(sb);
400 if (!inode)
401 return ERR_PTR(-ENOMEM);
403 f = JFFS2_INODE_INFO(inode);
404 jffs2_init_inode_info(f);
406 memset(ri, 0, sizeof(*ri));
407 /* Set OS-specific defaults for new inodes */
408 ri->uid = cpu_to_je16(current->fsuid);
410 if (dir_i->i_mode & S_ISGID) {
411 ri->gid = cpu_to_je16(dir_i->i_gid);
412 if (S_ISDIR(mode))
413 mode |= S_ISGID;
414 } else {
415 ri->gid = cpu_to_je16(current->fsgid);
417 ri->mode = cpu_to_jemode(mode);
418 ret = jffs2_do_new_inode (c, f, mode, ri);
419 if (ret) {
420 make_bad_inode(inode);
421 iput(inode);
422 return ERR_PTR(ret);
424 inode->i_nlink = 1;
425 inode->i_ino = je32_to_cpu(ri->ino);
426 inode->i_mode = jemode_to_cpu(ri->mode);
427 inode->i_gid = je16_to_cpu(ri->gid);
428 inode->i_uid = je16_to_cpu(ri->uid);
429 inode->i_atime = inode->i_ctime = inode->i_mtime = CURRENT_TIME;
430 ri->atime = ri->mtime = ri->ctime = cpu_to_je32(I_SEC(inode->i_mtime));
432 inode->i_blksize = PAGE_SIZE;
433 inode->i_blocks = 0;
434 inode->i_size = 0;
436 insert_inode_hash(inode);
438 return inode;
442 int jffs2_do_fill_super(struct super_block *sb, void *data, int silent)
444 struct jffs2_sb_info *c;
445 struct inode *root_i;
446 int ret;
447 size_t blocks;
449 c = JFFS2_SB_INFO(sb);
451 #ifndef CONFIG_JFFS2_FS_NAND
452 if (c->mtd->type == MTD_NANDFLASH) {
453 printk(KERN_ERR "jffs2: Cannot operate on NAND flash unless jffs2 NAND support is compiled in.\n");
454 return -EINVAL;
456 #endif
458 c->flash_size = c->mtd->size;
461 * Check, if we have to concatenate physical blocks to larger virtual blocks
462 * to reduce the memorysize for c->blocks. (kmalloc allows max. 128K allocation)
464 c->sector_size = c->mtd->erasesize;
465 blocks = c->flash_size / c->sector_size;
466 while ((blocks * sizeof (struct jffs2_eraseblock)) > (128 * 1024)) {
467 blocks >>= 1;
468 c->sector_size <<= 1;
472 * Size alignment check
474 if ((c->sector_size * blocks) != c->flash_size) {
475 c->flash_size = c->sector_size * blocks;
476 printk(KERN_INFO "jffs2: Flash size not aligned to erasesize, reducing to %dKiB\n",
477 c->flash_size / 1024);
480 if (c->sector_size != c->mtd->erasesize)
481 printk(KERN_INFO "jffs2: Erase block size too small (%dKiB). Using virtual blocks size (%dKiB) instead\n",
482 c->mtd->erasesize / 1024, c->sector_size / 1024);
484 #if 0 // mask by Victor Yu. 12-22-2005
485 if (c->flash_size < 5*c->sector_size) {
486 printk(KERN_ERR "jffs2: Too few erase blocks (%d)\n", c->flash_size / c->sector_size);
487 return -EINVAL;
489 #endif
491 c->cleanmarker_size = sizeof(struct jffs2_unknown_node);
492 /* Joern -- stick alignment for weird 8-byte-page flash here */
494 /* NAND (or other bizarre) flash... do setup accordingly */
495 ret = jffs2_flash_setup(c);
496 if (ret)
497 return ret;
499 c->inocache_list = kmalloc(INOCACHE_HASHSIZE * sizeof(struct jffs2_inode_cache *), GFP_KERNEL);
500 if (!c->inocache_list) {
501 ret = -ENOMEM;
502 goto out_wbuf;
504 memset(c->inocache_list, 0, INOCACHE_HASHSIZE * sizeof(struct jffs2_inode_cache *));
506 if ((ret = jffs2_do_mount_fs(c)))
507 goto out_inohash;
509 ret = -EINVAL;
511 D1(printk(KERN_DEBUG "jffs2_do_fill_super(): Getting root inode\n"));
512 root_i = iget(sb, 1);
513 if (is_bad_inode(root_i)) {
514 D1(printk(KERN_WARNING "get root inode failed\n"));
515 goto out_nodes;
518 D1(printk(KERN_DEBUG "jffs2_do_fill_super(): d_alloc_root()\n"));
519 sb->s_root = d_alloc_root(root_i);
520 if (!sb->s_root)
521 goto out_root_i;
523 #if LINUX_VERSION_CODE >= 0x20403
524 sb->s_maxbytes = 0xFFFFFFFF;
525 #endif
526 sb->s_blocksize = PAGE_CACHE_SIZE;
527 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
528 sb->s_magic = JFFS2_SUPER_MAGIC;
529 if (!(sb->s_flags & MS_RDONLY))
530 jffs2_start_garbage_collect_thread(c);
531 return 0;
533 out_root_i:
534 iput(root_i);
535 out_nodes:
536 jffs2_free_ino_caches(c);
537 jffs2_free_raw_node_refs(c);
538 kfree(c->blocks);
539 out_inohash:
540 kfree(c->inocache_list);
541 out_wbuf:
542 jffs2_flash_cleanup(c);
544 return ret;
547 void jffs2_gc_release_inode(struct jffs2_sb_info *c,
548 struct jffs2_inode_info *f)
550 iput(OFNI_EDONI_2SFFJ(f));
553 struct jffs2_inode_info *jffs2_gc_fetch_inode(struct jffs2_sb_info *c,
554 int inum, int nlink)
556 struct inode *inode;
557 struct jffs2_inode_cache *ic;
558 if (!nlink) {
559 /* The inode has zero nlink but its nodes weren't yet marked
560 obsolete. This has to be because we're still waiting for
561 the final (close() and) iput() to happen.
563 There's a possibility that the final iput() could have
564 happened while we were contemplating. In order to ensure
565 that we don't cause a new read_inode() (which would fail)
566 for the inode in question, we use ilookup() in this case
567 instead of iget().
569 The nlink can't _become_ zero at this point because we're
570 holding the alloc_sem, and jffs2_do_unlink() would also
571 need that while decrementing nlink on any inode.
573 inode = ilookup(OFNI_BS_2SFFJ(c), inum);
574 if (!inode) {
575 D1(printk(KERN_DEBUG "ilookup() failed for ino #%u; inode is probably deleted.\n",
576 inum));
578 spin_lock(&c->inocache_lock);
579 ic = jffs2_get_ino_cache(c, inum);
580 if (!ic) {
581 D1(printk(KERN_DEBUG "Inode cache for ino #%u is gone.\n", inum));
582 spin_unlock(&c->inocache_lock);
583 return NULL;
585 if (ic->state != INO_STATE_CHECKEDABSENT) {
586 /* Wait for progress. Don't just loop */
587 D1(printk(KERN_DEBUG "Waiting for ino #%u in state %d\n",
588 ic->ino, ic->state));
589 sleep_on_spinunlock(&c->inocache_wq, &c->inocache_lock);
590 } else {
591 spin_unlock(&c->inocache_lock);
594 return NULL;
596 } else {
597 /* Inode has links to it still; they're not going away because
598 jffs2_do_unlink() would need the alloc_sem and we have it.
599 Just iget() it, and if read_inode() is necessary that's OK.
601 inode = iget(OFNI_BS_2SFFJ(c), inum);
602 if (!inode)
603 return ERR_PTR(-ENOMEM);
605 if (is_bad_inode(inode)) {
606 printk(KERN_NOTICE "Eep. read_inode() failed for ino #%u. nlink %d\n",
607 inum, nlink);
608 /* NB. This will happen again. We need to do something appropriate here. */
609 iput(inode);
610 return ERR_PTR(-EIO);
613 return JFFS2_INODE_INFO(inode);
616 unsigned char *jffs2_gc_fetch_page(struct jffs2_sb_info *c,
617 struct jffs2_inode_info *f,
618 unsigned long offset,
619 unsigned long *priv)
621 struct inode *inode = OFNI_EDONI_2SFFJ(f);
622 struct page *pg;
624 pg = read_cache_page(inode->i_mapping, offset >> PAGE_CACHE_SHIFT,
625 (void *)jffs2_do_readpage_unlock, inode);
626 if (IS_ERR(pg))
627 return (void *)pg;
629 *priv = (unsigned long)pg;
630 return kmap(pg);
633 void jffs2_gc_release_page(struct jffs2_sb_info *c,
634 unsigned char *ptr,
635 unsigned long *priv)
637 struct page *pg = (void *)*priv;
639 kunmap(pg);
640 page_cache_release(pg);
643 int jffs2_flash_setup(struct jffs2_sb_info *c) {
644 int ret = 0;
646 if (jffs2_cleanmarker_oob(c)) {
647 /* NAND flash... do setup accordingly */
648 ret = jffs2_nand_flash_setup(c);
649 if (ret)
650 return ret;
653 /* add setups for other bizarre flashes here... */
654 return ret;
657 void jffs2_flash_cleanup(struct jffs2_sb_info *c) {
659 if (jffs2_cleanmarker_oob(c)) {
660 jffs2_nand_flash_cleanup(c);
663 /* add cleanups for other bizarre flashes here... */