Mercurial > yaffs-ecoscentric-gpl
annotate yaffs_fs.c @ 398:a688086ddd0c
Add nfs support.
This is a modified version of the patch suplied by
Jean-Loup Sabatier
Signed-off-by: Charles Manning <cdhmanning@gmail.com>
| author | Charles Manning <cdhmanning@gmail.com> |
|---|---|
| date | Tue, 30 Mar 2010 14:42:21 +1300 |
| parents | 36569f389824 |
| children | fb6ffedcfa89 |
| rev | line source |
|---|---|
| 7 | 1 /* |
| 168 | 2 * YAFFS: Yet Another Flash File System. A NAND-flash specific file system. |
| 7 | 3 * |
|
277
b55b92214eea
This file escaped copyright date update. Fixed.
wookey <wookey>
parents:
276
diff
changeset
|
4 * Copyright (C) 2002-2009 Aleph One Ltd. |
| 7 | 5 * for Toby Churchill Ltd and Brightstar Engineering |
| 6 * | |
| 7 * Created by Charles Manning <charles@aleph1.co.uk> | |
| 168 | 8 * Acknowledgements: |
| 9 * Luc van OostenRyck for numerous patches. | |
| 10 * Nick Bane for numerous patches. | |
| 11 * Nick Bane for 2.5/2.6 integration. | |
| 12 * Andras Toth for mknod rdev issue. | |
| 13 * Michael Fischer for finding the problem with inode inconsistency. | |
| 14 * Some code bodily lifted from JFFS | |
| 7 | 15 * |
| 16 * This program is free software; you can redistribute it and/or modify | |
| 17 * it under the terms of the GNU General Public License version 2 as | |
| 18 * published by the Free Software Foundation. | |
| 168 | 19 */ |
| 20 | |
| 21 /* | |
| 22 * | |
| 7 | 23 * This is the file system front-end to YAFFS that hooks it up to |
| 24 * the VFS. | |
| 25 * | |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
26 * Special notes: |
| 76 | 27 * >> 2.4: sb->u.generic_sbp points to the yaffs_Device associated with |
| 28 * this superblock | |
| 29 * >> 2.6: sb->s_fs_info points to the yaffs_Device associated with this | |
| 30 * superblock | |
| 7 | 31 * >> inode->u.generic_ip points to the associated yaffs_Object. |
| 32 */ | |
| 33 | |
| 76 | 34 const char *yaffs_fs_c_version = |
| 388 | 35 "$Id: yaffs_fs.c,v 1.102 2010-03-15 23:10:33 charles Exp $"; |
| 7 | 36 extern const char *yaffs_guts_c_version; |
| 37 | |
| 166 | 38 #include <linux/version.h> |
|
374
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
39 |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
40 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)) |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
41 #define YAFFS_COMPILE_BACKGROUND |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
42 #endif |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
43 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
44 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)) |
| 7 | 45 #include <linux/config.h> |
| 166 | 46 #endif |
| 7 | 47 #include <linux/kernel.h> |
| 48 #include <linux/module.h> | |
| 49 #include <linux/slab.h> | |
| 50 #include <linux/init.h> | |
| 51 #include <linux/fs.h> | |
| 52 #include <linux/proc_fs.h> | |
| 27 | 53 #include <linux/smp_lock.h> |
| 7 | 54 #include <linux/pagemap.h> |
| 55 #include <linux/mtd/mtd.h> | |
| 56 #include <linux/interrupt.h> | |
| 57 #include <linux/string.h> | |
|
115
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
58 #include <linux/ctype.h> |
| 398 | 59 #include <linux/exportfs.h> |
| 7 | 60 |
|
374
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
61 #ifdef YAFFS_COMPILE_BACKGROUND |
|
372
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
62 #include <linux/kthread.h> |
|
374
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
63 #include <linux/delay.h> |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
64 #endif |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
65 |
|
372
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
66 |
|
204
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
67 #include "asm/div64.h" |
|
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
68 |
| 332 | 69 |
| 70 #define LOCK_TRACE 0 | |
| 71 | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
72 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0)) |
| 7 | 73 |
| 74 #include <linux/statfs.h> /* Added NCB 15-8-2003 */ | |
| 273 | 75 #include <linux/statfs.h> |
| 7 | 76 #define UnlockPage(p) unlock_page(p) |
| 77 #define Page_Uptodate(page) test_bit(PG_uptodate, &(page)->flags) | |
| 76 | 78 |
| 79 /* FIXME: use sb->s_id instead ? */ | |
| 80 #define yaffs_devname(sb, buf) bdevname(sb->s_bdev, buf) | |
| 7 | 81 |
| 82 #else | |
| 83 | |
| 84 #include <linux/locks.h> | |
|
37
843d9d0add74
Fix devname which was faked by always using "(unavailable)".
luc <luc>
parents:
36
diff
changeset
|
85 #define BDEVNAME_SIZE 0 |
|
843d9d0add74
Fix devname which was faked by always using "(unavailable)".
luc <luc>
parents:
36
diff
changeset
|
86 #define yaffs_devname(sb, buf) kdevname(sb->s_dev) |
| 7 | 87 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
88 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)) |
| 137 | 89 /* added NCB 26/5/2006 for 2.4.25-vrs2-tcl1 kernel */ |
| 90 #define __user | |
| 91 #endif | |
| 92 | |
| 7 | 93 #endif |
| 94 | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
95 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26)) |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
96 #define YPROC_ROOT (&proc_root) |
|
212
0107f21a03fb
Fix compilation on Linux 2.6.26, fix compilation warnings
charles <charles>
parents:
210
diff
changeset
|
97 #else |
|
0107f21a03fb
Fix compilation on Linux 2.6.26, fix compilation warnings
charles <charles>
parents:
210
diff
changeset
|
98 #define YPROC_ROOT NULL |
|
0107f21a03fb
Fix compilation on Linux 2.6.26, fix compilation warnings
charles <charles>
parents:
210
diff
changeset
|
99 #endif |
|
0107f21a03fb
Fix compilation on Linux 2.6.26, fix compilation warnings
charles <charles>
parents:
210
diff
changeset
|
100 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
101 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17)) |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
102 #define WRITE_SIZE_STR "writesize" |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
103 #define WRITE_SIZE(mtd) ((mtd)->writesize) |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
104 #else |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
105 #define WRITE_SIZE_STR "oobblock" |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
106 #define WRITE_SIZE(mtd) ((mtd)->oobblock) |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
107 #endif |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
108 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
109 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 27)) |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
110 #define YAFFS_USE_WRITE_BEGIN_END 1 |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
111 #else |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
112 #define YAFFS_USE_WRITE_BEGIN_END 0 |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
113 #endif |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
114 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
115 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 28)) |
| 266 | 116 static uint32_t YCALCBLOCKS(uint64_t partition_size, uint32_t block_size) |
| 117 { | |
| 118 uint64_t result = partition_size; | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
119 do_div(result, block_size); |
| 266 | 120 return (uint32_t)result; |
| 121 } | |
| 122 #else | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
123 #define YCALCBLOCKS(s, b) ((s)/(b)) |
| 266 | 124 #endif |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
125 |
| 273 | 126 #include <linux/uaccess.h> |
| 7 | 127 |
| 128 #include "yportenv.h" | |
| 342 | 129 #include "yaffs_trace.h" |
| 7 | 130 #include "yaffs_guts.h" |
| 131 | |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
132 #include "yaffs_linux.h" |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
133 |
| 7 | 134 #include <linux/mtd/mtd.h> |
| 135 #include "yaffs_mtdif.h" | |
| 179 | 136 #include "yaffs_mtdif1.h" |
| 7 | 137 #include "yaffs_mtdif2.h" |
| 138 | |
| 311 | 139 unsigned int yaffs_traceMask = YAFFS_TRACE_BAD_BLOCKS | YAFFS_TRACE_ALWAYS; |
| 179 | 140 unsigned int yaffs_wr_attempts = YAFFS_WR_ATTEMPTS; |
| 249 | 141 unsigned int yaffs_auto_checkpoint = 1; |
| 388 | 142 unsigned int yaffs_gc_control = 1; |
| 179 | 143 |
| 144 /* Module Parameters */ | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
145 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0)) |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
146 module_param(yaffs_traceMask, uint, 0644); |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
147 module_param(yaffs_wr_attempts, uint, 0644); |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
148 module_param(yaffs_auto_checkpoint, uint, 0644); |
| 388 | 149 module_param(yaffs_gc_control, uint, 0644); |
| 179 | 150 #else |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
151 MODULE_PARM(yaffs_traceMask, "i"); |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
152 MODULE_PARM(yaffs_wr_attempts, "i"); |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
153 MODULE_PARM(yaffs_auto_checkpoint, "i"); |
| 388 | 154 MODULE_PARM(yaffs_gc_control, "i"); |
| 179 | 155 #endif |
| 156 | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
157 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25)) |
|
210
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
158 /* use iget and read_inode */ |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
159 #define Y_IGET(sb, inum) iget((sb), (inum)) |
|
210
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
160 static void yaffs_read_inode(struct inode *inode); |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
161 |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
162 #else |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
163 /* Call local equivalent */ |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
164 #define YAFFS_USE_OWN_IGET |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
165 #define Y_IGET(sb, inum) yaffs_iget((sb), (inum)) |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
166 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
167 static struct inode *yaffs_iget(struct super_block *sb, unsigned long ino); |
|
210
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
168 #endif |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
169 |
| 76 | 170 /*#define T(x) printk x */ |
| 7 | 171 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
172 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 18)) |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
173 #define yaffs_InodeToObjectLV(iptr) ((iptr)->i_private) |
| 166 | 174 #else |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
175 #define yaffs_InodeToObjectLV(iptr) ((iptr)->u.generic_ip) |
| 166 | 176 #endif |
| 177 | |
| 178 #define yaffs_InodeToObject(iptr) ((yaffs_Object *)(yaffs_InodeToObjectLV(iptr))) | |
| 7 | 179 #define yaffs_DentryToObject(dptr) yaffs_InodeToObject((dptr)->d_inode) |
| 180 | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
181 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0)) |
| 7 | 182 #define yaffs_SuperToDevice(sb) ((yaffs_Device *)sb->s_fs_info) |
| 183 #else | |
| 184 #define yaffs_SuperToDevice(sb) ((yaffs_Device *)sb->u.generic_sbp) | |
| 185 #endif | |
| 186 | |
| 280 | 187 |
| 188 #define update_dir_time(dir) do {\ | |
| 189 (dir)->i_ctime = (dir)->i_mtime = CURRENT_TIME; \ | |
| 190 } while(0) | |
| 191 | |
| 7 | 192 static void yaffs_put_super(struct super_block *sb); |
| 193 | |
| 76 | 194 static ssize_t yaffs_file_write(struct file *f, const char *buf, size_t n, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
195 loff_t *pos); |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
196 static ssize_t yaffs_hold_space(struct file *f); |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
197 static void yaffs_release_space(struct file *f); |
| 7 | 198 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
199 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17)) |
| 143 | 200 static int yaffs_file_flush(struct file *file, fl_owner_t id); |
| 201 #else | |
| 76 | 202 static int yaffs_file_flush(struct file *file); |
| 143 | 203 #endif |
| 7 | 204 |
| 76 | 205 static int yaffs_sync_object(struct file *file, struct dentry *dentry, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
206 int datasync); |
| 7 | 207 |
| 208 static int yaffs_readdir(struct file *f, void *dirent, filldir_t filldir); | |
| 209 | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
210 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0)) |
| 76 | 211 static int yaffs_create(struct inode *dir, struct dentry *dentry, int mode, |
| 212 struct nameidata *n); | |
| 213 static struct dentry *yaffs_lookup(struct inode *dir, struct dentry *dentry, | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
214 struct nameidata *n); |
| 7 | 215 #else |
| 216 static int yaffs_create(struct inode *dir, struct dentry *dentry, int mode); | |
| 76 | 217 static struct dentry *yaffs_lookup(struct inode *dir, struct dentry *dentry); |
| 7 | 218 #endif |
| 76 | 219 static int yaffs_link(struct dentry *old_dentry, struct inode *dir, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
220 struct dentry *dentry); |
| 76 | 221 static int yaffs_unlink(struct inode *dir, struct dentry *dentry); |
| 222 static int yaffs_symlink(struct inode *dir, struct dentry *dentry, | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
223 const char *symname); |
| 76 | 224 static int yaffs_mkdir(struct inode *dir, struct dentry *dentry, int mode); |
| 7 | 225 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
226 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0)) |
| 76 | 227 static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
228 dev_t dev); |
| 7 | 229 #else |
| 76 | 230 static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
231 int dev); |
| 7 | 232 #endif |
| 76 | 233 static int yaffs_rename(struct inode *old_dir, struct dentry *old_dentry, |
| 234 struct inode *new_dir, struct dentry *new_dentry); | |
| 7 | 235 static int yaffs_setattr(struct dentry *dentry, struct iattr *attr); |
| 236 | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
237 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17)) |
| 143 | 238 static int yaffs_sync_fs(struct super_block *sb, int wait); |
| 239 static void yaffs_write_super(struct super_block *sb); | |
| 240 #else | |
| 129 | 241 static int yaffs_sync_fs(struct super_block *sb); |
| 242 static int yaffs_write_super(struct super_block *sb); | |
| 143 | 243 #endif |
| 129 | 244 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
245 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17)) |
| 143 | 246 static int yaffs_statfs(struct dentry *dentry, struct kstatfs *buf); |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
247 #elif (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0)) |
| 7 | 248 static int yaffs_statfs(struct super_block *sb, struct kstatfs *buf); |
| 249 #else | |
| 250 static int yaffs_statfs(struct super_block *sb, struct statfs *buf); | |
| 251 #endif | |
| 252 | |
|
212
0107f21a03fb
Fix compilation on Linux 2.6.26, fix compilation warnings
charles <charles>
parents:
210
diff
changeset
|
253 #ifdef YAFFS_HAS_PUT_INODE |
| 76 | 254 static void yaffs_put_inode(struct inode *inode); |
|
212
0107f21a03fb
Fix compilation on Linux 2.6.26, fix compilation warnings
charles <charles>
parents:
210
diff
changeset
|
255 #endif |
|
0107f21a03fb
Fix compilation on Linux 2.6.26, fix compilation warnings
charles <charles>
parents:
210
diff
changeset
|
256 |
| 7 | 257 static void yaffs_delete_inode(struct inode *); |
| 258 static void yaffs_clear_inode(struct inode *); | |
| 259 | |
| 76 | 260 static int yaffs_readpage(struct file *file, struct page *page); |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
261 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0)) |
| 23 | 262 static int yaffs_writepage(struct page *page, struct writeback_control *wbc); |
| 263 #else | |
| 7 | 264 static int yaffs_writepage(struct page *page); |
| 23 | 265 #endif |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
266 |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
267 |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
268 #if (YAFFS_USE_WRITE_BEGIN_END != 0) |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
269 static int yaffs_write_begin(struct file *filp, struct address_space *mapping, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
270 loff_t pos, unsigned len, unsigned flags, |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
271 struct page **pagep, void **fsdata); |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
272 static int yaffs_write_end(struct file *filp, struct address_space *mapping, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
273 loff_t pos, unsigned len, unsigned copied, |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
274 struct page *pg, void *fsdadata); |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
275 #else |
| 76 | 276 static int yaffs_prepare_write(struct file *f, struct page *pg, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
277 unsigned offset, unsigned to); |
| 76 | 278 static int yaffs_commit_write(struct file *f, struct page *pg, unsigned offset, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
279 unsigned to); |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
280 |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
281 #endif |
| 7 | 282 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
283 static int yaffs_readlink(struct dentry *dentry, char __user *buffer, |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
284 int buflen); |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
285 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 13)) |
| 99 | 286 static void *yaffs_follow_link(struct dentry *dentry, struct nameidata *nd); |
| 287 #else | |
| 7 | 288 static int yaffs_follow_link(struct dentry *dentry, struct nameidata *nd); |
| 99 | 289 #endif |
| 398 | 290 static loff_t yaffs_dir_llseek(struct file *file, loff_t offset, int origin); |
| 7 | 291 |
| 292 static struct address_space_operations yaffs_file_address_operations = { | |
| 76 | 293 .readpage = yaffs_readpage, |
| 294 .writepage = yaffs_writepage, | |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
295 #if (YAFFS_USE_WRITE_BEGIN_END > 0) |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
296 .write_begin = yaffs_write_begin, |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
297 .write_end = yaffs_write_end, |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
298 #else |
| 76 | 299 .prepare_write = yaffs_prepare_write, |
| 300 .commit_write = yaffs_commit_write, | |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
301 #endif |
| 7 | 302 }; |
| 303 | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
304 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 22)) |
| 273 | 305 static const struct file_operations yaffs_file_operations = { |
| 166 | 306 .read = do_sync_read, |
| 307 .write = do_sync_write, | |
| 308 .aio_read = generic_file_aio_read, | |
| 309 .aio_write = generic_file_aio_write, | |
| 189 | 310 .mmap = generic_file_mmap, |
| 311 .flush = yaffs_file_flush, | |
| 312 .fsync = yaffs_sync_object, | |
| 313 .splice_read = generic_file_splice_read, | |
| 314 .splice_write = generic_file_splice_write, | |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
315 .llseek = generic_file_llseek, |
| 189 | 316 }; |
| 317 | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
318 #elif (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 18)) |
| 189 | 319 |
| 273 | 320 static const struct file_operations yaffs_file_operations = { |
| 189 | 321 .read = do_sync_read, |
| 322 .write = do_sync_write, | |
| 323 .aio_read = generic_file_aio_read, | |
| 324 .aio_write = generic_file_aio_write, | |
| 325 .mmap = generic_file_mmap, | |
| 326 .flush = yaffs_file_flush, | |
| 327 .fsync = yaffs_sync_object, | |
| 328 .sendfile = generic_file_sendfile, | |
| 329 }; | |
| 330 | |
| 166 | 331 #else |
| 189 | 332 |
| 273 | 333 static const struct file_operations yaffs_file_operations = { |
| 76 | 334 .read = generic_file_read, |
| 335 .write = generic_file_write, | |
| 336 .mmap = generic_file_mmap, | |
| 337 .flush = yaffs_file_flush, | |
| 338 .fsync = yaffs_sync_object, | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
339 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0)) |
|
112
0f8838615001
Add generic sendfile method for yaffs2, also thereby allowing loopback mount.
tpoynor <tpoynor>
parents:
109
diff
changeset
|
340 .sendfile = generic_file_sendfile, |
|
0f8838615001
Add generic sendfile method for yaffs2, also thereby allowing loopback mount.
tpoynor <tpoynor>
parents:
109
diff
changeset
|
341 #endif |
| 7 | 342 }; |
| 189 | 343 #endif |
| 7 | 344 |
|
346
e67cba11aad9
Add own zero_user_segment for older kernels
charles <charles>
parents:
342
diff
changeset
|
345 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)) |
|
e67cba11aad9
Add own zero_user_segment for older kernels
charles <charles>
parents:
342
diff
changeset
|
346 static void zero_user_segment(struct page *page, unsigned start, unsigned end) |
|
e67cba11aad9
Add own zero_user_segment for older kernels
charles <charles>
parents:
342
diff
changeset
|
347 { |
|
e67cba11aad9
Add own zero_user_segment for older kernels
charles <charles>
parents:
342
diff
changeset
|
348 void * kaddr = kmap_atomic(page, KM_USER0); |
|
e67cba11aad9
Add own zero_user_segment for older kernels
charles <charles>
parents:
342
diff
changeset
|
349 memset(kaddr + start, 0, end - start); |
|
e67cba11aad9
Add own zero_user_segment for older kernels
charles <charles>
parents:
342
diff
changeset
|
350 kunmap_atomic(kaddr, KM_USER0); |
|
e67cba11aad9
Add own zero_user_segment for older kernels
charles <charles>
parents:
342
diff
changeset
|
351 flush_dcache_page(page); |
|
e67cba11aad9
Add own zero_user_segment for older kernels
charles <charles>
parents:
342
diff
changeset
|
352 } |
|
e67cba11aad9
Add own zero_user_segment for older kernels
charles <charles>
parents:
342
diff
changeset
|
353 #endif |
|
e67cba11aad9
Add own zero_user_segment for older kernels
charles <charles>
parents:
342
diff
changeset
|
354 |
|
e67cba11aad9
Add own zero_user_segment for older kernels
charles <charles>
parents:
342
diff
changeset
|
355 |
| 273 | 356 static const struct inode_operations yaffs_file_inode_operations = { |
| 76 | 357 .setattr = yaffs_setattr, |
| 7 | 358 }; |
| 359 | |
| 273 | 360 static const struct inode_operations yaffs_symlink_inode_operations = { |
| 76 | 361 .readlink = yaffs_readlink, |
| 362 .follow_link = yaffs_follow_link, | |
| 363 .setattr = yaffs_setattr, | |
| 7 | 364 }; |
| 365 | |
| 273 | 366 static const struct inode_operations yaffs_dir_inode_operations = { |
| 76 | 367 .create = yaffs_create, |
| 368 .lookup = yaffs_lookup, | |
| 369 .link = yaffs_link, | |
| 370 .unlink = yaffs_unlink, | |
| 371 .symlink = yaffs_symlink, | |
| 372 .mkdir = yaffs_mkdir, | |
| 373 .rmdir = yaffs_unlink, | |
| 374 .mknod = yaffs_mknod, | |
| 375 .rename = yaffs_rename, | |
| 376 .setattr = yaffs_setattr, | |
| 7 | 377 }; |
| 378 | |
| 273 | 379 static const struct file_operations yaffs_dir_operations = { |
| 76 | 380 .read = generic_read_dir, |
| 381 .readdir = yaffs_readdir, | |
| 382 .fsync = yaffs_sync_object, | |
| 398 | 383 .llseek = yaffs_dir_llseek, |
| 7 | 384 }; |
| 385 | |
| 273 | 386 static const struct super_operations yaffs_super_ops = { |
| 76 | 387 .statfs = yaffs_statfs, |
|
210
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
388 |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
389 #ifndef YAFFS_USE_OWN_IGET |
| 76 | 390 .read_inode = yaffs_read_inode, |
|
210
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
391 #endif |
|
212
0107f21a03fb
Fix compilation on Linux 2.6.26, fix compilation warnings
charles <charles>
parents:
210
diff
changeset
|
392 #ifdef YAFFS_HAS_PUT_INODE |
| 76 | 393 .put_inode = yaffs_put_inode, |
|
212
0107f21a03fb
Fix compilation on Linux 2.6.26, fix compilation warnings
charles <charles>
parents:
210
diff
changeset
|
394 #endif |
| 76 | 395 .put_super = yaffs_put_super, |
| 396 .delete_inode = yaffs_delete_inode, | |
| 397 .clear_inode = yaffs_clear_inode, | |
| 129 | 398 .sync_fs = yaffs_sync_fs, |
| 399 .write_super = yaffs_write_super, | |
| 7 | 400 }; |
| 388 | 401 |
| 402 static unsigned yaffs_gc_control_callback(yaffs_Device *dev) | |
| 403 { | |
| 404 return yaffs_gc_control; | |
| 405 } | |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
406 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
407 static void yaffs_GrossLock(yaffs_Device *dev) |
| 7 | 408 { |
| 332 | 409 T(LOCK_TRACE && YAFFS_TRACE_OS, ("yaffs locking %p\n", current)); |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
410 down(&(yaffs_DeviceToContext(dev)->grossLock)); |
| 332 | 411 T(LOCK_TRACE && YAFFS_TRACE_OS, ("yaffs locked %p\n", current)); |
| 7 | 412 } |
| 413 | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
414 static void yaffs_GrossUnlock(yaffs_Device *dev) |
| 7 | 415 { |
| 332 | 416 T(LOCK_TRACE && YAFFS_TRACE_OS, ("yaffs unlocking %p\n", current)); |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
417 up(&(yaffs_DeviceToContext(dev)->grossLock)); |
| 7 | 418 } |
| 419 | |
| 321 | 420 |
| 398 | 421 |
| 422 static struct inode * | |
| 423 yaffs2_nfs_get_inode(struct super_block *sb, uint64_t ino, uint32_t generation) | |
| 424 { | |
| 425 return yaffs_iget(sb, ino); | |
| 426 } | |
| 427 | |
| 428 static struct dentry * | |
| 429 yaffs2_fh_to_dentry(struct super_block *sb, struct fid *fid, int fh_len, int fh_type) | |
| 430 { | |
| 431 return generic_fh_to_dentry(sb, fid, fh_len, fh_type, yaffs2_nfs_get_inode) ; | |
| 432 } | |
| 433 | |
| 434 static struct dentry * | |
| 435 yaffs2_fh_to_parent(struct super_block *sb, struct fid *fid, int fh_len, int fh_type) | |
| 436 { | |
| 437 return generic_fh_to_parent(sb, fid, fh_len, fh_type, yaffs2_nfs_get_inode); | |
| 438 } | |
| 439 | |
| 440 struct dentry *yaffs2_get_parent(struct dentry *dentry) | |
| 441 { | |
| 442 | |
| 443 struct super_block *sb = dentry->d_inode->i_sb; | |
| 444 struct dentry *parent = ERR_PTR(-ENOENT); | |
| 445 struct inode *inode; | |
| 446 unsigned long parent_ino; | |
| 447 yaffs_Object *d_obj; | |
| 448 yaffs_Object *parent_obj; | |
| 449 | |
| 450 d_obj = yaffs_InodeToObject(dentry->d_inode); | |
| 451 | |
| 452 if (d_obj) { | |
| 453 parent_obj = d_obj->parent; | |
| 454 if (parent_obj) { | |
| 455 parent_ino = yaffs_GetObjectInode(parent_obj); | |
| 456 inode = yaffs_iget(sb, parent_ino); | |
| 457 | |
| 458 if (IS_ERR(inode)) { | |
| 459 parent = ERR_CAST(inode); | |
| 460 } else { | |
| 461 parent = d_obtain_alias(inode); | |
| 462 if (!IS_ERR(parent)) { | |
| 463 parent = ERR_PTR(-ENOMEM); | |
| 464 iput(inode); | |
| 465 } | |
| 466 } | |
| 467 } | |
| 468 } | |
| 469 | |
| 470 return parent; | |
| 471 } | |
| 472 | |
| 473 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,9)) | |
| 474 /* Just declare a zero structure as a NULL value implies | |
| 475 * using the default functions of expfs. | |
| 476 */ | |
| 477 | |
| 478 static struct export_operations yaffs_export_ops = | |
| 479 { | |
| 480 .fh_to_dentry = yaffs2_fh_to_dentry, | |
| 481 .fh_to_parent = yaffs2_fh_to_parent, | |
| 482 .get_parent = yaffs2_get_parent, | |
| 483 } ; | |
| 484 | |
| 485 #endif | |
| 486 | |
| 321 | 487 /*-----------------------------------------------------------------*/ |
| 488 /* Directory search context allows us to unlock access to yaffs during | |
| 489 * filldir without causing problems with the directory being modified. | |
| 490 * This is similar to the tried and tested mechanism used in yaffs direct. | |
| 491 * | |
| 492 * A search context iterates along a doubly linked list of siblings in the | |
| 493 * directory. If the iterating object is deleted then this would corrupt | |
| 494 * the list iteration, likely causing a crash. The search context avoids | |
| 495 * this by using the removeObjectCallback to move the search context to the | |
| 496 * next object before the object is deleted. | |
| 497 * | |
| 498 * Many readdirs (and thus seach conexts) may be alive simulateously so | |
| 499 * each yaffs_Device has a list of these. | |
| 500 * | |
| 501 * A seach context lives for the duration of a readdir. | |
| 502 * | |
| 503 * All these functions must be called while yaffs is locked. | |
| 504 */ | |
| 505 | |
| 506 struct yaffs_SearchContext { | |
| 507 yaffs_Device *dev; | |
| 508 yaffs_Object *dirObj; | |
| 509 yaffs_Object *nextReturn; | |
| 510 struct ylist_head others; | |
| 511 }; | |
| 512 | |
| 513 /* | |
| 514 * yaffs_NewSearch() creates a new search context, initialises it and | |
| 515 * adds it to the device's search context list. | |
| 516 * | |
| 517 * Called at start of readdir. | |
| 518 */ | |
| 519 static struct yaffs_SearchContext * yaffs_NewSearch(yaffs_Object *dir) | |
| 520 { | |
| 521 yaffs_Device *dev = dir->myDev; | |
| 522 struct yaffs_SearchContext *sc = YMALLOC(sizeof(struct yaffs_SearchContext)); | |
| 523 if(sc){ | |
| 524 sc->dirObj = dir; | |
| 525 sc->dev = dev; | |
| 526 if( ylist_empty(&sc->dirObj->variant.directoryVariant.children)) | |
| 527 sc->nextReturn = NULL; | |
| 528 else | |
| 529 sc->nextReturn = ylist_entry( | |
| 530 dir->variant.directoryVariant.children.next, | |
| 531 yaffs_Object,siblings); | |
| 532 YINIT_LIST_HEAD(&sc->others); | |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
533 ylist_add(&sc->others,&(yaffs_DeviceToContext(dev)->searchContexts)); |
| 321 | 534 } |
| 535 return sc; | |
| 536 } | |
| 537 | |
| 538 /* | |
| 539 * yaffs_EndSearch() disposes of a search context and cleans up. | |
| 540 */ | |
| 541 static void yaffs_EndSearch(struct yaffs_SearchContext * sc) | |
| 542 { | |
| 543 if(sc){ | |
| 544 ylist_del(&sc->others); | |
| 545 YFREE(sc); | |
| 546 } | |
| 547 } | |
| 548 | |
| 549 /* | |
| 550 * yaffs_SearchAdvance() moves a search context to the next object. | |
| 551 * Called when the search iterates or when an object removal causes | |
| 552 * the search context to be moved to the next object. | |
| 553 */ | |
| 554 static void yaffs_SearchAdvance(struct yaffs_SearchContext *sc) | |
| 555 { | |
| 556 if(!sc) | |
| 557 return; | |
| 558 | |
| 559 if( sc->nextReturn == NULL || | |
| 560 ylist_empty(&sc->dirObj->variant.directoryVariant.children)) | |
| 561 sc->nextReturn = NULL; | |
| 562 else { | |
| 563 struct ylist_head *next = sc->nextReturn->siblings.next; | |
| 564 | |
| 565 if( next == &sc->dirObj->variant.directoryVariant.children) | |
| 566 sc->nextReturn = NULL; /* end of list */ | |
| 567 else | |
| 568 sc->nextReturn = ylist_entry(next,yaffs_Object,siblings); | |
| 569 } | |
| 570 } | |
| 571 | |
| 572 /* | |
| 573 * yaffs_RemoveObjectCallback() is called when an object is unlinked. | |
| 574 * We check open search contexts and advance any which are currently | |
| 575 * on the object being iterated. | |
| 576 */ | |
| 577 static void yaffs_RemoveObjectCallback(yaffs_Object *obj) | |
| 578 { | |
| 579 | |
| 580 struct ylist_head *i; | |
| 581 struct yaffs_SearchContext *sc; | |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
582 struct ylist_head *search_contexts = &(yaffs_DeviceToContext(obj->myDev)->searchContexts); |
| 321 | 583 |
| 584 | |
| 585 /* Iterate through the directory search contexts. | |
| 586 * If any are currently on the object being removed, then advance | |
| 587 * the search context to the next object to prevent a hanging pointer. | |
| 588 */ | |
| 589 ylist_for_each(i, search_contexts) { | |
| 590 if (i) { | |
| 591 sc = ylist_entry(i, struct yaffs_SearchContext,others); | |
| 592 if(sc->nextReturn == obj) | |
| 593 yaffs_SearchAdvance(sc); | |
| 594 } | |
| 595 } | |
| 596 | |
| 597 } | |
| 598 | |
| 599 | |
| 600 /*-----------------------------------------------------------------*/ | |
| 601 | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
602 static int yaffs_readlink(struct dentry *dentry, char __user *buffer, |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
603 int buflen) |
| 7 | 604 { |
| 605 unsigned char *alias; | |
| 606 int ret; | |
| 607 | |
| 608 yaffs_Device *dev = yaffs_DentryToObject(dentry)->myDev; | |
|
320
37b5b3fda7c0
Revert readdir locking fix that doesn't work properly
charles <charles>
parents:
319
diff
changeset
|
609 |
| 76 | 610 yaffs_GrossLock(dev); |
| 7 | 611 |
| 612 alias = yaffs_GetSymlinkAlias(yaffs_DentryToObject(dentry)); | |
| 76 | 613 |
| 7 | 614 yaffs_GrossUnlock(dev); |
| 76 | 615 |
| 616 if (!alias) | |
| 7 | 617 return -ENOMEM; |
| 618 | |
| 619 ret = vfs_readlink(dentry, buffer, buflen, alias); | |
| 620 kfree(alias); | |
| 621 return ret; | |
| 622 } | |
| 623 | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
624 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 13)) |
| 99 | 625 static void *yaffs_follow_link(struct dentry *dentry, struct nameidata *nd) |
| 626 #else | |
| 7 | 627 static int yaffs_follow_link(struct dentry *dentry, struct nameidata *nd) |
| 99 | 628 #endif |
| 7 | 629 { |
| 630 unsigned char *alias; | |
| 631 int ret; | |
| 632 yaffs_Device *dev = yaffs_DentryToObject(dentry)->myDev; | |
| 633 | |
| 634 yaffs_GrossLock(dev); | |
| 635 | |
| 636 alias = yaffs_GetSymlinkAlias(yaffs_DentryToObject(dentry)); | |
| 76 | 637 |
| 7 | 638 yaffs_GrossUnlock(dev); |
| 76 | 639 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
640 if (!alias) { |
| 99 | 641 ret = -ENOMEM; |
| 642 goto out; | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
643 } |
| 7 | 644 |
| 76 | 645 ret = vfs_follow_link(nd, alias); |
| 7 | 646 kfree(alias); |
| 99 | 647 out: |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
648 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 13)) |
| 273 | 649 return ERR_PTR(ret); |
| 99 | 650 #else |
| 7 | 651 return ret; |
| 99 | 652 #endif |
| 7 | 653 } |
| 654 | |
| 76 | 655 struct inode *yaffs_get_inode(struct super_block *sb, int mode, int dev, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
656 yaffs_Object *obj); |
| 7 | 657 |
| 658 /* | |
| 659 * Lookup is used to find objects in the fs | |
| 660 */ | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
661 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0)) |
| 7 | 662 |
| 76 | 663 static struct dentry *yaffs_lookup(struct inode *dir, struct dentry *dentry, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
664 struct nameidata *n) |
| 7 | 665 #else |
| 76 | 666 static struct dentry *yaffs_lookup(struct inode *dir, struct dentry *dentry) |
| 7 | 667 #endif |
| 668 { | |
| 669 yaffs_Object *obj; | |
| 76 | 670 struct inode *inode = NULL; /* NCB 2.5/2.6 needs NULL here */ |
| 671 | |
| 7 | 672 yaffs_Device *dev = yaffs_InodeToObject(dir)->myDev; |
| 673 | |
| 398 | 674 if(current != yaffs_DeviceToContext(dev)->readdirProcess) |
| 675 yaffs_GrossLock(dev); | |
| 7 | 676 |
| 76 | 677 T(YAFFS_TRACE_OS, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
678 ("yaffs_lookup for %d:%s\n", |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
679 yaffs_InodeToObject(dir)->objectId, dentry->d_name.name)); |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
680 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
681 obj = yaffs_FindObjectByName(yaffs_InodeToObject(dir), |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
682 dentry->d_name.name); |
| 76 | 683 |
| 684 obj = yaffs_GetEquivalentObject(obj); /* in case it was a hardlink */ | |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
685 |
|
106
5b8f68c30468
Apply Reed's deadlocking fix (manually applied)
charles <charles>
parents:
104
diff
changeset
|
686 /* Can't hold gross lock when calling yaffs_get_inode() */ |
| 398 | 687 if(current != yaffs_DeviceToContext(dev)->readdirProcess) |
| 688 yaffs_GrossUnlock(dev); | |
| 7 | 689 |
| 76 | 690 if (obj) { |
| 691 T(YAFFS_TRACE_OS, | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
692 ("yaffs_lookup found %d\n", obj->objectId)); |
| 76 | 693 |
| 694 inode = yaffs_get_inode(dir->i_sb, obj->yst_mode, 0, obj); | |
| 695 | |
| 696 if (inode) { | |
| 697 T(YAFFS_TRACE_OS, | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
698 ("yaffs_loookup dentry \n")); |
| 76 | 699 /* #if 0 asserted by NCB for 2.5/6 compatability - falls through to |
| 700 * d_add even if NULL inode */ | |
| 7 | 701 #if 0 |
| 76 | 702 /*dget(dentry); // try to solve directory bug */ |
| 703 d_add(dentry, inode); | |
| 704 | |
| 705 /* return dentry; */ | |
| 7 | 706 return NULL; |
| 707 #endif | |
| 708 } | |
| 709 | |
| 76 | 710 } else { |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
711 T(YAFFS_TRACE_OS, ("yaffs_lookup not found\n")); |
| 76 | 712 |
| 7 | 713 } |
| 714 | |
| 76 | 715 /* added NCB for 2.5/6 compatability - forces add even if inode is |
| 716 * NULL which creates dentry hash */ | |
| 717 d_add(dentry, inode); | |
| 718 | |
| 7 | 719 return NULL; |
| 720 } | |
| 721 | |
|
212
0107f21a03fb
Fix compilation on Linux 2.6.26, fix compilation warnings
charles <charles>
parents:
210
diff
changeset
|
722 |
|
0107f21a03fb
Fix compilation on Linux 2.6.26, fix compilation warnings
charles <charles>
parents:
210
diff
changeset
|
723 #ifdef YAFFS_HAS_PUT_INODE |
|
0107f21a03fb
Fix compilation on Linux 2.6.26, fix compilation warnings
charles <charles>
parents:
210
diff
changeset
|
724 |
| 76 | 725 /* For now put inode is just for debugging |
| 726 * Put inode is called when the inode **structure** is put. | |
| 727 */ | |
| 7 | 728 static void yaffs_put_inode(struct inode *inode) |
| 729 { | |
| 76 | 730 T(YAFFS_TRACE_OS, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
731 ("yaffs_put_inode: ino %d, count %d\n", (int)inode->i_ino, |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
732 atomic_read(&inode->i_count))); |
| 76 | 733 |
| 7 | 734 } |
|
212
0107f21a03fb
Fix compilation on Linux 2.6.26, fix compilation warnings
charles <charles>
parents:
210
diff
changeset
|
735 #endif |
| 7 | 736 |
| 76 | 737 /* clear is called to tell the fs to release any per-inode data it holds */ |
| 7 | 738 static void yaffs_clear_inode(struct inode *inode) |
| 739 { | |
| 740 yaffs_Object *obj; | |
| 741 yaffs_Device *dev; | |
| 76 | 742 |
| 7 | 743 obj = yaffs_InodeToObject(inode); |
| 744 | |
| 76 | 745 T(YAFFS_TRACE_OS, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
746 ("yaffs_clear_inode: ino %d, count %d %s\n", (int)inode->i_ino, |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
747 atomic_read(&inode->i_count), |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
748 obj ? "object exists" : "null object")); |
| 76 | 749 |
| 750 if (obj) { | |
| 7 | 751 dev = obj->myDev; |
| 752 yaffs_GrossLock(dev); | |
| 76 | 753 |
| 754 /* Clear the association between the inode and | |
| 755 * the yaffs_Object. | |
| 756 */ | |
| 7 | 757 obj->myInode = NULL; |
| 166 | 758 yaffs_InodeToObjectLV(inode) = NULL; |
| 76 | 759 |
| 760 /* If the object freeing was deferred, then the real | |
| 761 * free happens now. | |
| 762 * This should fix the inode inconsistency problem. | |
| 763 */ | |
| 764 | |
| 7 | 765 yaffs_HandleDeferedFree(obj); |
| 76 | 766 |
| 7 | 767 yaffs_GrossUnlock(dev); |
| 768 } | |
| 76 | 769 |
| 7 | 770 } |
| 771 | |
| 76 | 772 /* delete is called when the link count is zero and the inode |
| 773 * is put (ie. nobody wants to know about it anymore, time to | |
| 774 * delete the file). | |
| 775 * NB Must call clear_inode() | |
| 776 */ | |
| 7 | 777 static void yaffs_delete_inode(struct inode *inode) |
| 778 { | |
| 779 yaffs_Object *obj = yaffs_InodeToObject(inode); | |
| 780 yaffs_Device *dev; | |
| 781 | |
| 76 | 782 T(YAFFS_TRACE_OS, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
783 ("yaffs_delete_inode: ino %d, count %d %s\n", (int)inode->i_ino, |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
784 atomic_read(&inode->i_count), |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
785 obj ? "object exists" : "null object")); |
| 76 | 786 |
| 787 if (obj) { | |
| 788 dev = obj->myDev; | |
| 7 | 789 yaffs_GrossLock(dev); |
|
268
f13c5ef026ec
Change inode deletion to prevent issue raised by YBUG
charles <charles>
parents:
267
diff
changeset
|
790 yaffs_DeleteObject(obj); |
| 7 | 791 yaffs_GrossUnlock(dev); |
| 792 } | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
793 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 13)) |
| 273 | 794 truncate_inode_pages(&inode->i_data, 0); |
| 99 | 795 #endif |
| 7 | 796 clear_inode(inode); |
| 797 } | |
| 798 | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
799 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17)) |
| 143 | 800 static int yaffs_file_flush(struct file *file, fl_owner_t id) |
| 801 #else | |
| 76 | 802 static int yaffs_file_flush(struct file *file) |
| 143 | 803 #endif |
| 7 | 804 { |
| 805 yaffs_Object *obj = yaffs_DentryToObject(file->f_dentry); | |
| 76 | 806 |
| 7 | 807 yaffs_Device *dev = obj->myDev; |
| 76 | 808 |
| 809 T(YAFFS_TRACE_OS, | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
810 ("yaffs_file_flush object %d (%s)\n", obj->objectId, |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
811 obj->dirty ? "dirty" : "clean")); |
| 7 | 812 |
| 813 yaffs_GrossLock(dev); | |
| 76 | 814 |
| 332 | 815 yaffs_FlushFile(obj, 1, 0); |
| 7 | 816 |
| 817 yaffs_GrossUnlock(dev); | |
| 818 | |
| 76 | 819 return 0; |
| 7 | 820 } |
| 821 | |
| 76 | 822 static int yaffs_readpage_nolock(struct file *f, struct page *pg) |
| 823 { | |
| 824 /* Lifted from jffs2 */ | |
| 7 | 825 |
| 826 yaffs_Object *obj; | |
| 827 unsigned char *pg_buf; | |
| 828 int ret; | |
| 829 | |
| 830 yaffs_Device *dev; | |
| 831 | |
| 332 | 832 T(YAFFS_TRACE_OS, ("yaffs_readpage_nolock at %08x, size %08x\n", |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
833 (unsigned)(pg->index << PAGE_CACHE_SHIFT), |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
834 (unsigned)PAGE_CACHE_SIZE)); |
| 7 | 835 |
| 76 | 836 obj = yaffs_DentryToObject(f->f_dentry); |
| 7 | 837 |
| 838 dev = obj->myDev; | |
| 76 | 839 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
840 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0)) |
| 76 | 841 BUG_ON(!PageLocked(pg)); |
| 23 | 842 #else |
| 7 | 843 if (!PageLocked(pg)) |
| 76 | 844 PAGE_BUG(pg); |
| 23 | 845 #endif |
| 7 | 846 |
| 847 pg_buf = kmap(pg); | |
| 848 /* FIXME: Can kmap fail? */ | |
| 849 | |
| 850 yaffs_GrossLock(dev); | |
| 76 | 851 |
| 276 | 852 ret = yaffs_ReadDataFromFile(obj, pg_buf, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
853 pg->index << PAGE_CACHE_SHIFT, |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
854 PAGE_CACHE_SIZE); |
| 7 | 855 |
| 856 yaffs_GrossUnlock(dev); | |
| 76 | 857 |
| 858 if (ret >= 0) | |
| 859 ret = 0; | |
| 7 | 860 |
| 861 if (ret) { | |
| 862 ClearPageUptodate(pg); | |
| 863 SetPageError(pg); | |
| 864 } else { | |
| 865 SetPageUptodate(pg); | |
| 866 ClearPageError(pg); | |
| 867 } | |
| 868 | |
| 869 flush_dcache_page(pg); | |
| 870 kunmap(pg); | |
| 871 | |
| 332 | 872 T(YAFFS_TRACE_OS, ("yaffs_readpage_nolock done\n")); |
| 7 | 873 return ret; |
| 874 } | |
| 875 | |
| 876 static int yaffs_readpage_unlock(struct file *f, struct page *pg) | |
| 877 { | |
| 76 | 878 int ret = yaffs_readpage_nolock(f, pg); |
| 7 | 879 UnlockPage(pg); |
| 880 return ret; | |
| 881 } | |
| 882 | |
| 76 | 883 static int yaffs_readpage(struct file *f, struct page *pg) |
| 7 | 884 { |
| 332 | 885 int ret; |
| 886 | |
| 887 T(YAFFS_TRACE_OS, ("yaffs_readpage\n")); | |
| 888 ret=yaffs_readpage_unlock(f, pg); | |
| 889 T(YAFFS_TRACE_OS, ("yaffs_readpage done\n")); | |
| 890 return ret; | |
| 7 | 891 } |
| 892 | |
| 76 | 893 /* writepage inspired by/stolen from smbfs */ |
| 7 | 894 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
895 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0)) |
| 23 | 896 static int yaffs_writepage(struct page *page, struct writeback_control *wbc) |
| 897 #else | |
| 7 | 898 static int yaffs_writepage(struct page *page) |
| 23 | 899 #endif |
| 7 | 900 { |
| 901 struct address_space *mapping = page->mapping; | |
| 902 struct inode *inode; | |
| 903 unsigned long end_index; | |
| 904 char *buffer; | |
| 905 yaffs_Object *obj; | |
| 906 int nWritten = 0; | |
| 907 unsigned nBytes; | |
| 332 | 908 loff_t i_size; |
| 7 | 909 |
| 910 if (!mapping) | |
| 911 BUG(); | |
| 912 inode = mapping->host; | |
| 913 if (!inode) | |
| 914 BUG(); | |
| 332 | 915 i_size = i_size_read(inode); |
| 916 | |
| 917 end_index = i_size >> PAGE_CACHE_SHIFT; | |
| 918 | |
| 919 if(page->index < end_index) | |
| 920 nBytes = PAGE_CACHE_SIZE; | |
| 921 else { | |
| 922 nBytes = i_size & (PAGE_CACHE_SIZE -1); | |
| 923 | |
| 924 if (page->index > end_index || !nBytes) { | |
| 925 T(YAFFS_TRACE_OS, | |
| 926 ("yaffs_writepage at %08x, inode size = %08x!!!\n", | |
| 927 (unsigned)(page->index << PAGE_CACHE_SHIFT), | |
| 928 (unsigned)inode->i_size)); | |
| 929 T(YAFFS_TRACE_OS, | |
| 930 (" -> don't care!!\n")); | |
| 931 | |
| 932 zero_user_segment(page,0,PAGE_CACHE_SIZE); | |
| 933 set_page_writeback(page); | |
| 934 unlock_page(page); | |
| 935 end_page_writeback(page); | |
| 936 return 0; | |
| 937 } | |
|
67
cb8afec5ad31
Fix an error in writepage when a file is extended.
luc <luc>
parents:
61
diff
changeset
|
938 } |
|
cb8afec5ad31
Fix an error in writepage when a file is extended.
luc <luc>
parents:
61
diff
changeset
|
939 |
| 332 | 940 if(nBytes != PAGE_CACHE_SIZE) |
| 941 zero_user_segment(page,nBytes,PAGE_CACHE_SIZE); | |
| 7 | 942 |
| 943 get_page(page); | |
| 944 | |
| 945 buffer = kmap(page); | |
| 946 | |
| 947 obj = yaffs_InodeToObject(inode); | |
| 948 yaffs_GrossLock(obj->myDev); | |
| 949 | |
| 76 | 950 T(YAFFS_TRACE_OS, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
951 ("yaffs_writepage at %08x, size %08x\n", |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
952 (unsigned)(page->index << PAGE_CACHE_SHIFT), nBytes)); |
| 76 | 953 T(YAFFS_TRACE_OS, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
954 ("writepag0: obj = %05x, ino = %05x\n", |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
955 (int)obj->variant.fileVariant.fileSize, (int)inode->i_size)); |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
956 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
957 nWritten = yaffs_WriteDataToFile(obj, buffer, |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
958 page->index << PAGE_CACHE_SHIFT, nBytes, 0); |
| 7 | 959 |
| 76 | 960 T(YAFFS_TRACE_OS, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
961 ("writepag1: obj = %05x, ino = %05x\n", |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
962 (int)obj->variant.fileVariant.fileSize, (int)inode->i_size)); |
|
67
cb8afec5ad31
Fix an error in writepage when a file is extended.
luc <luc>
parents:
61
diff
changeset
|
963 |
| 7 | 964 yaffs_GrossUnlock(obj->myDev); |
| 76 | 965 |
| 7 | 966 kunmap(page); |
| 332 | 967 set_page_writeback(page); |
| 968 unlock_page(page); | |
| 969 end_page_writeback(page); | |
| 7 | 970 put_page(page); |
| 971 | |
| 76 | 972 return (nWritten == nBytes) ? 0 : -ENOSPC; |
| 7 | 973 } |
| 974 | |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
975 |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
976 #if (YAFFS_USE_WRITE_BEGIN_END > 0) |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
977 static int yaffs_write_begin(struct file *filp, struct address_space *mapping, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
978 loff_t pos, unsigned len, unsigned flags, |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
979 struct page **pagep, void **fsdata) |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
980 { |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
981 struct page *pg = NULL; |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
982 pgoff_t index = pos >> PAGE_CACHE_SHIFT; |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
983 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
984 int ret = 0; |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
985 int space_held = 0; |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
986 |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
987 /* Get a page */ |
|
289
850410979014
More recent 2.6.8 versions need this change too
charles <charles>
parents:
280
diff
changeset
|
988 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28) |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
989 pg = grab_cache_page_write_begin(mapping, index, flags); |
| 266 | 990 #else |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
991 pg = __grab_cache_page(mapping, index); |
| 266 | 992 #endif |
| 993 | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
994 *pagep = pg; |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
995 if (!pg) { |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
996 ret = -ENOMEM; |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
997 goto out; |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
998 } |
| 332 | 999 T(YAFFS_TRACE_OS, ("start yaffs_write_begin index %d(%x) uptodate %d\n",(int)index,(int)index,Page_Uptodate(pg) ? 1 : 0)); |
| 1000 | |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1001 /* Get fs space */ |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1002 space_held = yaffs_hold_space(filp); |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1003 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1004 if (!space_held) { |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1005 ret = -ENOSPC; |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1006 goto out; |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1007 } |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1008 |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1009 /* Update page if required */ |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1010 |
| 332 | 1011 if (!Page_Uptodate(pg)) |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1012 ret = yaffs_readpage_nolock(filp, pg); |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1013 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1014 if (ret) |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1015 goto out; |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1016 |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1017 /* Happy path return */ |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1018 T(YAFFS_TRACE_OS, ("end yaffs_write_begin - ok\n")); |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1019 |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1020 return 0; |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1021 |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1022 out: |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1023 T(YAFFS_TRACE_OS, ("end yaffs_write_begin fail returning %d\n", ret)); |
| 273 | 1024 if (space_held) |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1025 yaffs_release_space(filp); |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1026 if (pg) { |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1027 unlock_page(pg); |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1028 page_cache_release(pg); |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1029 } |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1030 return ret; |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1031 } |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1032 |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1033 #else |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1034 |
| 76 | 1035 static int yaffs_prepare_write(struct file *f, struct page *pg, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1036 unsigned offset, unsigned to) |
| 7 | 1037 { |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1038 T(YAFFS_TRACE_OS, ("yaffs_prepair_write\n")); |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1039 |
| 332 | 1040 if (!Page_Uptodate(pg)) |
| 76 | 1041 return yaffs_readpage_nolock(f, pg); |
| 7 | 1042 return 0; |
| 1043 } | |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1044 #endif |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1045 |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1046 #if (YAFFS_USE_WRITE_BEGIN_END > 0) |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1047 static int yaffs_write_end(struct file *filp, struct address_space *mapping, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1048 loff_t pos, unsigned len, unsigned copied, |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1049 struct page *pg, void *fsdadata) |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1050 { |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1051 int ret = 0; |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1052 void *addr, *kva; |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1053 uint32_t offset_into_page = pos & (PAGE_CACHE_SIZE - 1); |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1054 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1055 kva = kmap(pg); |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1056 addr = kva + offset_into_page; |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1057 |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1058 T(YAFFS_TRACE_OS, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1059 ("yaffs_write_end addr %x pos %x nBytes %d\n", |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1060 (unsigned) addr, |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1061 (int)pos, copied)); |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1062 |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1063 ret = yaffs_file_write(filp, addr, copied, &pos); |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1064 |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1065 if (ret != copied) { |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1066 T(YAFFS_TRACE_OS, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1067 ("yaffs_write_end not same size ret %d copied %d\n", |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1068 ret, copied)); |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1069 SetPageError(pg); |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1070 } else { |
| 332 | 1071 /* Nothing */ |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1072 } |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1073 |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1074 kunmap(pg); |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1075 |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1076 yaffs_release_space(filp); |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1077 unlock_page(pg); |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1078 page_cache_release(pg); |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1079 return ret; |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1080 } |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1081 #else |
| 7 | 1082 |
| 76 | 1083 static int yaffs_commit_write(struct file *f, struct page *pg, unsigned offset, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1084 unsigned to) |
| 7 | 1085 { |
| 218 | 1086 void *addr, *kva; |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1087 |
| 76 | 1088 loff_t pos = (((loff_t) pg->index) << PAGE_CACHE_SHIFT) + offset; |
| 7 | 1089 int nBytes = to - offset; |
| 1090 int nWritten; | |
| 76 | 1091 |
| 7 | 1092 unsigned spos = pos; |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1093 unsigned saddr; |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1094 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1095 kva = kmap(pg); |
| 218 | 1096 addr = kva + offset; |
| 7 | 1097 |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1098 saddr = (unsigned) addr; |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1099 |
| 76 | 1100 T(YAFFS_TRACE_OS, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1101 ("yaffs_commit_write addr %x pos %x nBytes %d\n", |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1102 saddr, spos, nBytes)); |
| 76 | 1103 |
| 1104 nWritten = yaffs_file_write(f, addr, nBytes, &pos); | |
| 1105 | |
| 1106 if (nWritten != nBytes) { | |
| 1107 T(YAFFS_TRACE_OS, | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1108 ("yaffs_commit_write not same size nWritten %d nBytes %d\n", |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1109 nWritten, nBytes)); |
| 7 | 1110 SetPageError(pg); |
| 76 | 1111 } else { |
| 332 | 1112 /* Nothing */ |
| 7 | 1113 } |
| 1114 | |
| 218 | 1115 kunmap(pg); |
| 1116 | |
| 76 | 1117 T(YAFFS_TRACE_OS, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1118 ("yaffs_commit_write returning %d\n", |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1119 nWritten == nBytes ? 0 : nWritten)); |
| 76 | 1120 |
|
113
325f5d3a757c
Handle partial writes more gracefully: return partial byte counts, return
tpoynor <tpoynor>
parents:
112
diff
changeset
|
1121 return nWritten == nBytes ? 0 : nWritten; |
| 7 | 1122 } |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1123 #endif |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1124 |
| 7 | 1125 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1126 static void yaffs_FillInodeFromObject(struct inode *inode, yaffs_Object *obj) |
| 7 | 1127 { |
| 76 | 1128 if (inode && obj) { |
| 139 | 1129 |
| 1130 | |
| 1131 /* Check mode against the variant type and attempt to repair if broken. */ | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1132 __u32 mode = obj->yst_mode; |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1133 switch (obj->variantType) { |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1134 case YAFFS_OBJECT_TYPE_FILE: |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1135 if (!S_ISREG(mode)) { |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1136 obj->yst_mode &= ~S_IFMT; |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1137 obj->yst_mode |= S_IFREG; |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1138 } |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1139 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1140 break; |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1141 case YAFFS_OBJECT_TYPE_SYMLINK: |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1142 if (!S_ISLNK(mode)) { |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1143 obj->yst_mode &= ~S_IFMT; |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1144 obj->yst_mode |= S_IFLNK; |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1145 } |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1146 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1147 break; |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1148 case YAFFS_OBJECT_TYPE_DIRECTORY: |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1149 if (!S_ISDIR(mode)) { |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1150 obj->yst_mode &= ~S_IFMT; |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1151 obj->yst_mode |= S_IFDIR; |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1152 } |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1153 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1154 break; |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1155 case YAFFS_OBJECT_TYPE_UNKNOWN: |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1156 case YAFFS_OBJECT_TYPE_HARDLINK: |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1157 case YAFFS_OBJECT_TYPE_SPECIAL: |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1158 default: |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1159 /* TODO? */ |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1160 break; |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1161 } |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1162 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1163 inode->i_flags |= S_NOATIME; |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1164 |
| 7 | 1165 inode->i_ino = obj->objectId; |
|
22
0b57027b96fe
Some improvements to garbage collection and st_xxx to yst_xxx changes
charles <charles>
parents:
19
diff
changeset
|
1166 inode->i_mode = obj->yst_mode; |
|
0b57027b96fe
Some improvements to garbage collection and st_xxx to yst_xxx changes
charles <charles>
parents:
19
diff
changeset
|
1167 inode->i_uid = obj->yst_uid; |
|
0b57027b96fe
Some improvements to garbage collection and st_xxx to yst_xxx changes
charles <charles>
parents:
19
diff
changeset
|
1168 inode->i_gid = obj->yst_gid; |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1169 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)) |
| 7 | 1170 inode->i_blksize = inode->i_sb->s_blocksize; |
| 166 | 1171 #endif |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1172 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0)) |
| 7 | 1173 |
|
22
0b57027b96fe
Some improvements to garbage collection and st_xxx to yst_xxx changes
charles <charles>
parents:
19
diff
changeset
|
1174 inode->i_rdev = old_decode_dev(obj->yst_rdev); |
| 76 | 1175 inode->i_atime.tv_sec = (time_t) (obj->yst_atime); |
| 7 | 1176 inode->i_atime.tv_nsec = 0; |
| 76 | 1177 inode->i_mtime.tv_sec = (time_t) obj->yst_mtime; |
| 1178 inode->i_mtime.tv_nsec = 0; | |
| 1179 inode->i_ctime.tv_sec = (time_t) obj->yst_ctime; | |
| 7 | 1180 inode->i_ctime.tv_nsec = 0; |
| 1181 #else | |
|
22
0b57027b96fe
Some improvements to garbage collection and st_xxx to yst_xxx changes
charles <charles>
parents:
19
diff
changeset
|
1182 inode->i_rdev = obj->yst_rdev; |
|
0b57027b96fe
Some improvements to garbage collection and st_xxx to yst_xxx changes
charles <charles>
parents:
19
diff
changeset
|
1183 inode->i_atime = obj->yst_atime; |
|
0b57027b96fe
Some improvements to garbage collection and st_xxx to yst_xxx changes
charles <charles>
parents:
19
diff
changeset
|
1184 inode->i_mtime = obj->yst_mtime; |
|
0b57027b96fe
Some improvements to garbage collection and st_xxx to yst_xxx changes
charles <charles>
parents:
19
diff
changeset
|
1185 inode->i_ctime = obj->yst_ctime; |
| 7 | 1186 #endif |
| 1187 inode->i_size = yaffs_GetObjectFileLength(obj); | |
| 1188 inode->i_blocks = (inode->i_size + 511) >> 9; | |
| 1189 | |
| 1190 inode->i_nlink = yaffs_GetObjectLinkCount(obj); | |
| 76 | 1191 |
| 1192 T(YAFFS_TRACE_OS, | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1193 ("yaffs_FillInode mode %x uid %d gid %d size %d count %d\n", |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1194 inode->i_mode, inode->i_uid, inode->i_gid, |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1195 (int)inode->i_size, atomic_read(&inode->i_count))); |
| 76 | 1196 |
| 1197 switch (obj->yst_mode & S_IFMT) { | |
| 1198 default: /* fifo, device or socket */ | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1199 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0)) |
| 76 | 1200 init_special_inode(inode, obj->yst_mode, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1201 old_decode_dev(obj->yst_rdev)); |
| 12 | 1202 #else |
| 76 | 1203 init_special_inode(inode, obj->yst_mode, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1204 (dev_t) (obj->yst_rdev)); |
| 76 | 1205 #endif |
| 1206 break; | |
| 1207 case S_IFREG: /* file */ | |
| 1208 inode->i_op = &yaffs_file_inode_operations; | |
| 1209 inode->i_fop = &yaffs_file_operations; | |
| 1210 inode->i_mapping->a_ops = | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1211 &yaffs_file_address_operations; |
| 76 | 1212 break; |
| 1213 case S_IFDIR: /* directory */ | |
| 1214 inode->i_op = &yaffs_dir_inode_operations; | |
| 1215 inode->i_fop = &yaffs_dir_operations; | |
| 1216 break; | |
| 1217 case S_IFLNK: /* symlink */ | |
| 1218 inode->i_op = &yaffs_symlink_inode_operations; | |
| 1219 break; | |
| 7 | 1220 } |
| 76 | 1221 |
| 166 | 1222 yaffs_InodeToObjectLV(inode) = obj; |
| 1223 | |
| 7 | 1224 obj->myInode = inode; |
| 76 | 1225 |
| 1226 } else { | |
| 1227 T(YAFFS_TRACE_OS, | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1228 ("yaffs_FileInode invalid parameters\n")); |
| 7 | 1229 } |
| 1230 | |
| 1231 } | |
| 1232 | |
| 76 | 1233 struct inode *yaffs_get_inode(struct super_block *sb, int mode, int dev, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1234 yaffs_Object *obj) |
| 7 | 1235 { |
| 76 | 1236 struct inode *inode; |
| 1237 | |
| 1238 if (!sb) { | |
| 1239 T(YAFFS_TRACE_OS, | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1240 ("yaffs_get_inode for NULL super_block!!\n")); |
| 76 | 1241 return NULL; |
| 1242 | |
| 7 | 1243 } |
| 76 | 1244 |
| 1245 if (!obj) { | |
| 1246 T(YAFFS_TRACE_OS, | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1247 ("yaffs_get_inode for NULL object!!\n")); |
| 76 | 1248 return NULL; |
| 1249 | |
| 7 | 1250 } |
| 76 | 1251 |
| 1252 T(YAFFS_TRACE_OS, | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1253 ("yaffs_get_inode for object %d\n", obj->objectId)); |
| 7 | 1254 |
|
210
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
1255 inode = Y_IGET(sb, obj->objectId); |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1256 if (IS_ERR(inode)) |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1257 return NULL; |
| 7 | 1258 |
| 76 | 1259 /* NB Side effect: iget calls back to yaffs_read_inode(). */ |
| 1260 /* iget also increments the inode's i_count */ | |
|
106
5b8f68c30468
Apply Reed's deadlocking fix (manually applied)
charles <charles>
parents:
104
diff
changeset
|
1261 /* NB You can't be holding grossLock or deadlock will happen! */ |
| 76 | 1262 |
| 7 | 1263 return inode; |
| 1264 } | |
| 1265 | |
| 76 | 1266 static ssize_t yaffs_file_write(struct file *f, const char *buf, size_t n, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1267 loff_t *pos) |
| 7 | 1268 { |
| 1269 yaffs_Object *obj; | |
| 76 | 1270 int nWritten, ipos; |
| 7 | 1271 struct inode *inode; |
| 1272 yaffs_Device *dev; | |
| 76 | 1273 |
| 1274 obj = yaffs_DentryToObject(f->f_dentry); | |
| 1275 | |
| 7 | 1276 dev = obj->myDev; |
| 76 | 1277 |
| 7 | 1278 yaffs_GrossLock(dev); |
| 1279 | |
| 1280 inode = f->f_dentry->d_inode; | |
| 1281 | |
| 273 | 1282 if (!S_ISBLK(inode->i_mode) && f->f_flags & O_APPEND) |
| 7 | 1283 ipos = inode->i_size; |
| 273 | 1284 else |
| 7 | 1285 ipos = *pos; |
| 273 | 1286 |
| 1287 if (!obj) | |
| 76 | 1288 T(YAFFS_TRACE_OS, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1289 ("yaffs_file_write: hey obj is null!\n")); |
| 273 | 1290 else |
| 76 | 1291 T(YAFFS_TRACE_OS, |
| 332 | 1292 ("yaffs_file_write about to write writing %u(%x) bytes" |
| 1293 "to object %d at %d(%x)\n", | |
| 1294 (unsigned) n, (unsigned) n, obj->objectId, ipos,ipos)); | |
| 7 | 1295 |
| 76 | 1296 nWritten = yaffs_WriteDataToFile(obj, buf, ipos, n, 0); |
| 7 | 1297 |
| 76 | 1298 T(YAFFS_TRACE_OS, |
| 332 | 1299 ("yaffs_file_write: %d(%x) bytes written\n", |
| 1300 (unsigned )n,(unsigned)n)); | |
| 273 | 1301 |
| 76 | 1302 if (nWritten > 0) { |
| 7 | 1303 ipos += nWritten; |
| 1304 *pos = ipos; | |
| 76 | 1305 if (ipos > inode->i_size) { |
| 7 | 1306 inode->i_size = ipos; |
| 76 | 1307 inode->i_blocks = (ipos + 511) >> 9; |
| 1308 | |
| 1309 T(YAFFS_TRACE_OS, | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1310 ("yaffs_file_write size updated to %d bytes, " |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1311 "%d blocks\n", |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1312 ipos, (int)(inode->i_blocks))); |
| 7 | 1313 } |
| 76 | 1314 |
| 7 | 1315 } |
| 1316 yaffs_GrossUnlock(dev); | |
|
278
ba8a7124dc1f
Fix -ENOSPC to work properly with zero length writes
charles <charles>
parents:
277
diff
changeset
|
1317 return (nWritten == 0) && (n > 0) ? -ENOSPC : nWritten; |
| 7 | 1318 } |
| 1319 | |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1320 /* Space holding and freeing is done to ensure we have space available for write_begin/end */ |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1321 /* For now we just assume few parallel writes and check against a small number. */ |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1322 /* Todo: need to do this with a counter to handle parallel reads better */ |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1323 |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1324 static ssize_t yaffs_hold_space(struct file *f) |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1325 { |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1326 yaffs_Object *obj; |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1327 yaffs_Device *dev; |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1328 |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1329 int nFreeChunks; |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1330 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1331 |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1332 obj = yaffs_DentryToObject(f->f_dentry); |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1333 |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1334 dev = obj->myDev; |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1335 |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1336 yaffs_GrossLock(dev); |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1337 |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1338 nFreeChunks = yaffs_GetNumberOfFreeChunks(dev); |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1339 |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1340 yaffs_GrossUnlock(dev); |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1341 |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1342 return (nFreeChunks > 20) ? 1 : 0; |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1343 } |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1344 |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1345 static void yaffs_release_space(struct file *f) |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1346 { |
|
320
37b5b3fda7c0
Revert readdir locking fix that doesn't work properly
charles <charles>
parents:
319
diff
changeset
|
1347 yaffs_Object *obj; |
|
37b5b3fda7c0
Revert readdir locking fix that doesn't work properly
charles <charles>
parents:
319
diff
changeset
|
1348 yaffs_Device *dev; |
|
37b5b3fda7c0
Revert readdir locking fix that doesn't work properly
charles <charles>
parents:
319
diff
changeset
|
1349 |
|
37b5b3fda7c0
Revert readdir locking fix that doesn't work properly
charles <charles>
parents:
319
diff
changeset
|
1350 |
|
37b5b3fda7c0
Revert readdir locking fix that doesn't work properly
charles <charles>
parents:
319
diff
changeset
|
1351 obj = yaffs_DentryToObject(f->f_dentry); |
|
37b5b3fda7c0
Revert readdir locking fix that doesn't work properly
charles <charles>
parents:
319
diff
changeset
|
1352 |
|
37b5b3fda7c0
Revert readdir locking fix that doesn't work properly
charles <charles>
parents:
319
diff
changeset
|
1353 dev = obj->myDev; |
|
37b5b3fda7c0
Revert readdir locking fix that doesn't work properly
charles <charles>
parents:
319
diff
changeset
|
1354 |
|
37b5b3fda7c0
Revert readdir locking fix that doesn't work properly
charles <charles>
parents:
319
diff
changeset
|
1355 yaffs_GrossLock(dev); |
|
37b5b3fda7c0
Revert readdir locking fix that doesn't work properly
charles <charles>
parents:
319
diff
changeset
|
1356 |
|
37b5b3fda7c0
Revert readdir locking fix that doesn't work properly
charles <charles>
parents:
319
diff
changeset
|
1357 |
|
37b5b3fda7c0
Revert readdir locking fix that doesn't work properly
charles <charles>
parents:
319
diff
changeset
|
1358 yaffs_GrossUnlock(dev); |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1359 } |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1360 |
| 398 | 1361 |
| 1362 static loff_t yaffs_dir_llseek(struct file *file, loff_t offset, int origin) | |
| 1363 { | |
| 1364 long long retval; | |
| 1365 | |
| 1366 lock_kernel(); | |
| 1367 | |
| 1368 switch (origin){ | |
| 1369 case 2: | |
| 1370 offset += i_size_read(file->f_path.dentry->d_inode); | |
| 1371 break; | |
| 1372 case 1: | |
| 1373 offset += file->f_pos; | |
| 1374 } | |
| 1375 retval = -EINVAL; | |
| 1376 | |
| 1377 if (offset >= 0){ | |
| 1378 if (offset != file->f_pos) | |
| 1379 file->f_pos = offset; | |
| 1380 | |
| 1381 retval = offset; | |
| 1382 } | |
| 1383 unlock_kernel(); | |
| 1384 return retval; | |
| 1385 } | |
| 1386 | |
| 1387 | |
| 7 | 1388 static int yaffs_readdir(struct file *f, void *dirent, filldir_t filldir) |
| 1389 { | |
| 1390 yaffs_Object *obj; | |
| 1391 yaffs_Device *dev; | |
| 321 | 1392 struct yaffs_SearchContext *sc; |
| 7 | 1393 struct inode *inode = f->f_dentry->d_inode; |
| 1394 unsigned long offset, curoffs; | |
| 1395 yaffs_Object *l; | |
| 321 | 1396 int retVal = 0; |
| 76 | 1397 |
| 1398 char name[YAFFS_MAX_NAME_LENGTH + 1]; | |
| 1399 | |
| 1400 obj = yaffs_DentryToObject(f->f_dentry); | |
| 7 | 1401 dev = obj->myDev; |
| 76 | 1402 |
| 7 | 1403 yaffs_GrossLock(dev); |
| 76 | 1404 |
| 398 | 1405 yaffs_DeviceToContext(dev)->readdirProcess = current; |
| 1406 | |
| 7 | 1407 offset = f->f_pos; |
| 76 | 1408 |
| 321 | 1409 sc = yaffs_NewSearch(obj); |
| 1410 if(!sc){ | |
| 1411 retVal = -ENOMEM; | |
| 1412 goto unlock_out; | |
| 1413 } | |
| 1414 | |
| 76 | 1415 T(YAFFS_TRACE_OS, ("yaffs_readdir: starting at %d\n", (int)offset)); |
| 1416 | |
| 1417 if (offset == 0) { | |
| 1418 T(YAFFS_TRACE_OS, | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1419 ("yaffs_readdir: entry . ino %d \n", |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1420 (int)inode->i_ino)); |
| 321 | 1421 yaffs_GrossUnlock(dev); |
| 273 | 1422 if (filldir(dirent, ".", 1, offset, inode->i_ino, DT_DIR) < 0) |
| 7 | 1423 goto out; |
| 321 | 1424 yaffs_GrossLock(dev); |
| 7 | 1425 offset++; |
| 1426 f->f_pos++; | |
| 1427 } | |
| 76 | 1428 if (offset == 1) { |
| 1429 T(YAFFS_TRACE_OS, | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1430 ("yaffs_readdir: entry .. ino %d \n", |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1431 (int)f->f_dentry->d_parent->d_inode->i_ino)); |
| 321 | 1432 yaffs_GrossUnlock(dev); |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1433 if (filldir(dirent, "..", 2, offset, |
| 273 | 1434 f->f_dentry->d_parent->d_inode->i_ino, DT_DIR) < 0) |
| 7 | 1435 goto out; |
| 321 | 1436 yaffs_GrossLock(dev); |
| 7 | 1437 offset++; |
| 1438 f->f_pos++; | |
| 1439 } | |
| 76 | 1440 |
| 7 | 1441 curoffs = 1; |
| 76 | 1442 |
| 117 | 1443 /* If the directory has changed since the open or last call to |
| 1444 readdir, rewind to after the 2 canned entries. */ | |
| 398 | 1445 #if 0 /* For exportfs patch */ |
| 117 | 1446 if (f->f_version != inode->i_version) { |
| 1447 offset = 2; | |
| 1448 f->f_pos = offset; | |
| 1449 f->f_version = inode->i_version; | |
| 1450 } | |
| 398 | 1451 #endif |
| 117 | 1452 |
| 321 | 1453 while(sc->nextReturn){ |
| 7 | 1454 curoffs++; |
| 321 | 1455 l = sc->nextReturn; |
| 76 | 1456 if (curoffs >= offset) { |
| 321 | 1457 int this_inode = yaffs_GetObjectInode(l); |
| 1458 int this_type = yaffs_GetObjectType(l); | |
| 76 | 1459 |
| 1460 yaffs_GetObjectName(l, name, | |
| 1461 YAFFS_MAX_NAME_LENGTH + 1); | |
| 1462 T(YAFFS_TRACE_OS, | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1463 ("yaffs_readdir: %s inode %d\n", name, |
| 76 | 1464 yaffs_GetObjectInode(l))); |
| 1465 | |
| 321 | 1466 yaffs_GrossUnlock(dev); |
| 1467 | |
| 76 | 1468 if (filldir(dirent, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1469 name, |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1470 strlen(name), |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1471 offset, |
| 321 | 1472 this_inode, |
| 1473 this_type) < 0) | |
| 1474 goto out; | |
| 1475 | |
| 1476 yaffs_GrossLock(dev); | |
| 76 | 1477 |
| 7 | 1478 offset++; |
| 76 | 1479 f->f_pos++; |
| 7 | 1480 } |
| 321 | 1481 yaffs_SearchAdvance(sc); |
| 7 | 1482 } |
| 1483 | |
| 321 | 1484 unlock_out: |
| 398 | 1485 yaffs_DeviceToContext(dev)->readdirProcess = NULL; |
| 1486 | |
| 321 | 1487 yaffs_GrossUnlock(dev); |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1488 out: |
| 321 | 1489 yaffs_EndSearch(sc); |
| 1490 | |
| 1491 return retVal; | |
| 7 | 1492 } |
| 1493 | |
| 398 | 1494 |
| 1495 | |
| 7 | 1496 /* |
| 1497 * File creation. Allocate an inode, and we're done.. | |
| 1498 */ | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1499 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1500 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) |
| 266 | 1501 #define YCRED(x) x |
| 1502 #else | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1503 #define YCRED(x) (x->cred) |
| 266 | 1504 #endif |
| 1505 | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1506 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0)) |
| 76 | 1507 static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1508 dev_t rdev) |
| 7 | 1509 #else |
| 76 | 1510 static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1511 int rdev) |
| 7 | 1512 #endif |
| 1513 { | |
| 1514 struct inode *inode; | |
| 76 | 1515 |
| 7 | 1516 yaffs_Object *obj = NULL; |
| 1517 yaffs_Device *dev; | |
| 76 | 1518 |
| 7 | 1519 yaffs_Object *parent = yaffs_InodeToObject(dir); |
| 76 | 1520 |
| 7 | 1521 int error = -ENOSPC; |
| 266 | 1522 uid_t uid = YCRED(current)->fsuid; |
| 1523 gid_t gid = (dir->i_mode & S_ISGID) ? dir->i_gid : YCRED(current)->fsgid; | |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
1524 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1525 if ((dir->i_mode & S_ISGID) && S_ISDIR(mode)) |
| 133 | 1526 mode |= S_ISGID; |
| 7 | 1527 |
| 76 | 1528 if (parent) { |
| 1529 T(YAFFS_TRACE_OS, | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1530 ("yaffs_mknod: parent object %d type %d\n", |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1531 parent->objectId, parent->variantType)); |
| 76 | 1532 } else { |
| 1533 T(YAFFS_TRACE_OS, | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1534 ("yaffs_mknod: could not get parent object\n")); |
| 7 | 1535 return -EPERM; |
| 1536 } | |
| 76 | 1537 |
| 1538 T(YAFFS_TRACE_OS, ("yaffs_mknod: making oject for %s, " | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1539 "mode %x dev %x\n", |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1540 dentry->d_name.name, mode, rdev)); |
| 7 | 1541 |
| 1542 dev = parent->myDev; | |
| 76 | 1543 |
| 7 | 1544 yaffs_GrossLock(dev); |
| 1545 | |
| 76 | 1546 switch (mode & S_IFMT) { |
| 1547 default: | |
| 1548 /* Special (socket, fifo, device...) */ | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1549 T(YAFFS_TRACE_OS, ("yaffs_mknod: making special\n")); |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1550 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0)) |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1551 obj = yaffs_MknodSpecial(parent, dentry->d_name.name, mode, uid, |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1552 gid, old_encode_dev(rdev)); |
| 12 | 1553 #else |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1554 obj = yaffs_MknodSpecial(parent, dentry->d_name.name, mode, uid, |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1555 gid, rdev); |
| 76 | 1556 #endif |
| 1557 break; | |
| 1558 case S_IFREG: /* file */ | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1559 T(YAFFS_TRACE_OS, ("yaffs_mknod: making file\n")); |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1560 obj = yaffs_MknodFile(parent, dentry->d_name.name, mode, uid, |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1561 gid); |
| 76 | 1562 break; |
| 1563 case S_IFDIR: /* directory */ | |
| 1564 T(YAFFS_TRACE_OS, | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1565 ("yaffs_mknod: making directory\n")); |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1566 obj = yaffs_MknodDirectory(parent, dentry->d_name.name, mode, |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1567 uid, gid); |
| 76 | 1568 break; |
| 1569 case S_IFLNK: /* symlink */ | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1570 T(YAFFS_TRACE_OS, ("yaffs_mknod: making symlink\n")); |
| 76 | 1571 obj = NULL; /* Do we ever get here? */ |
| 1572 break; | |
| 7 | 1573 } |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
1574 |
|
106
5b8f68c30468
Apply Reed's deadlocking fix (manually applied)
charles <charles>
parents:
104
diff
changeset
|
1575 /* Can not call yaffs_get_inode() with gross lock held */ |
|
5b8f68c30468
Apply Reed's deadlocking fix (manually applied)
charles <charles>
parents:
104
diff
changeset
|
1576 yaffs_GrossUnlock(dev); |
| 76 | 1577 |
| 1578 if (obj) { | |
| 7 | 1579 inode = yaffs_get_inode(dir->i_sb, mode, rdev, obj); |
| 1580 d_instantiate(dentry, inode); | |
| 280 | 1581 update_dir_time(dir); |
| 76 | 1582 T(YAFFS_TRACE_OS, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1583 ("yaffs_mknod created object %d count = %d\n", |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1584 obj->objectId, atomic_read(&inode->i_count))); |
| 7 | 1585 error = 0; |
| 398 | 1586 yaffs_FillInodeFromObject(dir,parent); |
| 76 | 1587 } else { |
| 1588 T(YAFFS_TRACE_OS, | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1589 ("yaffs_mknod failed making object\n")); |
| 7 | 1590 error = -ENOMEM; |
| 1591 } | |
| 1592 | |
| 1593 return error; | |
| 1594 } | |
| 1595 | |
| 76 | 1596 static int yaffs_mkdir(struct inode *dir, struct dentry *dentry, int mode) |
| 7 | 1597 { |
| 1598 int retVal; | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1599 T(YAFFS_TRACE_OS, ("yaffs_mkdir\n")); |
| 76 | 1600 retVal = yaffs_mknod(dir, dentry, mode | S_IFDIR, 0); |
| 7 | 1601 return retVal; |
| 1602 } | |
| 1603 | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1604 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0)) |
| 76 | 1605 static int yaffs_create(struct inode *dir, struct dentry *dentry, int mode, |
| 1606 struct nameidata *n) | |
| 7 | 1607 #else |
| 1608 static int yaffs_create(struct inode *dir, struct dentry *dentry, int mode) | |
| 1609 #endif | |
| 1610 { | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1611 T(YAFFS_TRACE_OS, ("yaffs_create\n")); |
| 7 | 1612 return yaffs_mknod(dir, dentry, mode | S_IFREG, 0); |
| 1613 } | |
| 1614 | |
| 76 | 1615 static int yaffs_unlink(struct inode *dir, struct dentry *dentry) |
| 7 | 1616 { |
| 1617 int retVal; | |
| 76 | 1618 |
| 7 | 1619 yaffs_Device *dev; |
| 398 | 1620 yaffs_Object *obj; |
| 76 | 1621 |
| 1622 T(YAFFS_TRACE_OS, | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1623 ("yaffs_unlink %d:%s\n", (int)(dir->i_ino), |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1624 dentry->d_name.name)); |
| 398 | 1625 obj = yaffs_InodeToObject(dir); |
| 1626 dev = obj->myDev; | |
| 76 | 1627 |
| 7 | 1628 yaffs_GrossLock(dev); |
| 76 | 1629 |
| 398 | 1630 retVal = yaffs_Unlink(obj, dentry->d_name.name); |
| 76 | 1631 |
| 1632 if (retVal == YAFFS_OK) { | |
| 7 | 1633 dentry->d_inode->i_nlink--; |
| 117 | 1634 dir->i_version++; |
|
320
37b5b3fda7c0
Revert readdir locking fix that doesn't work properly
charles <charles>
parents:
319
diff
changeset
|
1635 yaffs_GrossUnlock(dev); |
| 7 | 1636 mark_inode_dirty(dentry->d_inode); |
| 280 | 1637 update_dir_time(dir); |
| 7 | 1638 return 0; |
| 1639 } | |
|
320
37b5b3fda7c0
Revert readdir locking fix that doesn't work properly
charles <charles>
parents:
319
diff
changeset
|
1640 yaffs_GrossUnlock(dev); |
| 117 | 1641 return -ENOTEMPTY; |
| 7 | 1642 } |
| 1643 | |
| 1644 /* | |
| 1645 * Create a link... | |
| 1646 */ | |
| 76 | 1647 static int yaffs_link(struct dentry *old_dentry, struct inode *dir, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1648 struct dentry *dentry) |
| 7 | 1649 { |
| 1650 struct inode *inode = old_dentry->d_inode; | |
| 1651 yaffs_Object *obj = NULL; | |
| 76 | 1652 yaffs_Object *link = NULL; |
| 7 | 1653 yaffs_Device *dev; |
| 76 | 1654 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1655 T(YAFFS_TRACE_OS, ("yaffs_link\n")); |
| 76 | 1656 |
| 7 | 1657 obj = yaffs_InodeToObject(inode); |
| 1658 dev = obj->myDev; | |
| 76 | 1659 |
| 7 | 1660 yaffs_GrossLock(dev); |
| 1661 | |
| 273 | 1662 if (!S_ISDIR(inode->i_mode)) /* Don't link directories */ |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1663 link = yaffs_Link(yaffs_InodeToObject(dir), dentry->d_name.name, |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1664 obj); |
| 7 | 1665 |
| 76 | 1666 if (link) { |
| 1667 old_dentry->d_inode->i_nlink = yaffs_GetObjectLinkCount(obj); | |
| 7 | 1668 d_instantiate(dentry, old_dentry->d_inode); |
| 1669 atomic_inc(&old_dentry->d_inode->i_count); | |
| 76 | 1670 T(YAFFS_TRACE_OS, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1671 ("yaffs_link link count %d i_count %d\n", |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1672 old_dentry->d_inode->i_nlink, |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1673 atomic_read(&old_dentry->d_inode->i_count))); |
| 7 | 1674 } |
| 76 | 1675 |
| 7 | 1676 yaffs_GrossUnlock(dev); |
| 1677 | |
| 280 | 1678 if (link){ |
| 1679 update_dir_time(dir); | |
| 7 | 1680 return 0; |
| 280 | 1681 } |
| 76 | 1682 |
| 1683 return -EPERM; | |
| 7 | 1684 } |
| 1685 | |
| 76 | 1686 static int yaffs_symlink(struct inode *dir, struct dentry *dentry, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1687 const char *symname) |
| 7 | 1688 { |
| 1689 yaffs_Object *obj; | |
| 1690 yaffs_Device *dev; | |
| 266 | 1691 uid_t uid = YCRED(current)->fsuid; |
| 1692 gid_t gid = (dir->i_mode & S_ISGID) ? dir->i_gid : YCRED(current)->fsgid; | |
| 76 | 1693 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1694 T(YAFFS_TRACE_OS, ("yaffs_symlink\n")); |
| 76 | 1695 |
| 7 | 1696 dev = yaffs_InodeToObject(dir)->myDev; |
| 1697 yaffs_GrossLock(dev); | |
| 76 | 1698 obj = yaffs_MknodSymLink(yaffs_InodeToObject(dir), dentry->d_name.name, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1699 S_IFLNK | S_IRWXUGO, uid, gid, symname); |
| 7 | 1700 yaffs_GrossUnlock(dev); |
| 1701 | |
| 76 | 1702 if (obj) { |
| 1703 struct inode *inode; | |
| 1704 | |
|
22
0b57027b96fe
Some improvements to garbage collection and st_xxx to yst_xxx changes
charles <charles>
parents:
19
diff
changeset
|
1705 inode = yaffs_get_inode(dir->i_sb, obj->yst_mode, 0, obj); |
| 7 | 1706 d_instantiate(dentry, inode); |
| 280 | 1707 update_dir_time(dir); |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1708 T(YAFFS_TRACE_OS, ("symlink created OK\n")); |
| 7 | 1709 return 0; |
| 76 | 1710 } else { |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1711 T(YAFFS_TRACE_OS, ("symlink not created\n")); |
| 7 | 1712 } |
| 76 | 1713 |
| 7 | 1714 return -ENOMEM; |
| 1715 } | |
| 1716 | |
| 76 | 1717 static int yaffs_sync_object(struct file *file, struct dentry *dentry, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1718 int datasync) |
| 7 | 1719 { |
| 1720 | |
| 1721 yaffs_Object *obj; | |
| 1722 yaffs_Device *dev; | |
| 76 | 1723 |
| 7 | 1724 obj = yaffs_DentryToObject(dentry); |
| 1725 | |
| 1726 dev = obj->myDev; | |
| 76 | 1727 |
| 342 | 1728 T(YAFFS_TRACE_OS | YAFFS_TRACE_SYNC, ("yaffs_sync_object\n")); |
| 7 | 1729 yaffs_GrossLock(dev); |
| 291 | 1730 yaffs_FlushFile(obj, 1, datasync); |
| 7 | 1731 yaffs_GrossUnlock(dev); |
| 1732 return 0; | |
| 1733 } | |
| 1734 | |
| 1735 /* | |
| 1736 * The VFS layer already does all the dentry stuff for rename. | |
| 1737 * | |
| 1738 * NB: POSIX says you can rename an object over an old object of the same name | |
| 1739 */ | |
| 76 | 1740 static int yaffs_rename(struct inode *old_dir, struct dentry *old_dentry, |
| 1741 struct inode *new_dir, struct dentry *new_dentry) | |
| 7 | 1742 { |
| 1743 yaffs_Device *dev; | |
| 1744 int retVal = YAFFS_FAIL; | |
| 1745 yaffs_Object *target; | |
| 76 | 1746 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1747 T(YAFFS_TRACE_OS, ("yaffs_rename\n")); |
| 7 | 1748 dev = yaffs_InodeToObject(old_dir)->myDev; |
| 1749 | |
| 1750 yaffs_GrossLock(dev); | |
| 76 | 1751 |
| 1752 /* Check if the target is an existing directory that is not empty. */ | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1753 target = yaffs_FindObjectByName(yaffs_InodeToObject(new_dir), |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1754 new_dentry->d_name.name); |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1755 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1756 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1757 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1758 if (target && target->variantType == YAFFS_OBJECT_TYPE_DIRECTORY && |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1759 !ylist_empty(&target->variant.directoryVariant.children)) { |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1760 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1761 T(YAFFS_TRACE_OS, ("target is non-empty dir\n")); |
| 83 | 1762 |
| 7 | 1763 retVal = YAFFS_FAIL; |
| 76 | 1764 } else { |
| 1765 /* Now does unlinking internally using shadowing mechanism */ | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1766 T(YAFFS_TRACE_OS, ("calling yaffs_RenameObject\n")); |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1767 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1768 retVal = yaffs_RenameObject(yaffs_InodeToObject(old_dir), |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1769 old_dentry->d_name.name, |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1770 yaffs_InodeToObject(new_dir), |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1771 new_dentry->d_name.name); |
| 7 | 1772 } |
| 1773 yaffs_GrossUnlock(dev); | |
| 76 | 1774 |
| 1775 if (retVal == YAFFS_OK) { | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1776 if (target) { |
| 88 | 1777 new_dentry->d_inode->i_nlink--; |
| 1778 mark_inode_dirty(new_dentry->d_inode); | |
| 1779 } | |
| 280 | 1780 |
| 1781 update_dir_time(old_dir); | |
| 1782 if(old_dir != new_dir) | |
| 1783 update_dir_time(new_dir); | |
| 7 | 1784 return 0; |
| 76 | 1785 } else { |
| 7 | 1786 return -ENOTEMPTY; |
| 1787 } | |
| 1788 } | |
| 1789 | |
| 1790 static int yaffs_setattr(struct dentry *dentry, struct iattr *attr) | |
| 1791 { | |
| 1792 struct inode *inode = dentry->d_inode; | |
| 350 | 1793 int error = 0; |
| 7 | 1794 yaffs_Device *dev; |
| 76 | 1795 |
| 1796 T(YAFFS_TRACE_OS, | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1797 ("yaffs_setattr of object %d\n", |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1798 yaffs_InodeToObject(inode)->objectId)); |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1799 |
| 350 | 1800 /* Fail if a requested resize >= 2GB */ |
| 1801 if (attr->ia_valid & ATTR_SIZE && | |
| 1802 (attr->ia_size >> 31)) | |
| 1803 error = -EINVAL; | |
| 1804 | |
| 1805 if (error == 0) | |
| 1806 error = inode_change_ok(inode, attr); | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1807 if (error == 0) { |
| 332 | 1808 int result; |
| 1809 if (!error){ | |
| 1810 error = inode_setattr(inode, attr); | |
| 1811 T(YAFFS_TRACE_OS,("inode_setattr called\n")); | |
| 1812 if (attr->ia_valid & ATTR_SIZE) | |
| 1813 truncate_inode_pages(&inode->i_data,attr->ia_size); | |
| 1814 } | |
| 7 | 1815 dev = yaffs_InodeToObject(inode)->myDev; |
| 332 | 1816 if (attr->ia_valid & ATTR_SIZE){ |
| 1817 T(YAFFS_TRACE_OS,("resize to %d(%x)\n",(int)(attr->ia_size),(int)(attr->ia_size))); | |
| 1818 } | |
| 7 | 1819 yaffs_GrossLock(dev); |
| 332 | 1820 result = yaffs_SetAttributes(yaffs_InodeToObject(inode), attr); |
| 1821 if(result == YAFFS_OK) { | |
| 7 | 1822 error = 0; |
| 76 | 1823 } else { |
| 7 | 1824 error = -EPERM; |
| 1825 } | |
| 1826 yaffs_GrossUnlock(dev); | |
| 332 | 1827 |
| 7 | 1828 } |
| 350 | 1829 |
| 332 | 1830 T(YAFFS_TRACE_OS, |
| 350 | 1831 ("yaffs_setattr done returning %d\n",error)); |
| 332 | 1832 |
| 7 | 1833 return error; |
| 1834 } | |
| 1835 | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1836 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17)) |
| 143 | 1837 static int yaffs_statfs(struct dentry *dentry, struct kstatfs *buf) |
| 1838 { | |
| 1839 yaffs_Device *dev = yaffs_DentryToObject(dentry)->myDev; | |
| 1840 struct super_block *sb = dentry->d_sb; | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1841 #elif (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0)) |
| 7 | 1842 static int yaffs_statfs(struct super_block *sb, struct kstatfs *buf) |
| 143 | 1843 { |
| 1844 yaffs_Device *dev = yaffs_SuperToDevice(sb); | |
| 7 | 1845 #else |
| 1846 static int yaffs_statfs(struct super_block *sb, struct statfs *buf) | |
| 143 | 1847 { |
| 1848 yaffs_Device *dev = yaffs_SuperToDevice(sb); | |
| 7 | 1849 #endif |
| 15 | 1850 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1851 T(YAFFS_TRACE_OS, ("yaffs_statfs\n")); |
| 7 | 1852 |
| 1853 yaffs_GrossLock(dev); | |
| 76 | 1854 |
| 7 | 1855 buf->f_type = YAFFS_MAGIC; |
| 1856 buf->f_bsize = sb->s_blocksize; | |
| 1857 buf->f_namelen = 255; | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1858 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1859 if (dev->nDataBytesPerChunk & (dev->nDataBytesPerChunk - 1)) { |
|
204
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
1860 /* Do this if chunk size is not a power of 2 */ |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1861 |
|
204
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
1862 uint64_t bytesInDev; |
|
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
1863 uint64_t bytesFree; |
|
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
1864 |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
1865 bytesInDev = ((uint64_t)((dev->param.endBlock - dev->param.startBlock + 1))) * |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
1866 ((uint64_t)(dev->param.nChunksPerBlock * dev->nDataBytesPerChunk)); |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1867 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1868 do_div(bytesInDev, sb->s_blocksize); /* bytesInDev becomes the number of blocks */ |
|
204
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
1869 buf->f_blocks = bytesInDev; |
|
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
1870 |
|
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
1871 bytesFree = ((uint64_t)(yaffs_GetNumberOfFreeChunks(dev))) * |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1872 ((uint64_t)(dev->nDataBytesPerChunk)); |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1873 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1874 do_div(bytesFree, sb->s_blocksize); |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1875 |
|
204
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
1876 buf->f_bfree = bytesFree; |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1877 |
|
204
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
1878 } else if (sb->s_blocksize > dev->nDataBytesPerChunk) { |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1879 |
| 76 | 1880 buf->f_blocks = |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
1881 (dev->param.endBlock - dev->param.startBlock + 1) * |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
1882 dev->param.nChunksPerBlock / |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1883 (sb->s_blocksize / dev->nDataBytesPerChunk); |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1884 buf->f_bfree = |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1885 yaffs_GetNumberOfFreeChunks(dev) / |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1886 (sb->s_blocksize / dev->nDataBytesPerChunk); |
| 76 | 1887 } else { |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1888 buf->f_blocks = |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
1889 (dev->param.endBlock - dev->param.startBlock + 1) * |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
1890 dev->param.nChunksPerBlock * |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1891 (dev->nDataBytesPerChunk / sb->s_blocksize); |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1892 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1893 buf->f_bfree = |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1894 yaffs_GetNumberOfFreeChunks(dev) * |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1895 (dev->nDataBytesPerChunk / sb->s_blocksize); |
| 15 | 1896 } |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1897 |
| 7 | 1898 buf->f_files = 0; |
| 1899 buf->f_ffree = 0; | |
| 76 | 1900 buf->f_bavail = buf->f_bfree; |
| 1901 | |
| 7 | 1902 yaffs_GrossUnlock(dev); |
| 1903 return 0; | |
| 1904 } | |
| 1905 | |
| 129 | 1906 |
| 291 | 1907 |
|
372
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1908 static void yaffs_FlushInodes(struct super_block *sb) |
| 291 | 1909 { |
| 1910 struct inode *iptr; | |
| 1911 yaffs_Object *obj; | |
| 1912 | |
| 1913 list_for_each_entry(iptr,&sb->s_inodes, i_sb_list){ | |
| 1914 obj = yaffs_InodeToObject(iptr); | |
| 1915 if(obj){ | |
| 1916 T(YAFFS_TRACE_OS, ("flushing obj %d\n",obj->objectId)); | |
| 1917 yaffs_FlushFile(obj,1,0); | |
| 1918 } | |
| 1919 } | |
| 1920 } | |
| 1921 | |
|
372
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1922 |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1923 static void yaffs_FlushSuperBlock(struct super_block *sb, int do_checkpoint) |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1924 { |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1925 yaffs_Device *dev = yaffs_SuperToDevice(sb); |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1926 if(!dev) |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1927 return; |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1928 |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1929 yaffs_FlushInodes(sb); |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1930 yaffs_UpdateDirtyDirectories(dev); |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1931 yaffs_FlushEntireDeviceCache(dev); |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1932 if(do_checkpoint) |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1933 yaffs_CheckpointSave(dev); |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1934 } |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1935 |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1936 static int yaffs_do_sync_fs(struct super_block *sb, int do_checkpoint) |
| 129 | 1937 { |
| 1938 | |
| 1939 yaffs_Device *dev = yaffs_SuperToDevice(sb); | |
|
372
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1940 T(YAFFS_TRACE_OS | YAFFS_TRACE_SYNC, |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1941 ("yaffs_do_sync_fs: %s %s\n", |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1942 sb->s_dirt ? "dirty" : "clean", |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1943 do_checkpoint ? "with checkpoint" : "no checkpoint")); |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1944 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1945 if (sb->s_dirt) { |
| 129 | 1946 yaffs_GrossLock(dev); |
|
372
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1947 yaffs_FlushSuperBlock(sb,do_checkpoint); |
| 129 | 1948 yaffs_GrossUnlock(dev); |
| 1949 | |
| 1950 sb->s_dirt = 0; | |
| 1951 } | |
| 1952 return 0; | |
| 1953 } | |
|
210
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
1954 |
|
372
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1955 /* |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1956 * yaffs background thread functions . |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1957 * yaffs_BackgroundThread() the thread function |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1958 * yaffs_BackgroundStart() launches the background thread. |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1959 * yaffs_BackgroundStop() cleans up the background thread. |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1960 * |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1961 * NB: |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1962 * The thread should only run after the yaffs is initialised |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1963 * The thread should be stopped before yaffs is unmounted. |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1964 * The thread should not do any writing while the fs is in read only. |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1965 */ |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1966 |
|
374
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
1967 #ifdef YAFFS_COMPILE_BACKGROUND |
|
372
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1968 static int yaffs_BackgroundThread(void *data) |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1969 { |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1970 yaffs_Device *dev = (yaffs_Device *)data; |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1971 struct yaffs_LinuxContext *context = yaffs_DeviceToContext(dev); |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1972 |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1973 T(YAFFS_TRACE_BACKGROUND, |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1974 ("yaffs_background starting for dev %p\n", |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1975 (void *)dev)); |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1976 |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1977 while(context->bgRunning){ |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1978 T(YAFFS_TRACE_BACKGROUND, |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1979 ("yaffs_background\n")); |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1980 |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1981 if(kthread_should_stop()) |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1982 break; |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1983 yaffs_GrossLock(dev); |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1984 yaffs_UpdateDirtyDirectories(dev); |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1985 yaffs_GrossUnlock(dev); |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1986 msleep(500); |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1987 } |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1988 return 0; |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1989 } |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1990 |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1991 static int yaffs_BackgroundStart(yaffs_Device *dev) |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1992 { |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1993 int retval = 0; |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1994 |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1995 struct yaffs_LinuxContext *context = yaffs_DeviceToContext(dev); |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1996 |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1997 context->bgRunning = 1; |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1998 |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1999 context->bgThread = kthread_run(yaffs_BackgroundThread,(void *)dev,"yaffs_%x",(unsigned)dev); |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2000 |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2001 if(IS_ERR(context->bgThread)){ |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2002 retval = PTR_ERR(context->bgThread); |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2003 context->bgThread = NULL; |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2004 context->bgRunning = 0; |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2005 } |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2006 return retval; |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2007 } |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2008 |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2009 static void yaffs_BackgroundStop(yaffs_Device *dev) |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2010 { |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2011 struct yaffs_LinuxContext *ctxt = yaffs_DeviceToContext(dev); |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2012 |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2013 ctxt->bgRunning = 0; |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2014 |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2015 if( ctxt->bgThread){ |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2016 kthread_stop(ctxt->bgThread); |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2017 ctxt->bgThread = NULL; |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2018 } |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2019 } |
|
374
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
2020 #else |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
2021 static int yaffs_BackgroundThread(void *data) |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
2022 { |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
2023 return 0; |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
2024 } |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
2025 |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
2026 static int yaffs_BackgroundStart(yaffs_Device *dev) |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
2027 { |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
2028 return 0; |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
2029 } |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
2030 |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
2031 static void yaffs_BackgroundStop(yaffs_Device *dev) |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
2032 { |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
2033 } |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
2034 #endif |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
2035 |
| 129 | 2036 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2037 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17)) |
| 143 | 2038 static void yaffs_write_super(struct super_block *sb) |
| 2039 #else | |
| 129 | 2040 static int yaffs_write_super(struct super_block *sb) |
| 143 | 2041 #endif |
| 129 | 2042 { |
| 2043 | |
| 342 | 2044 T(YAFFS_TRACE_OS | YAFFS_TRACE_SYNC, ("yaffs_write_super\n")); |
|
372
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2045 yaffs_do_sync_fs(sb, yaffs_auto_checkpoint >= 2); |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2046 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2047 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18)) |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2048 return 0; |
| 143 | 2049 #endif |
| 129 | 2050 } |
| 2051 | |
| 2052 | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2053 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17)) |
| 143 | 2054 static int yaffs_sync_fs(struct super_block *sb, int wait) |
| 2055 #else | |
| 129 | 2056 static int yaffs_sync_fs(struct super_block *sb) |
| 143 | 2057 #endif |
| 129 | 2058 { |
| 342 | 2059 T(YAFFS_TRACE_OS | YAFFS_TRACE_SYNC, ("yaffs_sync_fs\n")); |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2060 |
|
372
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2061 yaffs_do_sync_fs(sb,yaffs_auto_checkpoint >= 1); |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2062 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2063 return 0; |
| 129 | 2064 } |
| 2065 | |
|
210
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2066 #ifdef YAFFS_USE_OWN_IGET |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2067 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2068 static struct inode *yaffs_iget(struct super_block *sb, unsigned long ino) |
|
210
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2069 { |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2070 struct inode *inode; |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2071 yaffs_Object *obj; |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2072 yaffs_Device *dev = yaffs_SuperToDevice(sb); |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2073 |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2074 T(YAFFS_TRACE_OS, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2075 ("yaffs_iget for %lu\n", ino)); |
|
210
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2076 |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2077 inode = iget_locked(sb, ino); |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2078 if (!inode) |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2079 return ERR_PTR(-ENOMEM); |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2080 if (!(inode->i_state & I_NEW)) |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2081 return inode; |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2082 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2083 /* NB This is called as a side effect of other functions, but |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2084 * we had to release the lock to prevent deadlocks, so |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2085 * need to lock again. |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2086 */ |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2087 |
|
210
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2088 yaffs_GrossLock(dev); |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2089 |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2090 obj = yaffs_FindObjectByNumber(dev, inode->i_ino); |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2091 |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2092 yaffs_FillInodeFromObject(inode, obj); |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2093 |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2094 yaffs_GrossUnlock(dev); |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2095 |
|
210
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2096 unlock_new_inode(inode); |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2097 return inode; |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2098 } |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2099 |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2100 #else |
| 129 | 2101 |
| 76 | 2102 static void yaffs_read_inode(struct inode *inode) |
| 7 | 2103 { |
|
106
5b8f68c30468
Apply Reed's deadlocking fix (manually applied)
charles <charles>
parents:
104
diff
changeset
|
2104 /* NB This is called as a side effect of other functions, but |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2105 * we had to release the lock to prevent deadlocks, so |
|
106
5b8f68c30468
Apply Reed's deadlocking fix (manually applied)
charles <charles>
parents:
104
diff
changeset
|
2106 * need to lock again. |
| 76 | 2107 */ |
| 2108 | |
| 2109 yaffs_Object *obj; | |
| 7 | 2110 yaffs_Device *dev = yaffs_SuperToDevice(inode->i_sb); |
| 76 | 2111 |
| 2112 T(YAFFS_TRACE_OS, | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2113 ("yaffs_read_inode for %d\n", (int)inode->i_ino)); |
| 7 | 2114 |
| 398 | 2115 if(current != yaffs_DeviceToContext(dev)->readdirProcess) |
| 2116 yaffs_GrossLock(dev); | |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2117 |
| 76 | 2118 obj = yaffs_FindObjectByNumber(dev, inode->i_ino); |
| 2119 | |
| 2120 yaffs_FillInodeFromObject(inode, obj); | |
| 7 | 2121 |
| 398 | 2122 if(current != yaffs_DeviceToContext(dev)->readdirProcess) |
| 2123 yaffs_GrossUnlock(dev); | |
| 7 | 2124 } |
| 2125 | |
|
210
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2126 #endif |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2127 |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2128 static YLIST_HEAD(yaffs_context_list); |
|
384
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2129 struct semaphore yaffs_context_lock; |
| 7 | 2130 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2131 #if 0 /* not used */ |
| 175 | 2132 static int yaffs_remount_fs(struct super_block *sb, int *flags, char *data) |
| 2133 { | |
| 2134 yaffs_Device *dev = yaffs_SuperToDevice(sb); | |
| 2135 | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2136 if (*flags & MS_RDONLY) { |
| 175 | 2137 struct mtd_info *mtd = yaffs_SuperToDevice(sb)->genericDevice; |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2138 |
| 175 | 2139 T(YAFFS_TRACE_OS, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2140 ("yaffs_remount_fs: %s: RO\n", dev->name)); |
|
320
37b5b3fda7c0
Revert readdir locking fix that doesn't work properly
charles <charles>
parents:
319
diff
changeset
|
2141 |
| 175 | 2142 yaffs_GrossLock(dev); |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2143 |
|
372
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2144 yaffs_FlushSuperBlock(sb,1); |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2145 |
| 175 | 2146 if (mtd->sync) |
| 2147 mtd->sync(mtd); | |
| 2148 | |
| 2149 yaffs_GrossUnlock(dev); | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2150 } else { |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2151 T(YAFFS_TRACE_OS, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2152 ("yaffs_remount_fs: %s: RW\n", dev->name)); |
| 175 | 2153 } |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2154 |
| 175 | 2155 return 0; |
| 2156 } | |
| 189 | 2157 #endif |
| 175 | 2158 |
| 7 | 2159 static void yaffs_put_super(struct super_block *sb) |
| 2160 { | |
| 2161 yaffs_Device *dev = yaffs_SuperToDevice(sb); | |
| 76 | 2162 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2163 T(YAFFS_TRACE_OS, ("yaffs_put_super\n")); |
| 129 | 2164 |
| 7 | 2165 yaffs_GrossLock(dev); |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2166 |
|
372
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2167 yaffs_FlushSuperBlock(sb,1); |
| 175 | 2168 |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2169 if (yaffs_DeviceToContext(dev)->putSuperFunc) |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2170 yaffs_DeviceToContext(dev)->putSuperFunc(sb); |
| 175 | 2171 |
|
372
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2172 yaffs_BackgroundStop(dev); |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2173 |
| 7 | 2174 yaffs_Deinitialise(dev); |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2175 |
| 7 | 2176 yaffs_GrossUnlock(dev); |
| 2177 | |
|
384
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2178 down(&yaffs_context_lock); |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2179 ylist_del_init(&(yaffs_DeviceToContext(dev)->contextList)); |
|
384
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2180 up(&yaffs_context_lock); |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2181 |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2182 if (yaffs_DeviceToContext(dev)->spareBuffer) { |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2183 YFREE(yaffs_DeviceToContext(dev)->spareBuffer); |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2184 yaffs_DeviceToContext(dev)->spareBuffer = NULL; |
| 124 | 2185 } |
| 27 | 2186 |
| 7 | 2187 kfree(dev); |
| 2188 } | |
| 2189 | |
| 2190 | |
| 76 | 2191 static void yaffs_MTDPutSuper(struct super_block *sb) |
| 7 | 2192 { |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2193 struct mtd_info *mtd = yaffs_DeviceToContext(yaffs_SuperToDevice(sb))->mtd; |
| 76 | 2194 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2195 if (mtd->sync) |
| 7 | 2196 mtd->sync(mtd); |
| 76 | 2197 |
| 7 | 2198 put_mtd_device(mtd); |
| 2199 } | |
| 2200 | |
| 2201 | |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2202 static void yaffs_MarkSuperBlockDirty(yaffs_Device *dev) |
| 129 | 2203 { |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2204 struct super_block *sb = yaffs_DeviceToContext(dev)->superBlock; |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2205 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2206 T(YAFFS_TRACE_OS, ("yaffs_MarkSuperBlockDirty() sb = %p\n", sb)); |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2207 if (sb) |
| 249 | 2208 sb->s_dirt = 1; |
| 129 | 2209 } |
| 2210 | |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2211 typedef struct { |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2212 int inband_tags; |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2213 int skip_checkpoint_read; |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2214 int skip_checkpoint_write; |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2215 int no_cache; |
| 300 | 2216 int tags_ecc_on; |
| 2217 int tags_ecc_overridden; | |
| 311 | 2218 int lazy_loading_enabled; |
| 2219 int lazy_loading_overridden; | |
| 2220 int empty_lost_and_found; | |
| 2221 int empty_lost_and_found_overridden; | |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2222 } yaffs_options; |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2223 |
| 311 | 2224 #define MAX_OPT_LEN 30 |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2225 static int yaffs_parse_options(yaffs_options *options, const char *options_str) |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2226 { |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2227 char cur_opt[MAX_OPT_LEN + 1]; |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2228 int p; |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2229 int error = 0; |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2230 |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2231 /* Parse through the options which is a comma seperated list */ |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2232 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2233 while (options_str && *options_str && !error) { |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2234 memset(cur_opt, 0, MAX_OPT_LEN + 1); |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2235 p = 0; |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2236 |
| 300 | 2237 while(*options_str == ',') |
| 2238 options_str++; | |
| 2239 | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2240 while (*options_str && *options_str != ',') { |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2241 if (p < MAX_OPT_LEN) { |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2242 cur_opt[p] = *options_str; |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2243 p++; |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2244 } |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2245 options_str++; |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2246 } |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2247 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2248 if (!strcmp(cur_opt, "inband-tags")) |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2249 options->inband_tags = 1; |
| 300 | 2250 else if (!strcmp(cur_opt, "tags-ecc-off")){ |
| 2251 options->tags_ecc_on = 0; | |
| 2252 options->tags_ecc_overridden=1; | |
| 2253 } else if (!strcmp(cur_opt, "tags-ecc-on")){ | |
| 2254 options->tags_ecc_on = 1; | |
| 2255 options->tags_ecc_overridden = 1; | |
| 311 | 2256 } else if (!strcmp(cur_opt, "lazy-loading-off")){ |
| 2257 options->lazy_loading_enabled = 0; | |
| 2258 options->lazy_loading_overridden=1; | |
| 2259 } else if (!strcmp(cur_opt, "lazy-loading-on")){ | |
| 2260 options->lazy_loading_enabled = 1; | |
| 2261 options->lazy_loading_overridden = 1; | |
| 2262 } else if (!strcmp(cur_opt, "empty-lost-and-found-off")){ | |
| 2263 options->empty_lost_and_found = 0; | |
| 2264 options->empty_lost_and_found_overridden=1; | |
| 2265 } else if (!strcmp(cur_opt, "empty-lost-and-found-on")){ | |
| 2266 options->empty_lost_and_found = 1; | |
| 2267 options->empty_lost_and_found_overridden=1; | |
| 300 | 2268 } else if (!strcmp(cur_opt, "no-cache")) |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2269 options->no_cache = 1; |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2270 else if (!strcmp(cur_opt, "no-checkpoint-read")) |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2271 options->skip_checkpoint_read = 1; |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2272 else if (!strcmp(cur_opt, "no-checkpoint-write")) |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2273 options->skip_checkpoint_write = 1; |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2274 else if (!strcmp(cur_opt, "no-checkpoint")) { |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2275 options->skip_checkpoint_read = 1; |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2276 options->skip_checkpoint_write = 1; |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2277 } else { |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2278 printk(KERN_INFO "yaffs: Bad mount option \"%s\"\n", |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2279 cur_opt); |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2280 error = 1; |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2281 } |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2282 } |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2283 |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2284 return error; |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2285 } |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2286 |
| 76 | 2287 static struct super_block *yaffs_internal_read_super(int yaffsVersion, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2288 struct super_block *sb, |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2289 void *data, int silent) |
| 7 | 2290 { |
| 2291 int nBlocks; | |
| 76 | 2292 struct inode *inode = NULL; |
| 2293 struct dentry *root; | |
| 27 | 2294 yaffs_Device *dev = 0; |
| 76 | 2295 char devname_buf[BDEVNAME_SIZE + 1]; |
|
59
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
2296 struct mtd_info *mtd; |
| 7 | 2297 int err; |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2298 char *data_str = (char *)data; |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2299 struct yaffs_LinuxContext *context = NULL; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2300 yaffs_DeviceParam *param; |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2301 |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2302 yaffs_options options; |
| 76 | 2303 |
| 7 | 2304 sb->s_magic = YAFFS_MAGIC; |
| 2305 sb->s_op = &yaffs_super_ops; | |
|
204
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
2306 sb->s_flags |= MS_NOATIME; |
| 76 | 2307 |
| 398 | 2308 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,9)) |
| 2309 sb->s_export_op = &yaffs_export_ops; | |
| 2310 #endif | |
| 2311 | |
| 76 | 2312 if (!sb) |
| 2313 printk(KERN_INFO "yaffs: sb is NULL\n"); | |
| 2314 else if (!sb->s_dev) | |
| 2315 printk(KERN_INFO "yaffs: sb->s_dev is NULL\n"); | |
| 2316 else if (!yaffs_devname(sb, devname_buf)) | |
| 2317 printk(KERN_INFO "yaffs: devname is NULL\n"); | |
| 7 | 2318 else |
| 76 | 2319 printk(KERN_INFO "yaffs: dev is %d name is \"%s\"\n", |
| 2320 sb->s_dev, | |
| 2321 yaffs_devname(sb, devname_buf)); | |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2322 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2323 if (!data_str) |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2324 data_str = ""; |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2325 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2326 printk(KERN_INFO "yaffs: passed flags \"%s\"\n", data_str); |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2327 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2328 memset(&options, 0, sizeof(options)); |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2329 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2330 if (yaffs_parse_options(&options, data_str)) { |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2331 /* Option parsing failed */ |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2332 return NULL; |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2333 } |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2334 |
| 7 | 2335 |
| 2336 sb->s_blocksize = PAGE_CACHE_SIZE; | |
| 2337 sb->s_blocksize_bits = PAGE_CACHE_SHIFT; | |
| 76 | 2338 T(YAFFS_TRACE_OS, ("yaffs_read_super: Using yaffs%d\n", yaffsVersion)); |
| 2339 T(YAFFS_TRACE_OS, | |
| 2340 ("yaffs_read_super: block size %d\n", (int)(sb->s_blocksize))); | |
| 7 | 2341 |
| 2342 #ifdef CONFIG_YAFFS_DISABLE_WRITE_VERIFY | |
| 76 | 2343 T(YAFFS_TRACE_OS, |
| 2344 ("yaffs: Write verification disabled. All guarantees " | |
| 2345 "null and void\n")); | |
| 7 | 2346 #endif |
| 2347 | |
| 76 | 2348 T(YAFFS_TRACE_ALWAYS, ("yaffs: Attempting MTD mount on %u.%u, " |
| 2349 "\"%s\"\n", | |
| 2350 MAJOR(sb->s_dev), MINOR(sb->s_dev), | |
| 2351 yaffs_devname(sb, devname_buf))); | |
| 7 | 2352 |
| 76 | 2353 /* Check it's an mtd device..... */ |
| 273 | 2354 if (MAJOR(sb->s_dev) != MTD_BLOCK_MAJOR) |
| 76 | 2355 return NULL; /* This isn't an mtd device */ |
| 273 | 2356 |
| 76 | 2357 /* Get the device */ |
|
59
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
2358 mtd = get_mtd_device(NULL, MINOR(sb->s_dev)); |
| 76 | 2359 if (!mtd) { |
| 2360 T(YAFFS_TRACE_ALWAYS, | |
| 2361 ("yaffs: MTD device #%u doesn't appear to exist\n", | |
| 2362 MINOR(sb->s_dev))); | |
|
59
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
2363 return NULL; |
|
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
2364 } |
| 76 | 2365 /* Check it's NAND */ |
| 2366 if (mtd->type != MTD_NANDFLASH) { | |
| 2367 T(YAFFS_TRACE_ALWAYS, | |
| 2368 ("yaffs: MTD device is not NAND it's type %d\n", mtd->type)); | |
|
59
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
2369 return NULL; |
|
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
2370 } |
|
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
2371 |
| 76 | 2372 T(YAFFS_TRACE_OS, (" erase %p\n", mtd->erase)); |
| 2373 T(YAFFS_TRACE_OS, (" read %p\n", mtd->read)); | |
| 2374 T(YAFFS_TRACE_OS, (" write %p\n", mtd->write)); | |
| 2375 T(YAFFS_TRACE_OS, (" readoob %p\n", mtd->read_oob)); | |
| 2376 T(YAFFS_TRACE_OS, (" writeoob %p\n", mtd->write_oob)); | |
| 2377 T(YAFFS_TRACE_OS, (" block_isbad %p\n", mtd->block_isbad)); | |
| 2378 T(YAFFS_TRACE_OS, (" block_markbad %p\n", mtd->block_markbad)); | |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2379 T(YAFFS_TRACE_OS, (" %s %d\n", WRITE_SIZE_STR, WRITE_SIZE(mtd))); |
| 76 | 2380 T(YAFFS_TRACE_OS, (" oobsize %d\n", mtd->oobsize)); |
| 2381 T(YAFFS_TRACE_OS, (" erasesize %d\n", mtd->erasesize)); | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2382 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) |
| 266 | 2383 T(YAFFS_TRACE_OS, (" size %u\n", mtd->size)); |
| 2384 #else | |
| 2385 T(YAFFS_TRACE_OS, (" size %lld\n", mtd->size)); | |
| 2386 #endif | |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2387 |
| 109 | 2388 #ifdef CONFIG_YAFFS_AUTO_YAFFS2 |
| 108 | 2389 |
| 273 | 2390 if (yaffsVersion == 1 && WRITE_SIZE(mtd) >= 2048) { |
| 2391 T(YAFFS_TRACE_ALWAYS, ("yaffs: auto selecting yaffs2\n")); | |
| 2392 yaffsVersion = 2; | |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2393 } |
|
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2394 |
| 137 | 2395 /* Added NCB 26/5/2006 for completeness */ |
| 273 | 2396 if (yaffsVersion == 2 && !options.inband_tags && WRITE_SIZE(mtd) == 512) { |
| 2397 T(YAFFS_TRACE_ALWAYS, ("yaffs: auto selecting yaffs1\n")); | |
| 2398 yaffsVersion = 1; | |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2399 } |
| 137 | 2400 |
| 108 | 2401 #endif |
|
59
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
2402 |
| 76 | 2403 if (yaffsVersion == 2) { |
| 2404 /* Check for version 2 style functions */ | |
| 2405 if (!mtd->erase || | |
| 2406 !mtd->block_isbad || | |
| 2407 !mtd->block_markbad || | |
| 2408 !mtd->read || | |
| 2409 !mtd->write || | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2410 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17)) |
| 143 | 2411 !mtd->read_oob || !mtd->write_oob) { |
| 2412 #else | |
| 76 | 2413 !mtd->write_ecc || |
| 2414 !mtd->read_ecc || !mtd->read_oob || !mtd->write_oob) { | |
| 143 | 2415 #endif |
| 76 | 2416 T(YAFFS_TRACE_ALWAYS, |
| 2417 ("yaffs: MTD device does not support required " | |
| 2418 "functions\n"));; | |
| 7 | 2419 return NULL; |
| 2420 } | |
| 76 | 2421 |
|
204
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
2422 if ((WRITE_SIZE(mtd) < YAFFS_MIN_YAFFS2_CHUNK_SIZE || |
|
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
2423 mtd->oobsize < YAFFS_MIN_YAFFS2_SPARE_SIZE) && |
|
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
2424 !options.inband_tags) { |
| 76 | 2425 T(YAFFS_TRACE_ALWAYS, |
|
126
2e7fd6d40037
Fix a couple of mistakes in TRACE/Error messages. Update copyright date.
wookey <wookey>
parents:
124
diff
changeset
|
2426 ("yaffs: MTD device does not have the " |
| 76 | 2427 "right page sizes\n")); |
|
59
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
2428 return NULL; |
| 7 | 2429 } |
| 76 | 2430 } else { |
| 2431 /* Check for V1 style functions */ | |
| 2432 if (!mtd->erase || | |
| 2433 !mtd->read || | |
| 2434 !mtd->write || | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2435 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17)) |
| 143 | 2436 !mtd->read_oob || !mtd->write_oob) { |
| 2437 #else | |
| 76 | 2438 !mtd->write_ecc || |
| 2439 !mtd->read_ecc || !mtd->read_oob || !mtd->write_oob) { | |
| 143 | 2440 #endif |
| 76 | 2441 T(YAFFS_TRACE_ALWAYS, |
| 2442 ("yaffs: MTD device does not support required " | |
| 2443 "functions\n"));; | |
| 2444 return NULL; | |
| 2445 } | |
| 2446 | |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2447 if (WRITE_SIZE(mtd) < YAFFS_BYTES_PER_CHUNK || |
| 76 | 2448 mtd->oobsize != YAFFS_BYTES_PER_SPARE) { |
| 2449 T(YAFFS_TRACE_ALWAYS, | |
| 2450 ("yaffs: MTD device does not support have the " | |
| 2451 "right page sizes\n")); | |
|
59
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
2452 return NULL; |
|
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
2453 } |
|
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
2454 } |
| 7 | 2455 |
| 76 | 2456 /* OK, so if we got here, we have an MTD that's NAND and looks |
| 2457 * like it has the right capabilities | |
| 2458 * Set the yaffs_Device up for mtd | |
| 2459 */ | |
| 7 | 2460 |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2461 dev = kmalloc(sizeof(yaffs_Device), GFP_KERNEL); |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2462 context = kmalloc(sizeof(struct yaffs_LinuxContext),GFP_KERNEL); |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2463 |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2464 if(!dev || !context ){ |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2465 if(dev) |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2466 kfree(dev); |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2467 if(context) |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2468 kfree(context); |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2469 dev = NULL; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2470 context = NULL; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2471 } |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2472 |
| 76 | 2473 if (!dev) { |
| 2474 /* Deep shit could not allocate device structure */ | |
| 2475 T(YAFFS_TRACE_ALWAYS, | |
| 2476 ("yaffs_read_super: Failed trying to allocate " | |
| 2477 "yaffs_Device. \n")); | |
|
59
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
2478 return NULL; |
|
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
2479 } |
| 76 | 2480 memset(dev, 0, sizeof(yaffs_Device)); |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2481 param = &(dev->param); |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2482 |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2483 memset(context,0,sizeof(struct yaffs_LinuxContext)); |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2484 dev->context = context; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2485 YINIT_LIST_HEAD(&(context->contextList)); |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2486 context->dev = dev; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2487 context->superBlock = sb; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2488 |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2489 |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2490 |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2491 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0)) |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2492 sb->s_fs_info = dev; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2493 #else |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2494 sb->u.generic_sbp = dev; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2495 #endif |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2496 |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2497 yaffs_DeviceToContext(dev)->mtd = mtd; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2498 param->name = mtd->name; |
| 7 | 2499 |
| 76 | 2500 /* Set up the memory size parameters.... */ |
| 2501 | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2502 nBlocks = YCALCBLOCKS(mtd->size, (YAFFS_CHUNKS_PER_BLOCK * YAFFS_BYTES_PER_CHUNK)); |
| 266 | 2503 |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2504 param->startBlock = 0; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2505 param->endBlock = nBlocks - 1; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2506 param->nChunksPerBlock = YAFFS_CHUNKS_PER_BLOCK; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2507 param->totalBytesPerChunk = YAFFS_BYTES_PER_CHUNK; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2508 param->nReservedBlocks = 5; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2509 param->nShortOpCaches = (options.no_cache) ? 0 : 10; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2510 param->inbandTags = options.inband_tags; |
| 7 | 2511 |
|
303
a9dda7e5b822
Runtime disbale of lazy loading. Fix problem where resize was breading rename shadowing
charles <charles>
parents:
300
diff
changeset
|
2512 #ifdef CONFIG_YAFFS_DISABLE_LAZY_LOAD |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2513 param->disableLazyLoad = 1; |
|
303
a9dda7e5b822
Runtime disbale of lazy loading. Fix problem where resize was breading rename shadowing
charles <charles>
parents:
300
diff
changeset
|
2514 #endif |
| 311 | 2515 if(options.lazy_loading_overridden) |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2516 param->disableLazyLoad = !options.lazy_loading_enabled; |
|
303
a9dda7e5b822
Runtime disbale of lazy loading. Fix problem where resize was breading rename shadowing
charles <charles>
parents:
300
diff
changeset
|
2517 |
| 300 | 2518 #ifdef CONFIG_YAFFS_DISABLE_TAGS_ECC |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2519 param->noTagsECC = 1; |
| 300 | 2520 #endif |
|
372
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2521 |
|
374
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
2522 #ifdef CONFIG_YAFFS_DISABLE_BACKGROUND |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
2523 #else |
|
372
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2524 param->deferDirectoryUpdate = 1; |
|
374
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
2525 #endif |
|
372
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2526 |
| 300 | 2527 if(options.tags_ecc_overridden) |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2528 param->noTagsECC = !options.tags_ecc_on; |
| 300 | 2529 |
| 311 | 2530 #ifdef CONFIG_YAFFS_EMPTY_LOST_AND_FOUND |
| 361 | 2531 param->emptyLostAndFound = 1; |
| 311 | 2532 #endif |
| 365 | 2533 |
| 2534 #ifdef CONFIG_YAFFS_DISABLE_BLOCK_REFRESHING | |
| 2535 param->refreshPeriod = 0; | |
| 2536 #else | |
| 2537 param->refreshPeriod = 10000; | |
| 2538 #endif | |
| 2539 | |
| 311 | 2540 if(options.empty_lost_and_found_overridden) |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2541 param->emptyLostAndFound = options.empty_lost_and_found; |
| 311 | 2542 |
| 76 | 2543 /* ... and the functions. */ |
| 2544 if (yaffsVersion == 2) { | |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2545 param->writeChunkWithTagsToNAND = |
| 76 | 2546 nandmtd2_WriteChunkWithTagsToNAND; |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2547 param->readChunkWithTagsFromNAND = |
| 76 | 2548 nandmtd2_ReadChunkWithTagsFromNAND; |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2549 param->markNANDBlockBad = nandmtd2_MarkNANDBlockBad; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2550 param->queryNANDBlock = nandmtd2_QueryNANDBlock; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2551 yaffs_DeviceToContext(dev)->spareBuffer = YMALLOC(mtd->oobsize); |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2552 param->isYaffs2 = 1; |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2553 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17)) |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2554 param->totalBytesPerChunk = mtd->writesize; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2555 param->nChunksPerBlock = mtd->erasesize / mtd->writesize; |
| 143 | 2556 #else |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2557 param->totalBytesPerChunk = mtd->oobblock; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2558 param->nChunksPerBlock = mtd->erasesize / mtd->oobblock; |
| 143 | 2559 #endif |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2560 nBlocks = YCALCBLOCKS(mtd->size, mtd->erasesize); |
| 131 | 2561 |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2562 param->startBlock = 0; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2563 param->endBlock = nBlocks - 1; |
| 76 | 2564 } else { |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2565 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17)) |
| 179 | 2566 /* use the MTD interface in yaffs_mtdif1.c */ |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2567 param->writeChunkWithTagsToNAND = |
| 179 | 2568 nandmtd1_WriteChunkWithTagsToNAND; |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2569 param->readChunkWithTagsFromNAND = |
| 179 | 2570 nandmtd1_ReadChunkWithTagsFromNAND; |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2571 param->markNANDBlockBad = nandmtd1_MarkNANDBlockBad; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2572 param->queryNANDBlock = nandmtd1_QueryNANDBlock; |
| 179 | 2573 #else |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2574 param->writeChunkToNAND = nandmtd_WriteChunkToNAND; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2575 param->readChunkFromNAND = nandmtd_ReadChunkFromNAND; |
| 179 | 2576 #endif |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2577 param->isYaffs2 = 0; |
|
59
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
2578 } |
| 76 | 2579 /* ... and common functions */ |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2580 param->eraseBlockInNAND = nandmtd_EraseBlockInNAND; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2581 param->initialiseNAND = nandmtd_InitialiseNAND; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2582 |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2583 yaffs_DeviceToContext(dev)->putSuperFunc = yaffs_MTDPutSuper; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2584 |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2585 param->markSuperBlockDirty = yaffs_MarkSuperBlockDirty; |
| 388 | 2586 param->gcControl = yaffs_gc_control_callback; |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2587 |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2588 yaffs_DeviceToContext(dev)->superBlock= sb; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2589 |
| 76 | 2590 |
|
61
49f66fca0b09
newconfig: use YAFFS_DOES_ECC instead of USE_NANDECC
luc <luc>
parents:
59
diff
changeset
|
2591 #ifndef CONFIG_YAFFS_DOES_ECC |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2592 param->useNANDECC = 1; |
| 7 | 2593 #endif |
| 2594 | |
| 104 | 2595 #ifdef CONFIG_YAFFS_DISABLE_WIDE_TNODES |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2596 param->wideTnodesDisabled = 1; |
| 104 | 2597 #endif |
| 2598 | |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2599 param->skipCheckpointRead = options.skip_checkpoint_read; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2600 param->skipCheckpointWrite = options.skip_checkpoint_write; |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2601 |
| 27 | 2602 /* we assume this is protected by lock_kernel() in mount/umount */ |
|
384
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2603 down(&yaffs_context_lock); |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2604 ylist_add_tail(&(yaffs_DeviceToContext(dev)->contextList), &yaffs_context_list); |
|
384
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2605 up(&yaffs_context_lock); |
|
320
37b5b3fda7c0
Revert readdir locking fix that doesn't work properly
charles <charles>
parents:
319
diff
changeset
|
2606 |
| 321 | 2607 /* Directory search handling...*/ |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2608 YINIT_LIST_HEAD(&(yaffs_DeviceToContext(dev)->searchContexts)); |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2609 param->removeObjectCallback = yaffs_RemoveObjectCallback; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2610 |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2611 init_MUTEX(&(yaffs_DeviceToContext(dev)->grossLock)); |
|
320
37b5b3fda7c0
Revert readdir locking fix that doesn't work properly
charles <charles>
parents:
319
diff
changeset
|
2612 |
| 7 | 2613 yaffs_GrossLock(dev); |
| 76 | 2614 |
| 7 | 2615 err = yaffs_GutsInitialise(dev); |
| 2616 | |
| 76 | 2617 T(YAFFS_TRACE_OS, |
| 2618 ("yaffs_read_super: guts initialised %s\n", | |
| 2619 (err == YAFFS_OK) ? "OK" : "FAILED")); | |
|
372
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2620 |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2621 if(err == YAFFS_OK) |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2622 yaffs_BackgroundStart(dev); |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2623 |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2624 if(!context->bgThread) |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2625 param->deferDirectoryUpdate = 0; |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2626 |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2627 |
|
106
5b8f68c30468
Apply Reed's deadlocking fix (manually applied)
charles <charles>
parents:
104
diff
changeset
|
2628 /* Release lock before yaffs_get_inode() */ |
|
5b8f68c30468
Apply Reed's deadlocking fix (manually applied)
charles <charles>
parents:
104
diff
changeset
|
2629 yaffs_GrossUnlock(dev); |
| 7 | 2630 |
| 76 | 2631 /* Create root inode */ |
| 2632 if (err == YAFFS_OK) | |
| 2633 inode = yaffs_get_inode(sb, S_IFDIR | 0755, 0, | |
| 2634 yaffs_Root(dev)); | |
| 7 | 2635 |
| 2636 if (!inode) | |
| 2637 return NULL; | |
| 2638 | |
| 76 | 2639 inode->i_op = &yaffs_dir_inode_operations; |
| 2640 inode->i_fop = &yaffs_dir_operations; | |
| 2641 | |
| 2642 T(YAFFS_TRACE_OS, ("yaffs_read_super: got root inode\n")); | |
| 7 | 2643 |
| 2644 root = d_alloc_root(inode); | |
| 2645 | |
| 76 | 2646 T(YAFFS_TRACE_OS, ("yaffs_read_super: d_alloc_root done\n")); |
| 7 | 2647 |
| 2648 if (!root) { | |
| 2649 iput(inode); | |
| 2650 return NULL; | |
| 2651 } | |
| 2652 sb->s_root = root; | |
| 249 | 2653 sb->s_dirt = !dev->isCheckpointed; |
| 2654 T(YAFFS_TRACE_ALWAYS, | |
| 2655 ("yaffs_read_super: isCheckpointed %d\n", dev->isCheckpointed)); | |
| 7 | 2656 |
| 76 | 2657 T(YAFFS_TRACE_OS, ("yaffs_read_super: done\n")); |
| 7 | 2658 return sb; |
| 2659 } | |
| 2660 | |
|
32
e344a10a3a1e
Move the internals read_super() functions near the declaration of
luc <luc>
parents:
29
diff
changeset
|
2661 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2662 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0)) |
| 76 | 2663 static int yaffs_internal_read_super_mtd(struct super_block *sb, void *data, |
| 2664 int silent) | |
| 7 | 2665 { |
| 95 | 2666 return yaffs_internal_read_super(1, sb, data, silent) ? 0 : -EINVAL; |
| 7 | 2667 } |
| 2668 | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2669 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17)) |
| 143 | 2670 static int yaffs_read_super(struct file_system_type *fs, |
| 2671 int flags, const char *dev_name, | |
| 2672 void *data, struct vfsmount *mnt) | |
| 2673 { | |
| 2674 | |
| 2675 return get_sb_bdev(fs, flags, dev_name, data, | |
| 2676 yaffs_internal_read_super_mtd, mnt); | |
| 2677 } | |
| 2678 #else | |
| 76 | 2679 static struct super_block *yaffs_read_super(struct file_system_type *fs, |
| 2680 int flags, const char *dev_name, | |
| 2681 void *data) | |
| 7 | 2682 { |
| 2683 | |
| 76 | 2684 return get_sb_bdev(fs, flags, dev_name, data, |
| 2685 yaffs_internal_read_super_mtd); | |
| 7 | 2686 } |
| 143 | 2687 #endif |
| 7 | 2688 |
| 2689 static struct file_system_type yaffs_fs_type = { | |
| 76 | 2690 .owner = THIS_MODULE, |
| 2691 .name = "yaffs", | |
| 2692 .get_sb = yaffs_read_super, | |
| 2693 .kill_sb = kill_block_super, | |
| 2694 .fs_flags = FS_REQUIRES_DEV, | |
| 7 | 2695 }; |
| 2696 #else | |
| 76 | 2697 static struct super_block *yaffs_read_super(struct super_block *sb, void *data, |
| 2698 int silent) | |
| 7 | 2699 { |
| 76 | 2700 return yaffs_internal_read_super(1, sb, data, silent); |
| 7 | 2701 } |
| 2702 | |
| 76 | 2703 static DECLARE_FSTYPE(yaffs_fs_type, "yaffs", yaffs_read_super, |
| 2704 FS_REQUIRES_DEV); | |
| 7 | 2705 #endif |
| 2706 | |
| 2707 | |
| 49 | 2708 #ifdef CONFIG_YAFFS_YAFFS2 |
| 7 | 2709 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2710 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0)) |
| 76 | 2711 static int yaffs2_internal_read_super_mtd(struct super_block *sb, void *data, |
| 2712 int silent) | |
|
32
e344a10a3a1e
Move the internals read_super() functions near the declaration of
luc <luc>
parents:
29
diff
changeset
|
2713 { |
| 95 | 2714 return yaffs_internal_read_super(2, sb, data, silent) ? 0 : -EINVAL; |
|
32
e344a10a3a1e
Move the internals read_super() functions near the declaration of
luc <luc>
parents:
29
diff
changeset
|
2715 } |
|
e344a10a3a1e
Move the internals read_super() functions near the declaration of
luc <luc>
parents:
29
diff
changeset
|
2716 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2717 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17)) |
| 143 | 2718 static int yaffs2_read_super(struct file_system_type *fs, |
| 2719 int flags, const char *dev_name, void *data, | |
| 2720 struct vfsmount *mnt) | |
| 2721 { | |
| 2722 return get_sb_bdev(fs, flags, dev_name, data, | |
| 2723 yaffs2_internal_read_super_mtd, mnt); | |
| 2724 } | |
| 2725 #else | |
| 76 | 2726 static struct super_block *yaffs2_read_super(struct file_system_type *fs, |
| 2727 int flags, const char *dev_name, | |
| 2728 void *data) | |
| 7 | 2729 { |
| 2730 | |
| 76 | 2731 return get_sb_bdev(fs, flags, dev_name, data, |
| 2732 yaffs2_internal_read_super_mtd); | |
| 7 | 2733 } |
| 143 | 2734 #endif |
| 7 | 2735 |
| 2736 static struct file_system_type yaffs2_fs_type = { | |
| 76 | 2737 .owner = THIS_MODULE, |
| 2738 .name = "yaffs2", | |
| 2739 .get_sb = yaffs2_read_super, | |
| 2740 .kill_sb = kill_block_super, | |
| 2741 .fs_flags = FS_REQUIRES_DEV, | |
| 7 | 2742 }; |
| 2743 #else | |
| 76 | 2744 static struct super_block *yaffs2_read_super(struct super_block *sb, |
| 2745 void *data, int silent) | |
| 7 | 2746 { |
| 76 | 2747 return yaffs_internal_read_super(2, sb, data, silent); |
| 7 | 2748 } |
| 2749 | |
| 76 | 2750 static DECLARE_FSTYPE(yaffs2_fs_type, "yaffs2", yaffs2_read_super, |
| 2751 FS_REQUIRES_DEV); | |
| 7 | 2752 #endif |
| 2753 | |
| 76 | 2754 #endif /* CONFIG_YAFFS_YAFFS2 */ |
| 7 | 2755 |
| 2756 static struct proc_dir_entry *my_proc_entry; | |
|
385
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
2757 static struct proc_dir_entry *debug_proc_entry; |
| 7 | 2758 |
| 311 | 2759 static char *yaffs_dump_dev_part0(char *buf, yaffs_Device * dev) |
| 7 | 2760 { |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2761 buf += sprintf(buf, "startBlock......... %d\n", dev->param.startBlock); |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2762 buf += sprintf(buf, "endBlock........... %d\n", dev->param.endBlock); |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2763 buf += sprintf(buf, "totalBytesPerChunk. %d\n", dev->param.totalBytesPerChunk); |
| 365 | 2764 buf += sprintf(buf, "useNANDECC......... %d\n", dev->param.useNANDECC); |
| 2765 buf += sprintf(buf, "noTagsECC.......... %d\n", dev->param.noTagsECC); | |
| 2766 buf += sprintf(buf, "isYaffs2........... %d\n", dev->param.isYaffs2); | |
| 2767 buf += sprintf(buf, "inbandTags......... %d\n", dev->param.inbandTags); | |
| 2768 buf += sprintf(buf, "emptyLostAndFound.. %d\n", dev->param.emptyLostAndFound); | |
| 2769 buf += sprintf(buf, "disableLazyLoad.... %d\n", dev->param.disableLazyLoad); | |
| 2770 buf += sprintf(buf, "refreshPeriod...... %d\n", dev->param.refreshPeriod); | |
|
384
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2771 buf += sprintf(buf, "nShortOpCaches..... %d\n", dev->param.nShortOpCaches); |
|
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2772 buf += sprintf(buf, "nReservedBlocks.... %d\n", dev->param.nReservedBlocks); |
| 365 | 2773 |
| 2774 buf += sprintf(buf, "\n"); | |
| 2775 | |
| 2776 return buf; | |
| 2777 } | |
| 2778 | |
| 2779 | |
| 2780 static char *yaffs_dump_dev_part1(char *buf, yaffs_Device * dev) | |
| 2781 { | |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2782 buf += sprintf(buf, "nDataBytesPerChunk. %d\n", dev->nDataBytesPerChunk); |
| 76 | 2783 buf += sprintf(buf, "chunkGroupBits..... %d\n", dev->chunkGroupBits); |
| 2784 buf += sprintf(buf, "chunkGroupSize..... %d\n", dev->chunkGroupSize); | |
| 2785 buf += sprintf(buf, "nErasedBlocks...... %d\n", dev->nErasedBlocks); | |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2786 buf += sprintf(buf, "blocksInCheckpoint. %d\n", dev->blocksInCheckpoint); |
|
384
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2787 buf += sprintf(buf, "\n"); |
| 76 | 2788 buf += sprintf(buf, "nTnodesCreated..... %d\n", dev->nTnodesCreated); |
| 2789 buf += sprintf(buf, "nFreeTnodes........ %d\n", dev->nFreeTnodes); | |
| 2790 buf += sprintf(buf, "nObjectsCreated.... %d\n", dev->nObjectsCreated); | |
| 2791 buf += sprintf(buf, "nFreeObjects....... %d\n", dev->nFreeObjects); | |
| 2792 buf += sprintf(buf, "nFreeChunks........ %d\n", dev->nFreeChunks); | |
|
384
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2793 buf += sprintf(buf, "\n"); |
|
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2794 buf += sprintf(buf, "nPageWrites........ %u\n", dev->nPageWrites); |
|
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2795 buf += sprintf(buf, "nPageReads......... %u\n", dev->nPageReads); |
|
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2796 buf += sprintf(buf, "nBlockErasures..... %u\n", dev->nBlockErasures); |
|
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2797 buf += sprintf(buf, "nGCCopies.......... %u\n", dev->nGCCopies); |
|
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2798 buf += sprintf(buf, "garbageCollections. %u\n", dev->garbageCollections); |
|
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2799 buf += sprintf(buf, "passiveGCs......... %u\n", dev->passiveGarbageCollections); |
|
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2800 buf += sprintf(buf, "nRetriedWrites..... %u\n", dev->nRetriedWrites); |
|
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2801 buf += sprintf(buf, "nRetireBlocks...... %u\n", dev->nRetiredBlocks); |
|
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2802 buf += sprintf(buf, "eccFixed........... %u\n", dev->eccFixed); |
|
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2803 buf += sprintf(buf, "eccUnfixed......... %u\n", dev->eccUnfixed); |
|
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2804 buf += sprintf(buf, "tagsEccFixed....... %u\n", dev->tagsEccFixed); |
|
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2805 buf += sprintf(buf, "tagsEccUnfixed..... %u\n", dev->tagsEccUnfixed); |
|
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2806 buf += sprintf(buf, "cacheHits.......... %u\n", dev->cacheHits); |
|
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2807 buf += sprintf(buf, "nDeletedFiles...... %u\n", dev->nDeletedFiles); |
|
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2808 buf += sprintf(buf, "nUnlinkedFiles..... %u\n", dev->nUnlinkedFiles); |
|
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2809 buf += sprintf(buf, "refreshCount....... %u\n", dev->refreshCount); |
| 76 | 2810 buf += |
|
384
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2811 sprintf(buf, "nBackgroudDeletions %u\n", dev->nBackgroundDeletions); |
| 311 | 2812 |
| 2813 return buf; | |
| 2814 } | |
| 2815 | |
| 76 | 2816 static int yaffs_proc_read(char *page, |
| 2817 char **start, | |
| 2818 off_t offset, int count, int *eof, void *data) | |
| 7 | 2819 { |
|
210
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2820 struct ylist_head *item; |
| 27 | 2821 char *buf = page; |
| 2822 int step = offset; | |
| 2823 int n = 0; | |
| 7 | 2824 |
| 27 | 2825 /* Get proc_file_read() to step 'offset' by one on each sucessive call. |
| 2826 * We use 'offset' (*ppos) to indicate where we are in devList. | |
| 2827 * This also assumes the user has posted a read buffer large | |
| 2828 * enough to hold the complete output; but that's life in /proc. | |
| 2829 */ | |
| 7 | 2830 |
| 27 | 2831 *(int *)start = 1; |
| 2832 | |
| 2833 /* Print header first */ | |
| 311 | 2834 if (step == 0) |
| 76 | 2835 buf += sprintf(buf, "YAFFS built:" __DATE__ " " __TIME__ |
| 2836 "\n%s\n%s\n", yaffs_fs_c_version, | |
| 2837 yaffs_guts_c_version); | |
| 311 | 2838 else if (step == 1) |
| 2839 buf += sprintf(buf,"\n"); | |
| 2840 else { | |
| 2841 step-=2; | |
| 2842 | |
|
384
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2843 down(&yaffs_context_lock); |
| 311 | 2844 |
| 2845 /* Locate and print the Nth entry. Order N-squared but N is small. */ | |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2846 ylist_for_each(item, &yaffs_context_list) { |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2847 struct yaffs_LinuxContext *dc = ylist_entry(item, struct yaffs_LinuxContext, contextList); |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2848 yaffs_Device *dev = dc->dev; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2849 |
| 311 | 2850 if (n < (step & ~1)) { |
| 2851 n+=2; | |
| 2852 continue; | |
| 2853 } | |
| 2854 if((step & 1)==0){ | |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2855 buf += sprintf(buf, "\nDevice %d \"%s\"\n", n, dev->param.name); |
| 311 | 2856 buf = yaffs_dump_dev_part0(buf, dev); |
| 2857 } else | |
| 2858 buf = yaffs_dump_dev_part1(buf, dev); | |
| 2859 | |
| 2860 break; | |
| 2861 } | |
|
384
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2862 up(&yaffs_context_lock); |
| 27 | 2863 } |
| 7 | 2864 |
| 76 | 2865 return buf - page < count ? buf - page : count; |
| 7 | 2866 } |
| 2867 | |
|
385
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
2868 static int yaffs_debug_proc_read(char *page, |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
2869 char **start, |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
2870 off_t offset, int count, int *eof, void *data) |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
2871 { |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
2872 struct ylist_head *item; |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
2873 char *buf = page; |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
2874 int n = 0; |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
2875 |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
2876 down(&yaffs_context_lock); |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
2877 |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
2878 /* Locate and print the Nth entry. Order N-squared but N is small. */ |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
2879 ylist_for_each(item, &yaffs_context_list) { |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
2880 struct yaffs_LinuxContext *dc = ylist_entry(item, struct yaffs_LinuxContext, contextList); |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
2881 yaffs_Device *dev = dc->dev; |
| 387 | 2882 |
| 2883 int erasedChunks; | |
| 2884 int nObjects; | |
| 2885 int nTnodes; | |
| 2886 | |
| 2887 erasedChunks = dev->nErasedBlocks * dev->param.nChunksPerBlock; | |
| 2888 nObjects = dev->nObjectsCreated -dev->nFreeObjects; | |
| 2889 nTnodes = dev->nTnodesCreated - dev->nFreeTnodes; | |
|
385
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
2890 |
| 387 | 2891 |
| 2892 buf += sprintf(buf,"%d, %d, %d, %d, %d\n", | |
| 2893 n, dev->nFreeChunks, erasedChunks, | |
| 2894 nObjects, nTnodes); | |
|
385
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
2895 } |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
2896 up(&yaffs_context_lock); |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
2897 |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
2898 |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
2899 return buf - page < count ? buf - page : count; |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
2900 } |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
2901 |
|
115
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2902 /** |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2903 * Set the verbosity of the warnings and error messages. |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2904 * |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2905 * Note that the names can only be a..z or _ with the current code. |
|
115
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2906 */ |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2907 |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2908 static struct { |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2909 char *mask_name; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2910 unsigned mask_bitfield; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2911 } mask_flags[] = { |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2912 {"allocate", YAFFS_TRACE_ALLOCATE}, |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2913 {"always", YAFFS_TRACE_ALWAYS}, |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2914 {"bad_blocks", YAFFS_TRACE_BAD_BLOCKS}, |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2915 {"buffers", YAFFS_TRACE_BUFFERS}, |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2916 {"bug", YAFFS_TRACE_BUG}, |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2917 {"checkpt", YAFFS_TRACE_CHECKPOINT}, |
|
115
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2918 {"deletion", YAFFS_TRACE_DELETION}, |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2919 {"erase", YAFFS_TRACE_ERASE}, |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2920 {"error", YAFFS_TRACE_ERROR}, |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2921 {"gc_detail", YAFFS_TRACE_GC_DETAIL}, |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2922 {"gc", YAFFS_TRACE_GC}, |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2923 {"mtd", YAFFS_TRACE_MTD}, |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2924 {"nandaccess", YAFFS_TRACE_NANDACCESS}, |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2925 {"os", YAFFS_TRACE_OS}, |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2926 {"scan_debug", YAFFS_TRACE_SCAN_DEBUG}, |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2927 {"scan", YAFFS_TRACE_SCAN}, |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2928 {"tracing", YAFFS_TRACE_TRACING}, |
| 342 | 2929 {"sync", YAFFS_TRACE_SYNC}, |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2930 |
|
372
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2931 {"background", YAFFS_TRACE_BACKGROUND}, |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2932 |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2933 {"verify", YAFFS_TRACE_VERIFY}, |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2934 {"verify_nand", YAFFS_TRACE_VERIFY_NAND}, |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2935 {"verify_full", YAFFS_TRACE_VERIFY_FULL}, |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2936 {"verify_all", YAFFS_TRACE_VERIFY_ALL}, |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2937 |
|
115
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2938 {"write", YAFFS_TRACE_WRITE}, |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2939 {"all", 0xffffffff}, |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2940 {"none", 0}, |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2941 {NULL, 0}, |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2942 }; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2943 |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2944 #define MAX_MASK_NAME_LENGTH 40 |
| 311 | 2945 static int yaffs_proc_write_trace_options(struct file *file, const char *buf, |
|
115
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2946 unsigned long count, void *data) |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2947 { |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2948 unsigned rg = 0, mask_bitfield; |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2949 char *end; |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2950 char *mask_name; |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2951 const char *x; |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2952 char substring[MAX_MASK_NAME_LENGTH + 1]; |
|
115
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2953 int i; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2954 int done = 0; |
| 166 | 2955 int add, len = 0; |
|
115
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2956 int pos = 0; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2957 |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2958 rg = yaffs_traceMask; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2959 |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2960 while (!done && (pos < count)) { |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2961 done = 1; |
| 273 | 2962 while ((pos < count) && isspace(buf[pos])) |
|
115
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2963 pos++; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2964 |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2965 switch (buf[pos]) { |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2966 case '+': |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2967 case '-': |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2968 case '=': |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2969 add = buf[pos]; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2970 pos++; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2971 break; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2972 |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2973 default: |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2974 add = ' '; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2975 break; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2976 } |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2977 mask_name = NULL; |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2978 |
|
115
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2979 mask_bitfield = simple_strtoul(buf + pos, &end, 0); |
| 273 | 2980 |
|
115
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2981 if (end > buf + pos) { |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2982 mask_name = "numeral"; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2983 len = end - (buf + pos); |
|
188
62921764ba1b
Fix infinite loop when parsing numeric trace flags written to /proc/yaffs.
imcd <imcd>
parents:
179
diff
changeset
|
2984 pos += len; |
|
115
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2985 done = 0; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2986 } else { |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2987 for (x = buf + pos, i = 0; |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2988 (*x == '_' || (*x >= 'a' && *x <= 'z')) && |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2989 i < MAX_MASK_NAME_LENGTH; x++, i++, pos++) |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2990 substring[i] = *x; |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2991 substring[i] = '\0'; |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2992 |
|
115
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2993 for (i = 0; mask_flags[i].mask_name != NULL; i++) { |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2994 if (strcmp(substring, mask_flags[i].mask_name) == 0) { |
|
115
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2995 mask_name = mask_flags[i].mask_name; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2996 mask_bitfield = mask_flags[i].mask_bitfield; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2997 done = 0; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2998 break; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
2999 } |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3000 } |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3001 } |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3002 |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3003 if (mask_name != NULL) { |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3004 done = 0; |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
3005 switch (add) { |
|
115
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3006 case '-': |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3007 rg &= ~mask_bitfield; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3008 break; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3009 case '+': |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3010 rg |= mask_bitfield; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3011 break; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3012 case '=': |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3013 rg = mask_bitfield; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3014 break; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3015 default: |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3016 rg |= mask_bitfield; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3017 break; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3018 } |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3019 } |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3020 } |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3021 |
| 165 | 3022 yaffs_traceMask = rg | YAFFS_TRACE_ALWAYS; |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
3023 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
3024 printk(KERN_DEBUG "new trace = 0x%08X\n", yaffs_traceMask); |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
3025 |
|
115
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3026 if (rg & YAFFS_TRACE_ALWAYS) { |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3027 for (i = 0; mask_flags[i].mask_name != NULL; i++) { |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3028 char flag; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3029 flag = ((rg & mask_flags[i].mask_bitfield) == mask_flags[i].mask_bitfield) ? '+' : '-'; |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
3030 printk(KERN_DEBUG "%c%s\n", flag, mask_flags[i].mask_name); |
|
115
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3031 } |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3032 } |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3033 |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3034 return count; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3035 } |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3036 |
| 311 | 3037 |
| 3038 static int yaffs_proc_write(struct file *file, const char *buf, | |
| 3039 unsigned long count, void *data) | |
| 3040 { | |
| 3041 return yaffs_proc_write_trace_options(file, buf, count, data); | |
| 3042 } | |
| 3043 | |
| 76 | 3044 /* Stuff to handle installation of file systems */ |
| 3045 struct file_system_to_install { | |
| 3046 struct file_system_type *fst; | |
| 3047 int installed; | |
| 7 | 3048 }; |
| 3049 | |
| 76 | 3050 static struct file_system_to_install fs_to_install[] = { |
| 3051 {&yaffs_fs_type, 0}, | |
| 3052 {&yaffs2_fs_type, 0}, | |
| 3053 {NULL, 0} | |
| 7 | 3054 }; |
| 3055 | |
| 3056 static int __init init_yaffs_fs(void) | |
| 3057 { | |
| 3058 int error = 0; | |
| 76 | 3059 struct file_system_to_install *fsinst; |
| 7 | 3060 |
| 76 | 3061 T(YAFFS_TRACE_ALWAYS, |
| 3062 ("yaffs " __DATE__ " " __TIME__ " Installing. \n")); | |
| 7 | 3063 |
|
384
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
3064 init_MUTEX(&yaffs_context_lock); |
|
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
3065 |
|
385
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
3066 /* Install the proc_fs entries */ |
|
115
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3067 my_proc_entry = create_proc_entry("yaffs", |
| 76 | 3068 S_IRUGO | S_IFREG, |
|
212
0107f21a03fb
Fix compilation on Linux 2.6.26, fix compilation warnings
charles <charles>
parents:
210
diff
changeset
|
3069 YPROC_ROOT); |
|
115
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3070 |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3071 if (my_proc_entry) { |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3072 my_proc_entry->write_proc = yaffs_proc_write; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3073 my_proc_entry->read_proc = yaffs_proc_read; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3074 my_proc_entry->data = NULL; |
| 273 | 3075 } else |
| 76 | 3076 return -ENOMEM; |
| 3077 | |
|
385
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
3078 debug_proc_entry = create_proc_entry("yaffs_debug", |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
3079 S_IRUGO | S_IFREG, |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
3080 YPROC_ROOT); |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
3081 |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
3082 if (debug_proc_entry) { |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
3083 debug_proc_entry->write_proc = NULL; |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
3084 debug_proc_entry->read_proc = yaffs_debug_proc_read; |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
3085 debug_proc_entry->data = NULL; |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
3086 } else |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
3087 return -ENOMEM; |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
3088 |
| 76 | 3089 /* Now add the file system entries */ |
| 3090 | |
| 3091 fsinst = fs_to_install; | |
| 7 | 3092 |
| 76 | 3093 while (fsinst->fst && !error) { |
| 3094 error = register_filesystem(fsinst->fst); | |
| 273 | 3095 if (!error) |
| 76 | 3096 fsinst->installed = 1; |
| 3097 fsinst++; | |
| 3098 } | |
| 3099 | |
| 3100 /* Any errors? uninstall */ | |
| 3101 if (error) { | |
| 3102 fsinst = fs_to_install; | |
| 3103 | |
| 3104 while (fsinst->fst) { | |
| 3105 if (fsinst->installed) { | |
| 3106 unregister_filesystem(fsinst->fst); | |
| 3107 fsinst->installed = 0; | |
| 3108 } | |
| 3109 fsinst++; | |
| 3110 } | |
| 3111 } | |
| 3112 | |
| 3113 return error; | |
| 7 | 3114 } |
| 3115 | |
| 3116 static void __exit exit_yaffs_fs(void) | |
| 3117 { | |
| 3118 | |
| 76 | 3119 struct file_system_to_install *fsinst; |
| 3120 | |
| 3121 T(YAFFS_TRACE_ALWAYS, ("yaffs " __DATE__ " " __TIME__ | |
| 3122 " removing. \n")); | |
| 3123 | |
|
212
0107f21a03fb
Fix compilation on Linux 2.6.26, fix compilation warnings
charles <charles>
parents:
210
diff
changeset
|
3124 remove_proc_entry("yaffs", YPROC_ROOT); |
| 7 | 3125 |
| 76 | 3126 fsinst = fs_to_install; |
| 3127 | |
| 3128 while (fsinst->fst) { | |
| 3129 if (fsinst->installed) { | |
| 3130 unregister_filesystem(fsinst->fst); | |
| 3131 fsinst->installed = 0; | |
| 3132 } | |
| 3133 fsinst++; | |
| 3134 } | |
| 7 | 3135 } |
| 3136 | |
| 3137 module_init(init_yaffs_fs) | |
| 3138 module_exit(exit_yaffs_fs) | |
| 3139 | |
| 3140 MODULE_DESCRIPTION("YAFFS2 - a NAND specific flash file system"); | |
|
126
2e7fd6d40037
Fix a couple of mistakes in TRACE/Error messages. Update copyright date.
wookey <wookey>
parents:
124
diff
changeset
|
3141 MODULE_AUTHOR("Charles Manning, Aleph One Ltd., 2002-2006"); |
| 7 | 3142 MODULE_LICENSE("GPL"); |
