Mercurial > yaffs-ecoscentric-gpl
annotate packages/fs/yaffs/current/src/yaffs_fs.c @ 425:dea4d7d250ad ecos
Move sources into packages/fs/yaffs/current/src/
| author | Ross Younger <wry@ecoscentric.com> |
|---|---|
| date | Fri, 14 May 2010 16:03:09 +0100 |
| parents | yaffs_fs.c@ff48885b11fb |
| children |
| rev | line source |
|---|---|
| 7 | 1 /* |
| 168 | 2 * YAFFS: Yet Another Flash File System. A NAND-flash specific file system. |
| 7 | 3 * |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
4 * Copyright (C) 2002-2010 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 | |
| 166 | 34 #include <linux/version.h> |
|
374
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
35 |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
36 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)) |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
37 #define YAFFS_COMPILE_BACKGROUND |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
38 #endif |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
39 |
| 401 | 40 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)) |
| 41 #define YAFFS_COMPILE_EXPORTFS | |
| 42 #endif | |
| 43 | |
| 44 | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
45 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)) |
| 7 | 46 #include <linux/config.h> |
| 166 | 47 #endif |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
48 |
| 7 | 49 #include <linux/kernel.h> |
| 50 #include <linux/module.h> | |
| 51 #include <linux/slab.h> | |
| 52 #include <linux/init.h> | |
| 53 #include <linux/fs.h> | |
| 54 #include <linux/proc_fs.h> | |
| 27 | 55 #include <linux/smp_lock.h> |
| 7 | 56 #include <linux/pagemap.h> |
| 57 #include <linux/mtd/mtd.h> | |
| 58 #include <linux/interrupt.h> | |
| 59 #include <linux/string.h> | |
|
115
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
60 #include <linux/ctype.h> |
| 401 | 61 |
| 62 #ifdef YAFFS_COMPILE_EXPORTFS | |
| 398 | 63 #include <linux/exportfs.h> |
| 401 | 64 #endif |
| 7 | 65 |
|
374
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
66 #ifdef YAFFS_COMPILE_BACKGROUND |
|
372
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
67 #include <linux/kthread.h> |
|
374
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
68 #include <linux/delay.h> |
| 402 | 69 #include <linux/freezer.h> |
|
374
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
70 #endif |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
71 |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
72 #include <asm/div64.h> |
| 332 | 73 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
74 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0)) |
| 7 | 75 |
| 273 | 76 #include <linux/statfs.h> |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
77 |
| 7 | 78 #define UnlockPage(p) unlock_page(p) |
| 79 #define Page_Uptodate(page) test_bit(PG_uptodate, &(page)->flags) | |
| 76 | 80 |
| 81 /* FIXME: use sb->s_id instead ? */ | |
| 82 #define yaffs_devname(sb, buf) bdevname(sb->s_bdev, buf) | |
| 7 | 83 |
| 84 #else | |
| 85 | |
| 86 #include <linux/locks.h> | |
|
37
843d9d0add74
Fix devname which was faked by always using "(unavailable)".
luc <luc>
parents:
36
diff
changeset
|
87 #define BDEVNAME_SIZE 0 |
|
843d9d0add74
Fix devname which was faked by always using "(unavailable)".
luc <luc>
parents:
36
diff
changeset
|
88 #define yaffs_devname(sb, buf) kdevname(sb->s_dev) |
| 7 | 89 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
90 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)) |
| 137 | 91 /* added NCB 26/5/2006 for 2.4.25-vrs2-tcl1 kernel */ |
| 92 #define __user | |
| 93 #endif | |
| 94 | |
| 7 | 95 #endif |
| 96 | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
97 #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
|
98 #define YPROC_ROOT (&proc_root) |
|
212
0107f21a03fb
Fix compilation on Linux 2.6.26, fix compilation warnings
charles <charles>
parents:
210
diff
changeset
|
99 #else |
|
0107f21a03fb
Fix compilation on Linux 2.6.26, fix compilation warnings
charles <charles>
parents:
210
diff
changeset
|
100 #define YPROC_ROOT NULL |
|
0107f21a03fb
Fix compilation on Linux 2.6.26, fix compilation warnings
charles <charles>
parents:
210
diff
changeset
|
101 #endif |
|
0107f21a03fb
Fix compilation on Linux 2.6.26, fix compilation warnings
charles <charles>
parents:
210
diff
changeset
|
102 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
103 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17)) |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
104 #define WRITE_SIZE_STR "writesize" |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
105 #define WRITE_SIZE(mtd) ((mtd)->writesize) |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
106 #else |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
107 #define WRITE_SIZE_STR "oobblock" |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
108 #define WRITE_SIZE(mtd) ((mtd)->oobblock) |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
109 #endif |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
110 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
111 #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
|
112 #define YAFFS_USE_WRITE_BEGIN_END 1 |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
113 #else |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
114 #define YAFFS_USE_WRITE_BEGIN_END 0 |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
115 #endif |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
116 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
117 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 28)) |
| 266 | 118 static uint32_t YCALCBLOCKS(uint64_t partition_size, uint32_t block_size) |
| 119 { | |
| 120 uint64_t result = partition_size; | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
121 do_div(result, block_size); |
| 266 | 122 return (uint32_t)result; |
| 123 } | |
| 124 #else | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
125 #define YCALCBLOCKS(s, b) ((s)/(b)) |
| 266 | 126 #endif |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
127 |
| 273 | 128 #include <linux/uaccess.h> |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
129 #include <linux/mtd/mtd.h> |
| 7 | 130 |
| 131 #include "yportenv.h" | |
| 342 | 132 #include "yaffs_trace.h" |
| 7 | 133 #include "yaffs_guts.h" |
| 134 | |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
135 #include "yaffs_linux.h" |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
136 |
| 7 | 137 #include "yaffs_mtdif.h" |
| 179 | 138 #include "yaffs_mtdif1.h" |
| 7 | 139 #include "yaffs_mtdif2.h" |
| 140 | |
| 311 | 141 unsigned int yaffs_traceMask = YAFFS_TRACE_BAD_BLOCKS | YAFFS_TRACE_ALWAYS; |
| 179 | 142 unsigned int yaffs_wr_attempts = YAFFS_WR_ATTEMPTS; |
| 249 | 143 unsigned int yaffs_auto_checkpoint = 1; |
| 388 | 144 unsigned int yaffs_gc_control = 1; |
| 179 | 145 |
| 146 /* Module Parameters */ | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
147 #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
|
148 module_param(yaffs_traceMask, uint, 0644); |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
149 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
|
150 module_param(yaffs_auto_checkpoint, uint, 0644); |
| 388 | 151 module_param(yaffs_gc_control, uint, 0644); |
| 179 | 152 #else |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
153 MODULE_PARM(yaffs_traceMask, "i"); |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
154 MODULE_PARM(yaffs_wr_attempts, "i"); |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
155 MODULE_PARM(yaffs_auto_checkpoint, "i"); |
| 388 | 156 MODULE_PARM(yaffs_gc_control, "i"); |
| 179 | 157 #endif |
| 158 | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
159 #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
|
160 /* use iget and read_inode */ |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
161 #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
|
162 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
|
163 |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
164 #else |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
165 /* Call local equivalent */ |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
166 #define YAFFS_USE_OWN_IGET |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
167 #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
|
168 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
169 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
|
170 #endif |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
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 { |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
409 T(YAFFS_TRACE_LOCK, (TSTR("yaffs locking %p\n"), current)); |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
410 down(&(yaffs_DeviceToContext(dev)->grossLock)); |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
411 T(YAFFS_TRACE_LOCK, (TSTR("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 { |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
416 T(YAFFS_TRACE_LOCK, (TSTR("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 | |
| 401 | 420 #ifdef YAFFS_COMPILE_EXPORTFS |
| 398 | 421 |
| 422 static struct inode * | |
| 423 yaffs2_nfs_get_inode(struct super_block *sb, uint64_t ino, uint32_t generation) | |
| 424 { | |
| 401 | 425 return Y_IGET(sb, ino); |
| 398 | 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); | |
| 401 | 456 inode = Y_IGET(sb, parent_ino); |
| 398 | 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 /* Just declare a zero structure as a NULL value implies | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
474 * using the default functions of exportfs. |
| 398 | 475 */ |
| 476 | |
| 477 static struct export_operations yaffs_export_ops = | |
| 478 { | |
| 479 .fh_to_dentry = yaffs2_fh_to_dentry, | |
| 480 .fh_to_parent = yaffs2_fh_to_parent, | |
| 481 .get_parent = yaffs2_get_parent, | |
| 482 } ; | |
| 483 | |
| 484 #endif | |
| 485 | |
| 321 | 486 /*-----------------------------------------------------------------*/ |
| 487 /* Directory search context allows us to unlock access to yaffs during | |
| 488 * filldir without causing problems with the directory being modified. | |
| 489 * This is similar to the tried and tested mechanism used in yaffs direct. | |
| 490 * | |
| 491 * A search context iterates along a doubly linked list of siblings in the | |
| 492 * directory. If the iterating object is deleted then this would corrupt | |
| 493 * the list iteration, likely causing a crash. The search context avoids | |
| 494 * this by using the removeObjectCallback to move the search context to the | |
| 495 * next object before the object is deleted. | |
| 496 * | |
| 497 * Many readdirs (and thus seach conexts) may be alive simulateously so | |
| 498 * each yaffs_Device has a list of these. | |
| 499 * | |
| 500 * A seach context lives for the duration of a readdir. | |
| 501 * | |
| 502 * All these functions must be called while yaffs is locked. | |
| 503 */ | |
| 504 | |
| 505 struct yaffs_SearchContext { | |
| 506 yaffs_Device *dev; | |
| 507 yaffs_Object *dirObj; | |
| 508 yaffs_Object *nextReturn; | |
| 509 struct ylist_head others; | |
| 510 }; | |
| 511 | |
| 512 /* | |
| 513 * yaffs_NewSearch() creates a new search context, initialises it and | |
| 514 * adds it to the device's search context list. | |
| 515 * | |
| 516 * Called at start of readdir. | |
| 517 */ | |
| 518 static struct yaffs_SearchContext * yaffs_NewSearch(yaffs_Object *dir) | |
| 519 { | |
| 520 yaffs_Device *dev = dir->myDev; | |
| 521 struct yaffs_SearchContext *sc = YMALLOC(sizeof(struct yaffs_SearchContext)); | |
| 522 if(sc){ | |
| 523 sc->dirObj = dir; | |
| 524 sc->dev = dev; | |
| 525 if( ylist_empty(&sc->dirObj->variant.directoryVariant.children)) | |
| 526 sc->nextReturn = NULL; | |
| 527 else | |
| 528 sc->nextReturn = ylist_entry( | |
| 529 dir->variant.directoryVariant.children.next, | |
| 530 yaffs_Object,siblings); | |
| 531 YINIT_LIST_HEAD(&sc->others); | |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
532 ylist_add(&sc->others,&(yaffs_DeviceToContext(dev)->searchContexts)); |
| 321 | 533 } |
| 534 return sc; | |
| 535 } | |
| 536 | |
| 537 /* | |
| 538 * yaffs_EndSearch() disposes of a search context and cleans up. | |
| 539 */ | |
| 540 static void yaffs_EndSearch(struct yaffs_SearchContext * sc) | |
| 541 { | |
| 542 if(sc){ | |
| 543 ylist_del(&sc->others); | |
| 544 YFREE(sc); | |
| 545 } | |
| 546 } | |
| 547 | |
| 548 /* | |
| 549 * yaffs_SearchAdvance() moves a search context to the next object. | |
| 550 * Called when the search iterates or when an object removal causes | |
| 551 * the search context to be moved to the next object. | |
| 552 */ | |
| 553 static void yaffs_SearchAdvance(struct yaffs_SearchContext *sc) | |
| 554 { | |
| 555 if(!sc) | |
| 556 return; | |
| 557 | |
| 558 if( sc->nextReturn == NULL || | |
| 559 ylist_empty(&sc->dirObj->variant.directoryVariant.children)) | |
| 560 sc->nextReturn = NULL; | |
| 561 else { | |
| 562 struct ylist_head *next = sc->nextReturn->siblings.next; | |
| 563 | |
| 564 if( next == &sc->dirObj->variant.directoryVariant.children) | |
| 565 sc->nextReturn = NULL; /* end of list */ | |
| 566 else | |
| 567 sc->nextReturn = ylist_entry(next,yaffs_Object,siblings); | |
| 568 } | |
| 569 } | |
| 570 | |
| 571 /* | |
| 572 * yaffs_RemoveObjectCallback() is called when an object is unlinked. | |
| 573 * We check open search contexts and advance any which are currently | |
| 574 * on the object being iterated. | |
| 575 */ | |
| 576 static void yaffs_RemoveObjectCallback(yaffs_Object *obj) | |
| 577 { | |
| 578 | |
| 579 struct ylist_head *i; | |
| 580 struct yaffs_SearchContext *sc; | |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
581 struct ylist_head *search_contexts = &(yaffs_DeviceToContext(obj->myDev)->searchContexts); |
| 321 | 582 |
| 583 | |
| 584 /* Iterate through the directory search contexts. | |
| 585 * If any are currently on the object being removed, then advance | |
| 586 * the search context to the next object to prevent a hanging pointer. | |
| 587 */ | |
| 588 ylist_for_each(i, search_contexts) { | |
| 589 if (i) { | |
| 590 sc = ylist_entry(i, struct yaffs_SearchContext,others); | |
| 591 if(sc->nextReturn == obj) | |
| 592 yaffs_SearchAdvance(sc); | |
| 593 } | |
| 594 } | |
| 595 | |
| 596 } | |
| 597 | |
| 598 | |
| 599 /*-----------------------------------------------------------------*/ | |
| 600 | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
601 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
|
602 int buflen) |
| 7 | 603 { |
| 604 unsigned char *alias; | |
| 605 int ret; | |
| 606 | |
| 607 yaffs_Device *dev = yaffs_DentryToObject(dentry)->myDev; | |
|
320
37b5b3fda7c0
Revert readdir locking fix that doesn't work properly
charles <charles>
parents:
319
diff
changeset
|
608 |
| 76 | 609 yaffs_GrossLock(dev); |
| 7 | 610 |
| 611 alias = yaffs_GetSymlinkAlias(yaffs_DentryToObject(dentry)); | |
| 76 | 612 |
| 7 | 613 yaffs_GrossUnlock(dev); |
| 76 | 614 |
| 615 if (!alias) | |
| 7 | 616 return -ENOMEM; |
| 617 | |
| 618 ret = vfs_readlink(dentry, buffer, buflen, alias); | |
| 619 kfree(alias); | |
| 620 return ret; | |
| 621 } | |
| 622 | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
623 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 13)) |
| 99 | 624 static void *yaffs_follow_link(struct dentry *dentry, struct nameidata *nd) |
| 625 #else | |
| 7 | 626 static int yaffs_follow_link(struct dentry *dentry, struct nameidata *nd) |
| 99 | 627 #endif |
| 7 | 628 { |
| 629 unsigned char *alias; | |
| 630 int ret; | |
| 631 yaffs_Device *dev = yaffs_DentryToObject(dentry)->myDev; | |
| 632 | |
| 633 yaffs_GrossLock(dev); | |
| 634 | |
| 635 alias = yaffs_GetSymlinkAlias(yaffs_DentryToObject(dentry)); | |
| 76 | 636 |
| 7 | 637 yaffs_GrossUnlock(dev); |
| 76 | 638 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
639 if (!alias) { |
| 99 | 640 ret = -ENOMEM; |
| 641 goto out; | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
642 } |
| 7 | 643 |
| 76 | 644 ret = vfs_follow_link(nd, alias); |
| 7 | 645 kfree(alias); |
| 99 | 646 out: |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
647 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 13)) |
| 273 | 648 return ERR_PTR(ret); |
| 99 | 649 #else |
| 7 | 650 return ret; |
| 99 | 651 #endif |
| 7 | 652 } |
| 653 | |
| 76 | 654 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
|
655 yaffs_Object *obj); |
| 7 | 656 |
| 657 /* | |
| 658 * Lookup is used to find objects in the fs | |
| 659 */ | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
660 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0)) |
| 7 | 661 |
| 76 | 662 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
|
663 struct nameidata *n) |
| 7 | 664 #else |
| 76 | 665 static struct dentry *yaffs_lookup(struct inode *dir, struct dentry *dentry) |
| 7 | 666 #endif |
| 667 { | |
| 668 yaffs_Object *obj; | |
| 76 | 669 struct inode *inode = NULL; /* NCB 2.5/2.6 needs NULL here */ |
| 670 | |
| 7 | 671 yaffs_Device *dev = yaffs_InodeToObject(dir)->myDev; |
| 672 | |
| 398 | 673 if(current != yaffs_DeviceToContext(dev)->readdirProcess) |
| 674 yaffs_GrossLock(dev); | |
| 7 | 675 |
| 76 | 676 T(YAFFS_TRACE_OS, |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
677 (TSTR("yaffs_lookup for %d:%s\n"), |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
678 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
|
679 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
680 obj = yaffs_FindObjectByName(yaffs_InodeToObject(dir), |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
681 dentry->d_name.name); |
| 76 | 682 |
| 683 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
|
684 |
|
106
5b8f68c30468
Apply Reed's deadlocking fix (manually applied)
charles <charles>
parents:
104
diff
changeset
|
685 /* Can't hold gross lock when calling yaffs_get_inode() */ |
| 398 | 686 if(current != yaffs_DeviceToContext(dev)->readdirProcess) |
| 687 yaffs_GrossUnlock(dev); | |
| 7 | 688 |
| 76 | 689 if (obj) { |
| 690 T(YAFFS_TRACE_OS, | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
691 (TSTR("yaffs_lookup found %d\n"), obj->objectId)); |
| 76 | 692 |
| 693 inode = yaffs_get_inode(dir->i_sb, obj->yst_mode, 0, obj); | |
| 694 | |
| 695 if (inode) { | |
| 696 T(YAFFS_TRACE_OS, | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
697 (TSTR("yaffs_loookup dentry \n"))); |
| 76 | 698 /* #if 0 asserted by NCB for 2.5/6 compatability - falls through to |
| 699 * d_add even if NULL inode */ | |
| 7 | 700 #if 0 |
| 76 | 701 /*dget(dentry); // try to solve directory bug */ |
| 702 d_add(dentry, inode); | |
| 703 | |
| 704 /* return dentry; */ | |
| 7 | 705 return NULL; |
| 706 #endif | |
| 707 } | |
| 708 | |
| 76 | 709 } else { |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
710 T(YAFFS_TRACE_OS,(TSTR("yaffs_lookup not found\n"))); |
| 76 | 711 |
| 7 | 712 } |
| 713 | |
| 76 | 714 /* added NCB for 2.5/6 compatability - forces add even if inode is |
| 715 * NULL which creates dentry hash */ | |
| 716 d_add(dentry, inode); | |
| 717 | |
| 7 | 718 return NULL; |
| 719 } | |
| 720 | |
|
212
0107f21a03fb
Fix compilation on Linux 2.6.26, fix compilation warnings
charles <charles>
parents:
210
diff
changeset
|
721 |
|
0107f21a03fb
Fix compilation on Linux 2.6.26, fix compilation warnings
charles <charles>
parents:
210
diff
changeset
|
722 #ifdef YAFFS_HAS_PUT_INODE |
|
0107f21a03fb
Fix compilation on Linux 2.6.26, fix compilation warnings
charles <charles>
parents:
210
diff
changeset
|
723 |
| 76 | 724 /* For now put inode is just for debugging |
| 725 * Put inode is called when the inode **structure** is put. | |
| 726 */ | |
| 7 | 727 static void yaffs_put_inode(struct inode *inode) |
| 728 { | |
| 76 | 729 T(YAFFS_TRACE_OS, |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
730 (TSTR("yaffs_put_inode: ino %d, count %d\n"), (int)inode->i_ino, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
731 atomic_read(&inode->i_count))); |
| 76 | 732 |
| 7 | 733 } |
|
212
0107f21a03fb
Fix compilation on Linux 2.6.26, fix compilation warnings
charles <charles>
parents:
210
diff
changeset
|
734 #endif |
| 7 | 735 |
| 76 | 736 /* clear is called to tell the fs to release any per-inode data it holds */ |
| 7 | 737 static void yaffs_clear_inode(struct inode *inode) |
| 738 { | |
| 739 yaffs_Object *obj; | |
| 740 yaffs_Device *dev; | |
| 76 | 741 |
| 7 | 742 obj = yaffs_InodeToObject(inode); |
| 743 | |
| 76 | 744 T(YAFFS_TRACE_OS, |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
745 (TSTR("yaffs_clear_inode: ino %d, count %d %s\n"), (int)inode->i_ino, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
746 atomic_read(&inode->i_count), |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
747 obj ? "object exists" : "null object")); |
| 76 | 748 |
| 749 if (obj) { | |
| 7 | 750 dev = obj->myDev; |
| 751 yaffs_GrossLock(dev); | |
| 76 | 752 |
| 753 /* Clear the association between the inode and | |
| 754 * the yaffs_Object. | |
| 755 */ | |
| 7 | 756 obj->myInode = NULL; |
| 166 | 757 yaffs_InodeToObjectLV(inode) = NULL; |
| 76 | 758 |
| 759 /* If the object freeing was deferred, then the real | |
| 760 * free happens now. | |
| 761 * This should fix the inode inconsistency problem. | |
| 762 */ | |
| 763 | |
| 7 | 764 yaffs_HandleDeferedFree(obj); |
| 76 | 765 |
| 7 | 766 yaffs_GrossUnlock(dev); |
| 767 } | |
| 76 | 768 |
| 7 | 769 } |
| 770 | |
| 76 | 771 /* delete is called when the link count is zero and the inode |
| 772 * is put (ie. nobody wants to know about it anymore, time to | |
| 773 * delete the file). | |
| 774 * NB Must call clear_inode() | |
| 775 */ | |
| 7 | 776 static void yaffs_delete_inode(struct inode *inode) |
| 777 { | |
| 778 yaffs_Object *obj = yaffs_InodeToObject(inode); | |
| 779 yaffs_Device *dev; | |
| 780 | |
| 76 | 781 T(YAFFS_TRACE_OS, |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
782 (TSTR("yaffs_delete_inode: ino %d, count %d %s\n"), (int)inode->i_ino, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
783 atomic_read(&inode->i_count), |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
784 obj ? "object exists" : "null object")); |
| 76 | 785 |
| 786 if (obj) { | |
| 787 dev = obj->myDev; | |
| 7 | 788 yaffs_GrossLock(dev); |
|
268
f13c5ef026ec
Change inode deletion to prevent issue raised by YBUG
charles <charles>
parents:
267
diff
changeset
|
789 yaffs_DeleteObject(obj); |
| 7 | 790 yaffs_GrossUnlock(dev); |
| 791 } | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
792 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 13)) |
| 273 | 793 truncate_inode_pages(&inode->i_data, 0); |
| 99 | 794 #endif |
| 7 | 795 clear_inode(inode); |
| 796 } | |
| 797 | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
798 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17)) |
| 143 | 799 static int yaffs_file_flush(struct file *file, fl_owner_t id) |
| 800 #else | |
| 76 | 801 static int yaffs_file_flush(struct file *file) |
| 143 | 802 #endif |
| 7 | 803 { |
| 804 yaffs_Object *obj = yaffs_DentryToObject(file->f_dentry); | |
| 76 | 805 |
| 7 | 806 yaffs_Device *dev = obj->myDev; |
| 76 | 807 |
| 808 T(YAFFS_TRACE_OS, | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
809 (TSTR("yaffs_file_flush object %d (%s)\n"), obj->objectId, |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
810 obj->dirty ? "dirty" : "clean")); |
| 7 | 811 |
| 812 yaffs_GrossLock(dev); | |
| 76 | 813 |
| 332 | 814 yaffs_FlushFile(obj, 1, 0); |
| 7 | 815 |
| 816 yaffs_GrossUnlock(dev); | |
| 817 | |
| 76 | 818 return 0; |
| 7 | 819 } |
| 820 | |
| 76 | 821 static int yaffs_readpage_nolock(struct file *f, struct page *pg) |
| 822 { | |
| 823 /* Lifted from jffs2 */ | |
| 7 | 824 |
| 825 yaffs_Object *obj; | |
| 826 unsigned char *pg_buf; | |
| 827 int ret; | |
| 828 | |
| 829 yaffs_Device *dev; | |
| 830 | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
831 T(YAFFS_TRACE_OS, |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
832 (TSTR("yaffs_readpage_nolock at %08x, size %08x\n"), |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
833 (unsigned)(pg->index << PAGE_CACHE_SHIFT), |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
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 | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
872 T(YAFFS_TRACE_OS, (TSTR("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 | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
887 T(YAFFS_TRACE_OS, (TSTR("yaffs_readpage\n"))); |
| 332 | 888 ret=yaffs_readpage_unlock(f, pg); |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
889 T(YAFFS_TRACE_OS, (TSTR("yaffs_readpage done\n"))); |
| 332 | 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, | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
926 (TSTR("yaffs_writepage at %08x, inode size = %08x!!!\n"), |
| 332 | 927 (unsigned)(page->index << PAGE_CACHE_SHIFT), |
| 928 (unsigned)inode->i_size)); | |
| 929 T(YAFFS_TRACE_OS, | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
930 (TSTR(" -> don't care!!\n"))); |
| 332 | 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, |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
951 (TSTR("yaffs_writepage at %08x, size %08x\n"), |
|
271
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, |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
954 (TSTR("writepag0: obj = %05x, ino = %05x\n"), |
|
271
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, |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
961 (TSTR("writepag1: obj = %05x, ino = %05x\n"), |
|
271
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 } |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
999 T(YAFFS_TRACE_OS, |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1000 (TSTR("start yaffs_write_begin index %d(%x) uptodate %d\n"), |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1001 (int)index,(int)index,Page_Uptodate(pg) ? 1 : 0)); |
| 332 | 1002 |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1003 /* Get fs space */ |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1004 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
|
1005 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1006 if (!space_held) { |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1007 ret = -ENOSPC; |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1008 goto out; |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1009 } |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1010 |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1011 /* Update page if required */ |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1012 |
| 332 | 1013 if (!Page_Uptodate(pg)) |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1014 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
|
1015 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1016 if (ret) |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1017 goto out; |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1018 |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1019 /* Happy path return */ |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1020 T(YAFFS_TRACE_OS, (TSTR("end yaffs_write_begin - ok\n"))); |
|
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 return 0; |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1023 |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1024 out: |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1025 T(YAFFS_TRACE_OS, |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1026 (TSTR("end yaffs_write_begin fail returning %d\n"), ret)); |
| 273 | 1027 if (space_held) |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1028 yaffs_release_space(filp); |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1029 if (pg) { |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1030 unlock_page(pg); |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1031 page_cache_release(pg); |
|
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 return ret; |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1034 } |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1035 |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1036 #else |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1037 |
| 76 | 1038 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
|
1039 unsigned offset, unsigned to) |
| 7 | 1040 { |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1041 T(YAFFS_TRACE_OS, (TSTR("yaffs_prepair_write\n"))); |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1042 |
| 332 | 1043 if (!Page_Uptodate(pg)) |
| 76 | 1044 return yaffs_readpage_nolock(f, pg); |
| 7 | 1045 return 0; |
| 1046 } | |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1047 #endif |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1048 |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1049 #if (YAFFS_USE_WRITE_BEGIN_END > 0) |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1050 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
|
1051 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
|
1052 struct page *pg, void *fsdadata) |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1053 { |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1054 int ret = 0; |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1055 void *addr, *kva; |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1056 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
|
1057 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1058 kva = kmap(pg); |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1059 addr = kva + offset_into_page; |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1060 |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1061 T(YAFFS_TRACE_OS, |
|
407
36a72b45da7c
yaffs: Clean up 64-bit compilation
Charles Manning <cdhmanning@gmail.com>
parents:
404
diff
changeset
|
1062 ("yaffs_write_end addr %p pos %x nBytes %d\n", |
|
36a72b45da7c
yaffs: Clean up 64-bit compilation
Charles Manning <cdhmanning@gmail.com>
parents:
404
diff
changeset
|
1063 addr,(unsigned)pos, copied)); |
|
253
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 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
|
1066 |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1067 if (ret != copied) { |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1068 T(YAFFS_TRACE_OS, |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1069 (TSTR("yaffs_write_end not same size ret %d copied %d\n"), |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1070 ret, copied)); |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1071 SetPageError(pg); |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1072 } else { |
| 332 | 1073 /* Nothing */ |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1074 } |
|
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 kunmap(pg); |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1077 |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1078 yaffs_release_space(filp); |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1079 unlock_page(pg); |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1080 page_cache_release(pg); |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1081 return ret; |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1082 } |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1083 #else |
| 7 | 1084 |
| 76 | 1085 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
|
1086 unsigned to) |
| 7 | 1087 { |
| 218 | 1088 void *addr, *kva; |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1089 |
| 76 | 1090 loff_t pos = (((loff_t) pg->index) << PAGE_CACHE_SHIFT) + offset; |
| 7 | 1091 int nBytes = to - offset; |
| 1092 int nWritten; | |
| 76 | 1093 |
| 7 | 1094 unsigned spos = pos; |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1095 unsigned saddr; |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1096 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1097 kva = kmap(pg); |
| 218 | 1098 addr = kva + offset; |
| 7 | 1099 |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1100 saddr = (unsigned) addr; |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1101 |
| 76 | 1102 T(YAFFS_TRACE_OS, |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1103 (TSTR("yaffs_commit_write addr %x pos %x nBytes %d\n"), |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1104 saddr, spos, nBytes)); |
| 76 | 1105 |
| 1106 nWritten = yaffs_file_write(f, addr, nBytes, &pos); | |
| 1107 | |
| 1108 if (nWritten != nBytes) { | |
| 1109 T(YAFFS_TRACE_OS, | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1110 (TSTR("yaffs_commit_write not same size nWritten %d nBytes %d\n"), |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1111 nWritten, nBytes)); |
| 7 | 1112 SetPageError(pg); |
| 76 | 1113 } else { |
| 332 | 1114 /* Nothing */ |
| 7 | 1115 } |
| 1116 | |
| 218 | 1117 kunmap(pg); |
| 1118 | |
| 76 | 1119 T(YAFFS_TRACE_OS, |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1120 (TSTR("yaffs_commit_write returning %d\n"), |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1121 nWritten == nBytes ? 0 : nWritten)); |
| 76 | 1122 |
|
113
325f5d3a757c
Handle partial writes more gracefully: return partial byte counts, return
tpoynor <tpoynor>
parents:
112
diff
changeset
|
1123 return nWritten == nBytes ? 0 : nWritten; |
| 7 | 1124 } |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1125 #endif |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1126 |
| 7 | 1127 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1128 static void yaffs_FillInodeFromObject(struct inode *inode, yaffs_Object *obj) |
| 7 | 1129 { |
| 76 | 1130 if (inode && obj) { |
| 139 | 1131 |
| 1132 | |
| 1133 /* 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
|
1134 __u32 mode = obj->yst_mode; |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1135 switch (obj->variantType) { |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1136 case YAFFS_OBJECT_TYPE_FILE: |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1137 if (!S_ISREG(mode)) { |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1138 obj->yst_mode &= ~S_IFMT; |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1139 obj->yst_mode |= S_IFREG; |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1140 } |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1141 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1142 break; |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1143 case YAFFS_OBJECT_TYPE_SYMLINK: |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1144 if (!S_ISLNK(mode)) { |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1145 obj->yst_mode &= ~S_IFMT; |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1146 obj->yst_mode |= S_IFLNK; |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1147 } |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1148 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1149 break; |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1150 case YAFFS_OBJECT_TYPE_DIRECTORY: |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1151 if (!S_ISDIR(mode)) { |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1152 obj->yst_mode &= ~S_IFMT; |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1153 obj->yst_mode |= S_IFDIR; |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1154 } |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1155 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1156 break; |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1157 case YAFFS_OBJECT_TYPE_UNKNOWN: |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1158 case YAFFS_OBJECT_TYPE_HARDLINK: |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1159 case YAFFS_OBJECT_TYPE_SPECIAL: |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1160 default: |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1161 /* TODO? */ |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1162 break; |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1163 } |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1164 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1165 inode->i_flags |= S_NOATIME; |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1166 |
| 7 | 1167 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
|
1168 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
|
1169 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
|
1170 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
|
1171 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)) |
| 7 | 1172 inode->i_blksize = inode->i_sb->s_blocksize; |
| 166 | 1173 #endif |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1174 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0)) |
| 7 | 1175 |
|
22
0b57027b96fe
Some improvements to garbage collection and st_xxx to yst_xxx changes
charles <charles>
parents:
19
diff
changeset
|
1176 inode->i_rdev = old_decode_dev(obj->yst_rdev); |
| 76 | 1177 inode->i_atime.tv_sec = (time_t) (obj->yst_atime); |
| 7 | 1178 inode->i_atime.tv_nsec = 0; |
| 76 | 1179 inode->i_mtime.tv_sec = (time_t) obj->yst_mtime; |
| 1180 inode->i_mtime.tv_nsec = 0; | |
| 1181 inode->i_ctime.tv_sec = (time_t) obj->yst_ctime; | |
| 7 | 1182 inode->i_ctime.tv_nsec = 0; |
| 1183 #else | |
|
22
0b57027b96fe
Some improvements to garbage collection and st_xxx to yst_xxx changes
charles <charles>
parents:
19
diff
changeset
|
1184 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
|
1185 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
|
1186 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
|
1187 inode->i_ctime = obj->yst_ctime; |
| 7 | 1188 #endif |
| 1189 inode->i_size = yaffs_GetObjectFileLength(obj); | |
| 1190 inode->i_blocks = (inode->i_size + 511) >> 9; | |
| 1191 | |
| 1192 inode->i_nlink = yaffs_GetObjectLinkCount(obj); | |
| 76 | 1193 |
| 1194 T(YAFFS_TRACE_OS, | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1195 (TSTR("yaffs_FillInode mode %x uid %d gid %d size %d count %d\n"), |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1196 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
|
1197 (int)inode->i_size, atomic_read(&inode->i_count))); |
| 76 | 1198 |
| 1199 switch (obj->yst_mode & S_IFMT) { | |
| 1200 default: /* fifo, device or socket */ | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1201 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0)) |
| 76 | 1202 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
|
1203 old_decode_dev(obj->yst_rdev)); |
| 12 | 1204 #else |
| 76 | 1205 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
|
1206 (dev_t) (obj->yst_rdev)); |
| 76 | 1207 #endif |
| 1208 break; | |
| 1209 case S_IFREG: /* file */ | |
| 1210 inode->i_op = &yaffs_file_inode_operations; | |
| 1211 inode->i_fop = &yaffs_file_operations; | |
| 1212 inode->i_mapping->a_ops = | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1213 &yaffs_file_address_operations; |
| 76 | 1214 break; |
| 1215 case S_IFDIR: /* directory */ | |
| 1216 inode->i_op = &yaffs_dir_inode_operations; | |
| 1217 inode->i_fop = &yaffs_dir_operations; | |
| 1218 break; | |
| 1219 case S_IFLNK: /* symlink */ | |
| 1220 inode->i_op = &yaffs_symlink_inode_operations; | |
| 1221 break; | |
| 7 | 1222 } |
| 76 | 1223 |
| 166 | 1224 yaffs_InodeToObjectLV(inode) = obj; |
| 1225 | |
| 7 | 1226 obj->myInode = inode; |
| 76 | 1227 |
| 1228 } else { | |
| 1229 T(YAFFS_TRACE_OS, | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1230 (TSTR("yaffs_FileInode invalid parameters\n"))); |
| 7 | 1231 } |
| 1232 | |
| 1233 } | |
| 1234 | |
| 76 | 1235 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
|
1236 yaffs_Object *obj) |
| 7 | 1237 { |
| 76 | 1238 struct inode *inode; |
| 1239 | |
| 1240 if (!sb) { | |
| 1241 T(YAFFS_TRACE_OS, | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1242 (TSTR("yaffs_get_inode for NULL super_block!!\n"))); |
| 76 | 1243 return NULL; |
| 1244 | |
| 7 | 1245 } |
| 76 | 1246 |
| 1247 if (!obj) { | |
| 1248 T(YAFFS_TRACE_OS, | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1249 (TSTR("yaffs_get_inode for NULL object!!\n"))); |
| 76 | 1250 return NULL; |
| 1251 | |
| 7 | 1252 } |
| 76 | 1253 |
| 1254 T(YAFFS_TRACE_OS, | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1255 (TSTR("yaffs_get_inode for object %d\n"), obj->objectId)); |
| 7 | 1256 |
|
210
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
1257 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
|
1258 if (IS_ERR(inode)) |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1259 return NULL; |
| 7 | 1260 |
| 76 | 1261 /* NB Side effect: iget calls back to yaffs_read_inode(). */ |
| 1262 /* iget also increments the inode's i_count */ | |
|
106
5b8f68c30468
Apply Reed's deadlocking fix (manually applied)
charles <charles>
parents:
104
diff
changeset
|
1263 /* NB You can't be holding grossLock or deadlock will happen! */ |
| 76 | 1264 |
| 7 | 1265 return inode; |
| 1266 } | |
| 1267 | |
| 76 | 1268 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
|
1269 loff_t *pos) |
| 7 | 1270 { |
| 1271 yaffs_Object *obj; | |
| 76 | 1272 int nWritten, ipos; |
| 7 | 1273 struct inode *inode; |
| 1274 yaffs_Device *dev; | |
| 76 | 1275 |
| 1276 obj = yaffs_DentryToObject(f->f_dentry); | |
| 1277 | |
| 7 | 1278 dev = obj->myDev; |
| 76 | 1279 |
| 7 | 1280 yaffs_GrossLock(dev); |
| 1281 | |
| 1282 inode = f->f_dentry->d_inode; | |
| 1283 | |
| 273 | 1284 if (!S_ISBLK(inode->i_mode) && f->f_flags & O_APPEND) |
| 7 | 1285 ipos = inode->i_size; |
| 273 | 1286 else |
| 7 | 1287 ipos = *pos; |
| 273 | 1288 |
| 1289 if (!obj) | |
| 76 | 1290 T(YAFFS_TRACE_OS, |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1291 (TSTR("yaffs_file_write: hey obj is null!\n"))); |
| 273 | 1292 else |
| 76 | 1293 T(YAFFS_TRACE_OS, |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1294 (TSTR("yaffs_file_write about to write writing %u(%x) bytes" |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1295 "to object %d at %d(%x)\n"), |
| 332 | 1296 (unsigned) n, (unsigned) n, obj->objectId, ipos,ipos)); |
| 7 | 1297 |
| 76 | 1298 nWritten = yaffs_WriteDataToFile(obj, buf, ipos, n, 0); |
| 7 | 1299 |
| 76 | 1300 T(YAFFS_TRACE_OS, |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1301 (TSTR("yaffs_file_write: %d(%x) bytes written\n"), |
| 332 | 1302 (unsigned )n,(unsigned)n)); |
| 273 | 1303 |
| 76 | 1304 if (nWritten > 0) { |
| 7 | 1305 ipos += nWritten; |
| 1306 *pos = ipos; | |
| 76 | 1307 if (ipos > inode->i_size) { |
| 7 | 1308 inode->i_size = ipos; |
| 76 | 1309 inode->i_blocks = (ipos + 511) >> 9; |
| 1310 | |
| 1311 T(YAFFS_TRACE_OS, | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1312 (TSTR("yaffs_file_write size updated to %d bytes, " |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1313 "%d blocks\n"), |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1314 ipos, (int)(inode->i_blocks))); |
| 7 | 1315 } |
| 76 | 1316 |
| 7 | 1317 } |
| 1318 yaffs_GrossUnlock(dev); | |
|
278
ba8a7124dc1f
Fix -ENOSPC to work properly with zero length writes
charles <charles>
parents:
277
diff
changeset
|
1319 return (nWritten == 0) && (n > 0) ? -ENOSPC : nWritten; |
| 7 | 1320 } |
| 1321 | |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1322 /* 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
|
1323 /* 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
|
1324 /* 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
|
1325 |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1326 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
|
1327 { |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1328 yaffs_Object *obj; |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1329 yaffs_Device *dev; |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1330 |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1331 int nFreeChunks; |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1332 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1333 |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1334 obj = yaffs_DentryToObject(f->f_dentry); |
|
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 dev = obj->myDev; |
|
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 yaffs_GrossLock(dev); |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1339 |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1340 nFreeChunks = yaffs_GetNumberOfFreeChunks(dev); |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1341 |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1342 yaffs_GrossUnlock(dev); |
|
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 return (nFreeChunks > 20) ? 1 : 0; |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1345 } |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1346 |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1347 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
|
1348 { |
|
320
37b5b3fda7c0
Revert readdir locking fix that doesn't work properly
charles <charles>
parents:
319
diff
changeset
|
1349 yaffs_Object *obj; |
|
37b5b3fda7c0
Revert readdir locking fix that doesn't work properly
charles <charles>
parents:
319
diff
changeset
|
1350 yaffs_Device *dev; |
|
37b5b3fda7c0
Revert readdir locking fix that doesn't work properly
charles <charles>
parents:
319
diff
changeset
|
1351 |
|
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 obj = yaffs_DentryToObject(f->f_dentry); |
|
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 dev = obj->myDev; |
|
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 yaffs_GrossLock(dev); |
|
37b5b3fda7c0
Revert readdir locking fix that doesn't work properly
charles <charles>
parents:
319
diff
changeset
|
1358 |
|
37b5b3fda7c0
Revert readdir locking fix that doesn't work properly
charles <charles>
parents:
319
diff
changeset
|
1359 |
|
37b5b3fda7c0
Revert readdir locking fix that doesn't work properly
charles <charles>
parents:
319
diff
changeset
|
1360 yaffs_GrossUnlock(dev); |
|
253
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1361 } |
|
6dd9ed6bed42
Change Linux glue code to work with 2.6.28
charles <charles>
parents:
249
diff
changeset
|
1362 |
| 398 | 1363 |
| 1364 static loff_t yaffs_dir_llseek(struct file *file, loff_t offset, int origin) | |
| 1365 { | |
| 1366 long long retval; | |
| 1367 | |
| 1368 lock_kernel(); | |
| 1369 | |
| 1370 switch (origin){ | |
| 1371 case 2: | |
| 1372 offset += i_size_read(file->f_path.dentry->d_inode); | |
| 1373 break; | |
| 1374 case 1: | |
| 1375 offset += file->f_pos; | |
| 1376 } | |
| 1377 retval = -EINVAL; | |
| 1378 | |
| 1379 if (offset >= 0){ | |
| 1380 if (offset != file->f_pos) | |
| 1381 file->f_pos = offset; | |
| 1382 | |
| 1383 retval = offset; | |
| 1384 } | |
| 1385 unlock_kernel(); | |
| 1386 return retval; | |
| 1387 } | |
| 1388 | |
| 1389 | |
| 7 | 1390 static int yaffs_readdir(struct file *f, void *dirent, filldir_t filldir) |
| 1391 { | |
| 1392 yaffs_Object *obj; | |
| 1393 yaffs_Device *dev; | |
| 321 | 1394 struct yaffs_SearchContext *sc; |
| 7 | 1395 struct inode *inode = f->f_dentry->d_inode; |
| 1396 unsigned long offset, curoffs; | |
| 1397 yaffs_Object *l; | |
| 321 | 1398 int retVal = 0; |
| 76 | 1399 |
| 1400 char name[YAFFS_MAX_NAME_LENGTH + 1]; | |
| 1401 | |
| 1402 obj = yaffs_DentryToObject(f->f_dentry); | |
| 7 | 1403 dev = obj->myDev; |
| 76 | 1404 |
| 7 | 1405 yaffs_GrossLock(dev); |
| 76 | 1406 |
| 398 | 1407 yaffs_DeviceToContext(dev)->readdirProcess = current; |
| 1408 | |
| 7 | 1409 offset = f->f_pos; |
| 76 | 1410 |
| 321 | 1411 sc = yaffs_NewSearch(obj); |
| 1412 if(!sc){ | |
| 1413 retVal = -ENOMEM; | |
| 1414 goto unlock_out; | |
| 1415 } | |
| 1416 | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1417 T(YAFFS_TRACE_OS, (TSTR("yaffs_readdir: starting at %d\n"), (int)offset)); |
| 76 | 1418 |
| 1419 if (offset == 0) { | |
| 1420 T(YAFFS_TRACE_OS, | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1421 (TSTR("yaffs_readdir: entry . ino %d \n"), |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1422 (int)inode->i_ino)); |
| 321 | 1423 yaffs_GrossUnlock(dev); |
| 273 | 1424 if (filldir(dirent, ".", 1, offset, inode->i_ino, DT_DIR) < 0) |
| 7 | 1425 goto out; |
| 321 | 1426 yaffs_GrossLock(dev); |
| 7 | 1427 offset++; |
| 1428 f->f_pos++; | |
| 1429 } | |
| 76 | 1430 if (offset == 1) { |
| 1431 T(YAFFS_TRACE_OS, | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1432 (TSTR("yaffs_readdir: entry .. ino %d \n"), |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1433 (int)f->f_dentry->d_parent->d_inode->i_ino)); |
| 321 | 1434 yaffs_GrossUnlock(dev); |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1435 if (filldir(dirent, "..", 2, offset, |
| 273 | 1436 f->f_dentry->d_parent->d_inode->i_ino, DT_DIR) < 0) |
| 7 | 1437 goto out; |
| 321 | 1438 yaffs_GrossLock(dev); |
| 7 | 1439 offset++; |
| 1440 f->f_pos++; | |
| 1441 } | |
| 76 | 1442 |
| 7 | 1443 curoffs = 1; |
| 76 | 1444 |
| 117 | 1445 /* If the directory has changed since the open or last call to |
| 1446 readdir, rewind to after the 2 canned entries. */ | |
| 1447 if (f->f_version != inode->i_version) { | |
| 1448 offset = 2; | |
| 1449 f->f_pos = offset; | |
| 1450 f->f_version = inode->i_version; | |
| 1451 } | |
| 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, | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1463 (TSTR("yaffs_readdir: %s inode %d\n"), |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1464 name, yaffs_GetObjectInode(l))); |
| 76 | 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, | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1530 (TSTR("yaffs_mknod: parent object %d type %d\n"), |
|
271
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, | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1534 (TSTR("yaffs_mknod: could not get parent object\n"))); |
| 7 | 1535 return -EPERM; |
| 1536 } | |
| 76 | 1537 |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1538 T(YAFFS_TRACE_OS, (TSTR("yaffs_mknod: making oject for %s, " |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1539 "mode %x dev %x\n"), |
|
271
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...) */ | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1549 T(YAFFS_TRACE_OS, (TSTR("yaffs_mknod: making special\n"))); |
|
271
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 */ | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1559 T(YAFFS_TRACE_OS, (TSTR("yaffs_mknod: making file\n"))); |
|
271
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, | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1565 (TSTR("yaffs_mknod: making directory\n"))); |
|
271
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 */ | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1570 T(YAFFS_TRACE_OS, (TSTR("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, |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1583 (TSTR("yaffs_mknod created object %d count = %d\n"), |
|
271
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, | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1589 (TSTR("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; | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1599 T(YAFFS_TRACE_OS, (TSTR("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 { | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1611 T(YAFFS_TRACE_OS,(TSTR("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, | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1623 (TSTR("yaffs_unlink %d:%s\n"), |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1624 (int)(dir->i_ino), |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1625 dentry->d_name.name)); |
| 398 | 1626 obj = yaffs_InodeToObject(dir); |
| 1627 dev = obj->myDev; | |
| 76 | 1628 |
| 7 | 1629 yaffs_GrossLock(dev); |
| 76 | 1630 |
| 398 | 1631 retVal = yaffs_Unlink(obj, dentry->d_name.name); |
| 76 | 1632 |
| 1633 if (retVal == YAFFS_OK) { | |
| 7 | 1634 dentry->d_inode->i_nlink--; |
| 117 | 1635 dir->i_version++; |
|
320
37b5b3fda7c0
Revert readdir locking fix that doesn't work properly
charles <charles>
parents:
319
diff
changeset
|
1636 yaffs_GrossUnlock(dev); |
| 7 | 1637 mark_inode_dirty(dentry->d_inode); |
| 280 | 1638 update_dir_time(dir); |
| 7 | 1639 return 0; |
| 1640 } | |
|
320
37b5b3fda7c0
Revert readdir locking fix that doesn't work properly
charles <charles>
parents:
319
diff
changeset
|
1641 yaffs_GrossUnlock(dev); |
| 117 | 1642 return -ENOTEMPTY; |
| 7 | 1643 } |
| 1644 | |
| 1645 /* | |
| 1646 * Create a link... | |
| 1647 */ | |
| 76 | 1648 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
|
1649 struct dentry *dentry) |
| 7 | 1650 { |
| 1651 struct inode *inode = old_dentry->d_inode; | |
| 1652 yaffs_Object *obj = NULL; | |
| 76 | 1653 yaffs_Object *link = NULL; |
| 7 | 1654 yaffs_Device *dev; |
| 76 | 1655 |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1656 T(YAFFS_TRACE_OS, (TSTR("yaffs_link\n"))); |
| 76 | 1657 |
| 7 | 1658 obj = yaffs_InodeToObject(inode); |
| 1659 dev = obj->myDev; | |
| 76 | 1660 |
| 7 | 1661 yaffs_GrossLock(dev); |
| 1662 | |
| 273 | 1663 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
|
1664 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
|
1665 obj); |
| 7 | 1666 |
| 76 | 1667 if (link) { |
| 1668 old_dentry->d_inode->i_nlink = yaffs_GetObjectLinkCount(obj); | |
| 7 | 1669 d_instantiate(dentry, old_dentry->d_inode); |
| 1670 atomic_inc(&old_dentry->d_inode->i_count); | |
| 76 | 1671 T(YAFFS_TRACE_OS, |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1672 (TSTR("yaffs_link link count %d i_count %d\n"), |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1673 old_dentry->d_inode->i_nlink, |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1674 atomic_read(&old_dentry->d_inode->i_count))); |
| 7 | 1675 } |
| 76 | 1676 |
| 7 | 1677 yaffs_GrossUnlock(dev); |
| 1678 | |
| 280 | 1679 if (link){ |
| 1680 update_dir_time(dir); | |
| 7 | 1681 return 0; |
| 280 | 1682 } |
| 76 | 1683 |
| 1684 return -EPERM; | |
| 7 | 1685 } |
| 1686 | |
| 76 | 1687 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
|
1688 const char *symname) |
| 7 | 1689 { |
| 1690 yaffs_Object *obj; | |
| 1691 yaffs_Device *dev; | |
| 266 | 1692 uid_t uid = YCRED(current)->fsuid; |
| 1693 gid_t gid = (dir->i_mode & S_ISGID) ? dir->i_gid : YCRED(current)->fsgid; | |
| 76 | 1694 |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1695 T(YAFFS_TRACE_OS, (TSTR("yaffs_symlink\n"))); |
| 76 | 1696 |
| 7 | 1697 dev = yaffs_InodeToObject(dir)->myDev; |
| 1698 yaffs_GrossLock(dev); | |
| 76 | 1699 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
|
1700 S_IFLNK | S_IRWXUGO, uid, gid, symname); |
| 7 | 1701 yaffs_GrossUnlock(dev); |
| 1702 | |
| 76 | 1703 if (obj) { |
| 1704 struct inode *inode; | |
| 1705 | |
|
22
0b57027b96fe
Some improvements to garbage collection and st_xxx to yst_xxx changes
charles <charles>
parents:
19
diff
changeset
|
1706 inode = yaffs_get_inode(dir->i_sb, obj->yst_mode, 0, obj); |
| 7 | 1707 d_instantiate(dentry, inode); |
| 280 | 1708 update_dir_time(dir); |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1709 T(YAFFS_TRACE_OS, (TSTR("symlink created OK\n"))); |
| 7 | 1710 return 0; |
| 76 | 1711 } else { |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1712 T(YAFFS_TRACE_OS, (TSTR("symlink not created\n"))); |
| 7 | 1713 } |
| 76 | 1714 |
| 7 | 1715 return -ENOMEM; |
| 1716 } | |
| 1717 | |
| 76 | 1718 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
|
1719 int datasync) |
| 7 | 1720 { |
| 1721 | |
| 1722 yaffs_Object *obj; | |
| 1723 yaffs_Device *dev; | |
| 76 | 1724 |
| 7 | 1725 obj = yaffs_DentryToObject(dentry); |
| 1726 | |
| 1727 dev = obj->myDev; | |
| 76 | 1728 |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1729 T(YAFFS_TRACE_OS | YAFFS_TRACE_SYNC, |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1730 (TSTR("yaffs_sync_object\n"))); |
| 7 | 1731 yaffs_GrossLock(dev); |
| 291 | 1732 yaffs_FlushFile(obj, 1, datasync); |
| 7 | 1733 yaffs_GrossUnlock(dev); |
| 1734 return 0; | |
| 1735 } | |
| 1736 | |
| 1737 /* | |
| 1738 * The VFS layer already does all the dentry stuff for rename. | |
| 1739 * | |
| 1740 * NB: POSIX says you can rename an object over an old object of the same name | |
| 1741 */ | |
| 76 | 1742 static int yaffs_rename(struct inode *old_dir, struct dentry *old_dentry, |
| 1743 struct inode *new_dir, struct dentry *new_dentry) | |
| 7 | 1744 { |
| 1745 yaffs_Device *dev; | |
| 1746 int retVal = YAFFS_FAIL; | |
| 1747 yaffs_Object *target; | |
| 76 | 1748 |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1749 T(YAFFS_TRACE_OS, (TSTR("yaffs_rename\n"))); |
| 7 | 1750 dev = yaffs_InodeToObject(old_dir)->myDev; |
| 1751 | |
| 1752 yaffs_GrossLock(dev); | |
| 76 | 1753 |
| 1754 /* 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
|
1755 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
|
1756 new_dentry->d_name.name); |
|
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 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1759 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1760 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
|
1761 !ylist_empty(&target->variant.directoryVariant.children)) { |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1762 |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1763 T(YAFFS_TRACE_OS, (TSTR("target is non-empty dir\n"))); |
| 83 | 1764 |
| 7 | 1765 retVal = YAFFS_FAIL; |
| 76 | 1766 } else { |
| 1767 /* Now does unlinking internally using shadowing mechanism */ | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1768 T(YAFFS_TRACE_OS, (TSTR("calling yaffs_RenameObject\n"))); |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1769 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1770 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
|
1771 old_dentry->d_name.name, |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1772 yaffs_InodeToObject(new_dir), |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1773 new_dentry->d_name.name); |
| 7 | 1774 } |
| 1775 yaffs_GrossUnlock(dev); | |
| 76 | 1776 |
| 1777 if (retVal == YAFFS_OK) { | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1778 if (target) { |
| 88 | 1779 new_dentry->d_inode->i_nlink--; |
| 1780 mark_inode_dirty(new_dentry->d_inode); | |
| 1781 } | |
| 280 | 1782 |
| 1783 update_dir_time(old_dir); | |
| 1784 if(old_dir != new_dir) | |
| 1785 update_dir_time(new_dir); | |
| 7 | 1786 return 0; |
| 76 | 1787 } else { |
| 7 | 1788 return -ENOTEMPTY; |
| 1789 } | |
| 1790 } | |
| 1791 | |
| 1792 static int yaffs_setattr(struct dentry *dentry, struct iattr *attr) | |
| 1793 { | |
| 1794 struct inode *inode = dentry->d_inode; | |
| 350 | 1795 int error = 0; |
| 7 | 1796 yaffs_Device *dev; |
| 76 | 1797 |
| 1798 T(YAFFS_TRACE_OS, | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1799 (TSTR("yaffs_setattr of object %d\n"), |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1800 yaffs_InodeToObject(inode)->objectId)); |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1801 |
| 350 | 1802 /* Fail if a requested resize >= 2GB */ |
| 1803 if (attr->ia_valid & ATTR_SIZE && | |
| 1804 (attr->ia_size >> 31)) | |
| 1805 error = -EINVAL; | |
| 1806 | |
| 1807 if (error == 0) | |
| 1808 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
|
1809 if (error == 0) { |
| 332 | 1810 int result; |
| 1811 if (!error){ | |
| 1812 error = inode_setattr(inode, attr); | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1813 T(YAFFS_TRACE_OS,(TSTR("inode_setattr called\n"))); |
| 332 | 1814 if (attr->ia_valid & ATTR_SIZE) |
| 1815 truncate_inode_pages(&inode->i_data,attr->ia_size); | |
| 1816 } | |
| 7 | 1817 dev = yaffs_InodeToObject(inode)->myDev; |
| 332 | 1818 if (attr->ia_valid & ATTR_SIZE){ |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1819 T(YAFFS_TRACE_OS,(TSTR("resize to %d(%x)\n"), |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1820 (int)(attr->ia_size),(int)(attr->ia_size))); |
| 332 | 1821 } |
| 7 | 1822 yaffs_GrossLock(dev); |
| 332 | 1823 result = yaffs_SetAttributes(yaffs_InodeToObject(inode), attr); |
| 1824 if(result == YAFFS_OK) { | |
| 7 | 1825 error = 0; |
| 76 | 1826 } else { |
| 7 | 1827 error = -EPERM; |
| 1828 } | |
| 1829 yaffs_GrossUnlock(dev); | |
| 332 | 1830 |
| 7 | 1831 } |
| 350 | 1832 |
| 332 | 1833 T(YAFFS_TRACE_OS, |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1834 (TSTR("yaffs_setattr done returning %d\n"),error)); |
| 332 | 1835 |
| 7 | 1836 return error; |
| 1837 } | |
| 1838 | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1839 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17)) |
| 143 | 1840 static int yaffs_statfs(struct dentry *dentry, struct kstatfs *buf) |
| 1841 { | |
| 1842 yaffs_Device *dev = yaffs_DentryToObject(dentry)->myDev; | |
| 1843 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
|
1844 #elif (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0)) |
| 7 | 1845 static int yaffs_statfs(struct super_block *sb, struct kstatfs *buf) |
| 143 | 1846 { |
| 1847 yaffs_Device *dev = yaffs_SuperToDevice(sb); | |
| 7 | 1848 #else |
| 1849 static int yaffs_statfs(struct super_block *sb, struct statfs *buf) | |
| 143 | 1850 { |
| 1851 yaffs_Device *dev = yaffs_SuperToDevice(sb); | |
| 7 | 1852 #endif |
| 15 | 1853 |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1854 T(YAFFS_TRACE_OS, (TSTR("yaffs_statfs\n"))); |
| 7 | 1855 |
| 1856 yaffs_GrossLock(dev); | |
| 76 | 1857 |
| 7 | 1858 buf->f_type = YAFFS_MAGIC; |
| 1859 buf->f_bsize = sb->s_blocksize; | |
| 1860 buf->f_namelen = 255; | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1861 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1862 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
|
1863 /* 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
|
1864 |
|
204
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
1865 uint64_t bytesInDev; |
|
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
1866 uint64_t bytesFree; |
|
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
1867 |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
1868 bytesInDev = ((uint64_t)((dev->param.endBlock - dev->param.startBlock + 1))) * |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
1869 ((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
|
1870 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1871 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
|
1872 buf->f_blocks = bytesInDev; |
|
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
1873 |
|
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
1874 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
|
1875 ((uint64_t)(dev->nDataBytesPerChunk)); |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1876 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1877 do_div(bytesFree, sb->s_blocksize); |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1878 |
|
204
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
1879 buf->f_bfree = bytesFree; |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1880 |
|
204
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
1881 } 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
|
1882 |
| 76 | 1883 buf->f_blocks = |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
1884 (dev->param.endBlock - dev->param.startBlock + 1) * |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
1885 dev->param.nChunksPerBlock / |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1886 (sb->s_blocksize / dev->nDataBytesPerChunk); |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1887 buf->f_bfree = |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1888 yaffs_GetNumberOfFreeChunks(dev) / |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1889 (sb->s_blocksize / dev->nDataBytesPerChunk); |
| 76 | 1890 } else { |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1891 buf->f_blocks = |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
1892 (dev->param.endBlock - dev->param.startBlock + 1) * |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
1893 dev->param.nChunksPerBlock * |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1894 (dev->nDataBytesPerChunk / sb->s_blocksize); |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1895 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1896 buf->f_bfree = |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1897 yaffs_GetNumberOfFreeChunks(dev) * |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1898 (dev->nDataBytesPerChunk / sb->s_blocksize); |
| 15 | 1899 } |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
1900 |
| 7 | 1901 buf->f_files = 0; |
| 1902 buf->f_ffree = 0; | |
| 76 | 1903 buf->f_bavail = buf->f_bfree; |
| 1904 | |
| 7 | 1905 yaffs_GrossUnlock(dev); |
| 1906 return 0; | |
| 1907 } | |
| 1908 | |
| 129 | 1909 |
| 291 | 1910 |
|
372
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1911 static void yaffs_FlushInodes(struct super_block *sb) |
| 291 | 1912 { |
| 1913 struct inode *iptr; | |
| 1914 yaffs_Object *obj; | |
| 1915 | |
| 1916 list_for_each_entry(iptr,&sb->s_inodes, i_sb_list){ | |
| 1917 obj = yaffs_InodeToObject(iptr); | |
| 1918 if(obj){ | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1919 T(YAFFS_TRACE_OS, (TSTR("flushing obj %d\n"), |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1920 obj->objectId)); |
| 291 | 1921 yaffs_FlushFile(obj,1,0); |
| 1922 } | |
| 1923 } | |
| 1924 } | |
| 1925 | |
|
372
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1926 |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1927 static void yaffs_FlushSuperBlock(struct super_block *sb, int do_checkpoint) |
|
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_Device *dev = yaffs_SuperToDevice(sb); |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1930 if(!dev) |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1931 return; |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1932 |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1933 yaffs_FlushInodes(sb); |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1934 yaffs_UpdateDirtyDirectories(dev); |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1935 yaffs_FlushEntireDeviceCache(dev); |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1936 if(do_checkpoint) |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1937 yaffs_CheckpointSave(dev); |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1938 } |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1939 |
|
403
205fa93db422
yaffs New background garbage collector and related tweaks
Charles Manning <cdhmanning@gmail.com>
parents:
402
diff
changeset
|
1940 |
|
205fa93db422
yaffs New background garbage collector and related tweaks
Charles Manning <cdhmanning@gmail.com>
parents:
402
diff
changeset
|
1941 static unsigned yaffs_bg_gc_urgency(yaffs_Device *dev) |
|
205fa93db422
yaffs New background garbage collector and related tweaks
Charles Manning <cdhmanning@gmail.com>
parents:
402
diff
changeset
|
1942 { |
|
205fa93db422
yaffs New background garbage collector and related tweaks
Charles Manning <cdhmanning@gmail.com>
parents:
402
diff
changeset
|
1943 unsigned erasedChunks = dev->nErasedBlocks * dev->param.nChunksPerBlock; |
|
205fa93db422
yaffs New background garbage collector and related tweaks
Charles Manning <cdhmanning@gmail.com>
parents:
402
diff
changeset
|
1944 struct yaffs_LinuxContext *context = yaffs_DeviceToContext(dev); |
|
404
792f3d959342
yaffs: More background gc tweaks.
Charles Manning <cdhmanning@gmail.com>
parents:
403
diff
changeset
|
1945 unsigned scatteredFree = 0; /* Free chunks not in an erased block */ |
|
792f3d959342
yaffs: More background gc tweaks.
Charles Manning <cdhmanning@gmail.com>
parents:
403
diff
changeset
|
1946 |
|
792f3d959342
yaffs: More background gc tweaks.
Charles Manning <cdhmanning@gmail.com>
parents:
403
diff
changeset
|
1947 if(erasedChunks < dev->nFreeChunks) |
|
792f3d959342
yaffs: More background gc tweaks.
Charles Manning <cdhmanning@gmail.com>
parents:
403
diff
changeset
|
1948 scatteredFree = (dev->nFreeChunks - erasedChunks); |
|
403
205fa93db422
yaffs New background garbage collector and related tweaks
Charles Manning <cdhmanning@gmail.com>
parents:
402
diff
changeset
|
1949 |
|
205fa93db422
yaffs New background garbage collector and related tweaks
Charles Manning <cdhmanning@gmail.com>
parents:
402
diff
changeset
|
1950 if(!context->bgRunning) |
|
205fa93db422
yaffs New background garbage collector and related tweaks
Charles Manning <cdhmanning@gmail.com>
parents:
402
diff
changeset
|
1951 return 0; |
|
404
792f3d959342
yaffs: More background gc tweaks.
Charles Manning <cdhmanning@gmail.com>
parents:
403
diff
changeset
|
1952 else if(scatteredFree < (dev->param.nChunksPerBlock * 2)) |
|
792f3d959342
yaffs: More background gc tweaks.
Charles Manning <cdhmanning@gmail.com>
parents:
403
diff
changeset
|
1953 return 0; |
|
403
205fa93db422
yaffs New background garbage collector and related tweaks
Charles Manning <cdhmanning@gmail.com>
parents:
402
diff
changeset
|
1954 else if(erasedChunks > dev->nFreeChunks/2) |
|
205fa93db422
yaffs New background garbage collector and related tweaks
Charles Manning <cdhmanning@gmail.com>
parents:
402
diff
changeset
|
1955 return 0; |
|
205fa93db422
yaffs New background garbage collector and related tweaks
Charles Manning <cdhmanning@gmail.com>
parents:
402
diff
changeset
|
1956 else if(erasedChunks > dev->nFreeChunks/4) |
|
205fa93db422
yaffs New background garbage collector and related tweaks
Charles Manning <cdhmanning@gmail.com>
parents:
402
diff
changeset
|
1957 return 1; |
|
205fa93db422
yaffs New background garbage collector and related tweaks
Charles Manning <cdhmanning@gmail.com>
parents:
402
diff
changeset
|
1958 else |
|
205fa93db422
yaffs New background garbage collector and related tweaks
Charles Manning <cdhmanning@gmail.com>
parents:
402
diff
changeset
|
1959 return 2; |
|
205fa93db422
yaffs New background garbage collector and related tweaks
Charles Manning <cdhmanning@gmail.com>
parents:
402
diff
changeset
|
1960 } |
|
205fa93db422
yaffs New background garbage collector and related tweaks
Charles Manning <cdhmanning@gmail.com>
parents:
402
diff
changeset
|
1961 |
|
205fa93db422
yaffs New background garbage collector and related tweaks
Charles Manning <cdhmanning@gmail.com>
parents:
402
diff
changeset
|
1962 static int yaffs_do_sync_fs(struct super_block *sb, |
|
205fa93db422
yaffs New background garbage collector and related tweaks
Charles Manning <cdhmanning@gmail.com>
parents:
402
diff
changeset
|
1963 int request_checkpoint) |
| 129 | 1964 { |
| 1965 | |
| 1966 yaffs_Device *dev = yaffs_SuperToDevice(sb); | |
|
400
fb6ffedcfa89
Add one-shot feature for yaffs auto checkpointing.
Charles Manning <cdhmanning@gmail.com>
parents:
398
diff
changeset
|
1967 unsigned int oneshot_checkpoint = (yaffs_auto_checkpoint & 4); |
|
404
792f3d959342
yaffs: More background gc tweaks.
Charles Manning <cdhmanning@gmail.com>
parents:
403
diff
changeset
|
1968 unsigned gc_urgent = yaffs_bg_gc_urgency(dev); |
|
792f3d959342
yaffs: More background gc tweaks.
Charles Manning <cdhmanning@gmail.com>
parents:
403
diff
changeset
|
1969 int do_checkpoint; |
|
792f3d959342
yaffs: More background gc tweaks.
Charles Manning <cdhmanning@gmail.com>
parents:
403
diff
changeset
|
1970 |
|
792f3d959342
yaffs: More background gc tweaks.
Charles Manning <cdhmanning@gmail.com>
parents:
403
diff
changeset
|
1971 T(YAFFS_TRACE_OS | YAFFS_TRACE_SYNC | YAFFS_TRACE_BACKGROUND, |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
1972 (TSTR("yaffs_do_sync_fs: gc-urgency %d %s %s%s\n"), |
|
404
792f3d959342
yaffs: More background gc tweaks.
Charles Manning <cdhmanning@gmail.com>
parents:
403
diff
changeset
|
1973 gc_urgent, |
|
372
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1974 sb->s_dirt ? "dirty" : "clean", |
|
403
205fa93db422
yaffs New background garbage collector and related tweaks
Charles Manning <cdhmanning@gmail.com>
parents:
402
diff
changeset
|
1975 request_checkpoint ? "checkpoint requested" : "no checkpoint", |
|
400
fb6ffedcfa89
Add one-shot feature for yaffs auto checkpointing.
Charles Manning <cdhmanning@gmail.com>
parents:
398
diff
changeset
|
1976 oneshot_checkpoint ? " one-shot" : "" )); |
|
fb6ffedcfa89
Add one-shot feature for yaffs auto checkpointing.
Charles Manning <cdhmanning@gmail.com>
parents:
398
diff
changeset
|
1977 |
|
404
792f3d959342
yaffs: More background gc tweaks.
Charles Manning <cdhmanning@gmail.com>
parents:
403
diff
changeset
|
1978 yaffs_GrossLock(dev); |
|
792f3d959342
yaffs: More background gc tweaks.
Charles Manning <cdhmanning@gmail.com>
parents:
403
diff
changeset
|
1979 do_checkpoint = ((request_checkpoint && !gc_urgent) || |
|
792f3d959342
yaffs: More background gc tweaks.
Charles Manning <cdhmanning@gmail.com>
parents:
403
diff
changeset
|
1980 oneshot_checkpoint) && |
|
792f3d959342
yaffs: More background gc tweaks.
Charles Manning <cdhmanning@gmail.com>
parents:
403
diff
changeset
|
1981 !dev->isCheckpointed; |
|
792f3d959342
yaffs: More background gc tweaks.
Charles Manning <cdhmanning@gmail.com>
parents:
403
diff
changeset
|
1982 |
|
792f3d959342
yaffs: More background gc tweaks.
Charles Manning <cdhmanning@gmail.com>
parents:
403
diff
changeset
|
1983 if (sb->s_dirt || do_checkpoint) { |
|
792f3d959342
yaffs: More background gc tweaks.
Charles Manning <cdhmanning@gmail.com>
parents:
403
diff
changeset
|
1984 yaffs_FlushSuperBlock(sb, !dev->isCheckpointed && do_checkpoint); |
| 129 | 1985 sb->s_dirt = 0; |
|
400
fb6ffedcfa89
Add one-shot feature for yaffs auto checkpointing.
Charles Manning <cdhmanning@gmail.com>
parents:
398
diff
changeset
|
1986 if(oneshot_checkpoint) |
|
fb6ffedcfa89
Add one-shot feature for yaffs auto checkpointing.
Charles Manning <cdhmanning@gmail.com>
parents:
398
diff
changeset
|
1987 yaffs_auto_checkpoint &= ~4; |
| 129 | 1988 } |
|
404
792f3d959342
yaffs: More background gc tweaks.
Charles Manning <cdhmanning@gmail.com>
parents:
403
diff
changeset
|
1989 yaffs_GrossUnlock(dev); |
|
403
205fa93db422
yaffs New background garbage collector and related tweaks
Charles Manning <cdhmanning@gmail.com>
parents:
402
diff
changeset
|
1990 |
| 129 | 1991 return 0; |
| 1992 } | |
|
210
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
1993 |
|
372
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 * yaffs background thread functions . |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1996 * yaffs_BackgroundThread() the thread function |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1997 * yaffs_BackgroundStart() launches the background thread. |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1998 * yaffs_BackgroundStop() cleans up the background thread. |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
1999 * |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2000 * NB: |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2001 * The thread should only run after the yaffs is initialised |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2002 * The thread should be stopped before yaffs is unmounted. |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2003 * 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
|
2004 */ |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2005 |
|
374
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
2006 #ifdef YAFFS_COMPILE_BACKGROUND |
| 402 | 2007 |
| 2008 void yaffs_background_waker(unsigned long data) | |
| 2009 { | |
| 2010 wake_up_process((struct task_struct *)data); | |
| 2011 } | |
| 2012 | |
|
372
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2013 static int yaffs_BackgroundThread(void *data) |
|
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 yaffs_Device *dev = (yaffs_Device *)data; |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2016 struct yaffs_LinuxContext *context = yaffs_DeviceToContext(dev); |
| 402 | 2017 unsigned long now = jiffies; |
| 2018 unsigned long next_dir_update = now; | |
| 2019 unsigned long next_gc = now; | |
| 2020 unsigned long expires; | |
|
403
205fa93db422
yaffs New background garbage collector and related tweaks
Charles Manning <cdhmanning@gmail.com>
parents:
402
diff
changeset
|
2021 unsigned int urgency; |
| 402 | 2022 |
| 2023 int gcResult; | |
| 2024 struct timer_list timer; | |
|
372
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2025 |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2026 T(YAFFS_TRACE_BACKGROUND, |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2027 (TSTR("yaffs_background starting for dev %p\n"), |
|
372
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2028 (void *)dev)); |
| 402 | 2029 |
| 2030 set_freezable(); | |
| 2031 | |
|
372
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2032 while(context->bgRunning){ |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2033 T(YAFFS_TRACE_BACKGROUND, |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2034 (TSTR("yaffs_background\n"))); |
|
372
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2035 |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2036 if(kthread_should_stop()) |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2037 break; |
| 402 | 2038 |
| 2039 if(try_to_freeze()) | |
| 2040 continue; | |
| 2041 | |
|
372
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2042 yaffs_GrossLock(dev); |
| 402 | 2043 |
| 2044 now = jiffies; | |
| 2045 | |
|
404
792f3d959342
yaffs: More background gc tweaks.
Charles Manning <cdhmanning@gmail.com>
parents:
403
diff
changeset
|
2046 if(time_after(now, next_dir_update)){ |
| 402 | 2047 yaffs_UpdateDirtyDirectories(dev); |
| 2048 next_dir_update = now + HZ; | |
| 2049 } | |
| 2050 | |
|
404
792f3d959342
yaffs: More background gc tweaks.
Charles Manning <cdhmanning@gmail.com>
parents:
403
diff
changeset
|
2051 if(time_after(now,next_gc)){ |
|
792f3d959342
yaffs: More background gc tweaks.
Charles Manning <cdhmanning@gmail.com>
parents:
403
diff
changeset
|
2052 if(!dev->isCheckpointed){ |
|
792f3d959342
yaffs: More background gc tweaks.
Charles Manning <cdhmanning@gmail.com>
parents:
403
diff
changeset
|
2053 urgency = yaffs_bg_gc_urgency(dev); |
|
792f3d959342
yaffs: More background gc tweaks.
Charles Manning <cdhmanning@gmail.com>
parents:
403
diff
changeset
|
2054 gcResult = yaffs_BackgroundGarbageCollect(dev, urgency); |
|
792f3d959342
yaffs: More background gc tweaks.
Charles Manning <cdhmanning@gmail.com>
parents:
403
diff
changeset
|
2055 if(urgency > 1) |
|
792f3d959342
yaffs: More background gc tweaks.
Charles Manning <cdhmanning@gmail.com>
parents:
403
diff
changeset
|
2056 next_gc = now + HZ/20+1; |
|
792f3d959342
yaffs: More background gc tweaks.
Charles Manning <cdhmanning@gmail.com>
parents:
403
diff
changeset
|
2057 else if(urgency > 0) |
|
792f3d959342
yaffs: More background gc tweaks.
Charles Manning <cdhmanning@gmail.com>
parents:
403
diff
changeset
|
2058 next_gc = now + HZ/10+1; |
|
792f3d959342
yaffs: More background gc tweaks.
Charles Manning <cdhmanning@gmail.com>
parents:
403
diff
changeset
|
2059 else |
|
792f3d959342
yaffs: More background gc tweaks.
Charles Manning <cdhmanning@gmail.com>
parents:
403
diff
changeset
|
2060 next_gc = now + HZ * 2; |
|
792f3d959342
yaffs: More background gc tweaks.
Charles Manning <cdhmanning@gmail.com>
parents:
403
diff
changeset
|
2061 } else /* |
|
792f3d959342
yaffs: More background gc tweaks.
Charles Manning <cdhmanning@gmail.com>
parents:
403
diff
changeset
|
2062 * gc not running so set to next_dir_update |
|
792f3d959342
yaffs: More background gc tweaks.
Charles Manning <cdhmanning@gmail.com>
parents:
403
diff
changeset
|
2063 * to cut down on wake ups |
|
792f3d959342
yaffs: More background gc tweaks.
Charles Manning <cdhmanning@gmail.com>
parents:
403
diff
changeset
|
2064 */ |
|
792f3d959342
yaffs: More background gc tweaks.
Charles Manning <cdhmanning@gmail.com>
parents:
403
diff
changeset
|
2065 next_gc = next_dir_update; |
| 402 | 2066 } |
|
372
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2067 yaffs_GrossUnlock(dev); |
| 402 | 2068 #if 1 |
| 2069 expires = next_dir_update; | |
| 2070 if (time_before(next_gc,expires)) | |
| 2071 expires = next_gc; | |
| 2072 if(time_before(expires,now)) | |
| 2073 expires = now + HZ; | |
| 2074 | |
| 2075 init_timer(&timer); | |
| 2076 timer.expires = expires+1; | |
| 2077 timer.data = (unsigned long) current; | |
| 2078 timer.function = yaffs_background_waker; | |
| 2079 | |
| 2080 set_current_state(TASK_INTERRUPTIBLE); | |
| 2081 add_timer(&timer); | |
| 2082 schedule(); | |
| 2083 del_timer_sync(&timer); | |
| 2084 #else | |
| 2085 msleep(10); | |
| 2086 #endif | |
|
372
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2087 } |
| 402 | 2088 |
|
372
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2089 return 0; |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2090 } |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2091 |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2092 static int yaffs_BackgroundStart(yaffs_Device *dev) |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2093 { |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2094 int retval = 0; |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2095 struct yaffs_LinuxContext *context = yaffs_DeviceToContext(dev); |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2096 |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2097 context->bgRunning = 1; |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2098 |
|
407
36a72b45da7c
yaffs: Clean up 64-bit compilation
Charles Manning <cdhmanning@gmail.com>
parents:
404
diff
changeset
|
2099 context->bgThread = kthread_run(yaffs_BackgroundThread, |
|
36a72b45da7c
yaffs: Clean up 64-bit compilation
Charles Manning <cdhmanning@gmail.com>
parents:
404
diff
changeset
|
2100 (void *)dev,"yaffs-bg"); |
|
372
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2101 |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2102 if(IS_ERR(context->bgThread)){ |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2103 retval = PTR_ERR(context->bgThread); |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2104 context->bgThread = NULL; |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2105 context->bgRunning = 0; |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2106 } |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2107 return retval; |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2108 } |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2109 |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2110 static void yaffs_BackgroundStop(yaffs_Device *dev) |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2111 { |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2112 struct yaffs_LinuxContext *ctxt = yaffs_DeviceToContext(dev); |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2113 |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2114 ctxt->bgRunning = 0; |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2115 |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2116 if( ctxt->bgThread){ |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2117 kthread_stop(ctxt->bgThread); |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2118 ctxt->bgThread = NULL; |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2119 } |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2120 } |
|
374
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
2121 #else |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
2122 static int yaffs_BackgroundThread(void *data) |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
2123 { |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
2124 return 0; |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
2125 } |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
2126 |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
2127 static int yaffs_BackgroundStart(yaffs_Device *dev) |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
2128 { |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
2129 return 0; |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
2130 } |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
2131 |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
2132 static void yaffs_BackgroundStop(yaffs_Device *dev) |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
2133 { |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
2134 } |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
2135 #endif |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
2136 |
| 129 | 2137 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2138 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17)) |
| 143 | 2139 static void yaffs_write_super(struct super_block *sb) |
| 2140 #else | |
| 129 | 2141 static int yaffs_write_super(struct super_block *sb) |
| 143 | 2142 #endif |
| 129 | 2143 { |
|
403
205fa93db422
yaffs New background garbage collector and related tweaks
Charles Manning <cdhmanning@gmail.com>
parents:
402
diff
changeset
|
2144 unsigned request_checkpoint = (yaffs_auto_checkpoint >= 2); |
|
205fa93db422
yaffs New background garbage collector and related tweaks
Charles Manning <cdhmanning@gmail.com>
parents:
402
diff
changeset
|
2145 |
|
404
792f3d959342
yaffs: More background gc tweaks.
Charles Manning <cdhmanning@gmail.com>
parents:
403
diff
changeset
|
2146 T(YAFFS_TRACE_OS | YAFFS_TRACE_SYNC | YAFFS_TRACE_BACKGROUND, |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2147 (TSTR("yaffs_write_super%s\n"), |
|
403
205fa93db422
yaffs New background garbage collector and related tweaks
Charles Manning <cdhmanning@gmail.com>
parents:
402
diff
changeset
|
2148 request_checkpoint ? " checkpt" : "")); |
|
205fa93db422
yaffs New background garbage collector and related tweaks
Charles Manning <cdhmanning@gmail.com>
parents:
402
diff
changeset
|
2149 |
|
205fa93db422
yaffs New background garbage collector and related tweaks
Charles Manning <cdhmanning@gmail.com>
parents:
402
diff
changeset
|
2150 yaffs_do_sync_fs(sb, request_checkpoint); |
|
372
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2151 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2152 #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
|
2153 return 0; |
| 143 | 2154 #endif |
| 129 | 2155 } |
| 2156 | |
| 2157 | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2158 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17)) |
| 143 | 2159 static int yaffs_sync_fs(struct super_block *sb, int wait) |
| 2160 #else | |
| 129 | 2161 static int yaffs_sync_fs(struct super_block *sb) |
| 143 | 2162 #endif |
| 129 | 2163 { |
|
403
205fa93db422
yaffs New background garbage collector and related tweaks
Charles Manning <cdhmanning@gmail.com>
parents:
402
diff
changeset
|
2164 unsigned request_checkpoint = (yaffs_auto_checkpoint >= 1); |
|
205fa93db422
yaffs New background garbage collector and related tweaks
Charles Manning <cdhmanning@gmail.com>
parents:
402
diff
changeset
|
2165 |
|
205fa93db422
yaffs New background garbage collector and related tweaks
Charles Manning <cdhmanning@gmail.com>
parents:
402
diff
changeset
|
2166 T(YAFFS_TRACE_OS | YAFFS_TRACE_SYNC, |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2167 (TSTR("yaffs_sync_fs%s\n"), |
|
403
205fa93db422
yaffs New background garbage collector and related tweaks
Charles Manning <cdhmanning@gmail.com>
parents:
402
diff
changeset
|
2168 request_checkpoint ? " checkpt" : "")); |
|
205fa93db422
yaffs New background garbage collector and related tweaks
Charles Manning <cdhmanning@gmail.com>
parents:
402
diff
changeset
|
2169 |
|
205fa93db422
yaffs New background garbage collector and related tweaks
Charles Manning <cdhmanning@gmail.com>
parents:
402
diff
changeset
|
2170 yaffs_do_sync_fs(sb, request_checkpoint); |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2171 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2172 return 0; |
| 129 | 2173 } |
| 2174 | |
|
210
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2175 #ifdef YAFFS_USE_OWN_IGET |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2176 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2177 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
|
2178 { |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2179 struct inode *inode; |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2180 yaffs_Object *obj; |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2181 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
|
2182 |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2183 T(YAFFS_TRACE_OS, |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2184 (TSTR("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
|
2185 |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2186 inode = iget_locked(sb, ino); |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2187 if (!inode) |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2188 return ERR_PTR(-ENOMEM); |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2189 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
|
2190 return inode; |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2191 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2192 /* 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
|
2193 * 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
|
2194 * need to lock again. |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2195 */ |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2196 |
|
210
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2197 yaffs_GrossLock(dev); |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2198 |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2199 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
|
2200 |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2201 yaffs_FillInodeFromObject(inode, obj); |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2202 |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2203 yaffs_GrossUnlock(dev); |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2204 |
|
210
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2205 unlock_new_inode(inode); |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2206 return inode; |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2207 } |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2208 |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2209 #else |
| 129 | 2210 |
| 76 | 2211 static void yaffs_read_inode(struct inode *inode) |
| 7 | 2212 { |
|
106
5b8f68c30468
Apply Reed's deadlocking fix (manually applied)
charles <charles>
parents:
104
diff
changeset
|
2213 /* 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
|
2214 * 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
|
2215 * need to lock again. |
| 76 | 2216 */ |
| 2217 | |
| 2218 yaffs_Object *obj; | |
| 7 | 2219 yaffs_Device *dev = yaffs_SuperToDevice(inode->i_sb); |
| 76 | 2220 |
| 2221 T(YAFFS_TRACE_OS, | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2222 (TSTR("yaffs_read_inode for %d\n"), (int)inode->i_ino)); |
| 7 | 2223 |
| 398 | 2224 if(current != yaffs_DeviceToContext(dev)->readdirProcess) |
| 2225 yaffs_GrossLock(dev); | |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2226 |
| 76 | 2227 obj = yaffs_FindObjectByNumber(dev, inode->i_ino); |
| 2228 | |
| 2229 yaffs_FillInodeFromObject(inode, obj); | |
| 7 | 2230 |
| 398 | 2231 if(current != yaffs_DeviceToContext(dev)->readdirProcess) |
| 2232 yaffs_GrossUnlock(dev); | |
| 7 | 2233 } |
| 2234 | |
|
210
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2235 #endif |
|
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2236 |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2237 static YLIST_HEAD(yaffs_context_list); |
|
384
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2238 struct semaphore yaffs_context_lock; |
| 7 | 2239 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2240 #if 0 /* not used */ |
| 175 | 2241 static int yaffs_remount_fs(struct super_block *sb, int *flags, char *data) |
| 2242 { | |
| 2243 yaffs_Device *dev = yaffs_SuperToDevice(sb); | |
| 2244 | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2245 if (*flags & MS_RDONLY) { |
| 175 | 2246 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
|
2247 |
| 175 | 2248 T(YAFFS_TRACE_OS, |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2249 (TSTR("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
|
2250 |
| 175 | 2251 yaffs_GrossLock(dev); |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2252 |
|
372
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2253 yaffs_FlushSuperBlock(sb,1); |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2254 |
| 175 | 2255 if (mtd->sync) |
| 2256 mtd->sync(mtd); | |
| 2257 | |
| 2258 yaffs_GrossUnlock(dev); | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2259 } else { |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2260 T(YAFFS_TRACE_OS, |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2261 (TSTR("yaffs_remount_fs: %s: RW\n"), dev->name)); |
| 175 | 2262 } |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2263 |
| 175 | 2264 return 0; |
| 2265 } | |
| 189 | 2266 #endif |
| 175 | 2267 |
| 7 | 2268 static void yaffs_put_super(struct super_block *sb) |
| 2269 { | |
| 2270 yaffs_Device *dev = yaffs_SuperToDevice(sb); | |
| 76 | 2271 |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2272 T(YAFFS_TRACE_OS, (TSTR("yaffs_put_super\n"))); |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2273 |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2274 T(YAFFS_TRACE_OS | YAFFS_TRACE_BACKGROUND, |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2275 (TSTR("Shutting down yaffs background thread\n"))); |
| 402 | 2276 yaffs_BackgroundStop(dev); |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2277 T(YAFFS_TRACE_OS | YAFFS_TRACE_BACKGROUND, |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2278 (TSTR("yaffs background thread shut down\n"))); |
| 402 | 2279 |
| 7 | 2280 yaffs_GrossLock(dev); |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2281 |
|
372
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2282 yaffs_FlushSuperBlock(sb,1); |
| 175 | 2283 |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2284 if (yaffs_DeviceToContext(dev)->putSuperFunc) |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2285 yaffs_DeviceToContext(dev)->putSuperFunc(sb); |
| 175 | 2286 |
|
372
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2287 |
| 7 | 2288 yaffs_Deinitialise(dev); |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2289 |
| 7 | 2290 yaffs_GrossUnlock(dev); |
| 2291 | |
|
384
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2292 down(&yaffs_context_lock); |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2293 ylist_del_init(&(yaffs_DeviceToContext(dev)->contextList)); |
|
384
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2294 up(&yaffs_context_lock); |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2295 |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2296 if (yaffs_DeviceToContext(dev)->spareBuffer) { |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2297 YFREE(yaffs_DeviceToContext(dev)->spareBuffer); |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2298 yaffs_DeviceToContext(dev)->spareBuffer = NULL; |
| 124 | 2299 } |
| 27 | 2300 |
| 7 | 2301 kfree(dev); |
| 2302 } | |
| 2303 | |
| 2304 | |
| 76 | 2305 static void yaffs_MTDPutSuper(struct super_block *sb) |
| 7 | 2306 { |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2307 struct mtd_info *mtd = yaffs_DeviceToContext(yaffs_SuperToDevice(sb))->mtd; |
| 76 | 2308 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2309 if (mtd->sync) |
| 7 | 2310 mtd->sync(mtd); |
| 76 | 2311 |
| 7 | 2312 put_mtd_device(mtd); |
| 2313 } | |
| 2314 | |
| 2315 | |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2316 static void yaffs_MarkSuperBlockDirty(yaffs_Device *dev) |
| 129 | 2317 { |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2318 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
|
2319 |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2320 T(YAFFS_TRACE_OS, (TSTR("yaffs_MarkSuperBlockDirty() sb = %p\n"), sb)); |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2321 if (sb) |
| 249 | 2322 sb->s_dirt = 1; |
| 129 | 2323 } |
| 2324 | |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2325 typedef struct { |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2326 int inband_tags; |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2327 int skip_checkpoint_read; |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2328 int skip_checkpoint_write; |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2329 int no_cache; |
| 300 | 2330 int tags_ecc_on; |
| 2331 int tags_ecc_overridden; | |
| 311 | 2332 int lazy_loading_enabled; |
| 2333 int lazy_loading_overridden; | |
| 2334 int empty_lost_and_found; | |
| 2335 int empty_lost_and_found_overridden; | |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2336 } yaffs_options; |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2337 |
| 311 | 2338 #define MAX_OPT_LEN 30 |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2339 static int yaffs_parse_options(yaffs_options *options, const char *options_str) |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2340 { |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2341 char cur_opt[MAX_OPT_LEN + 1]; |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2342 int p; |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2343 int error = 0; |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2344 |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2345 /* 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
|
2346 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2347 while (options_str && *options_str && !error) { |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2348 memset(cur_opt, 0, MAX_OPT_LEN + 1); |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2349 p = 0; |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2350 |
| 300 | 2351 while(*options_str == ',') |
| 2352 options_str++; | |
| 2353 | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2354 while (*options_str && *options_str != ',') { |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2355 if (p < MAX_OPT_LEN) { |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2356 cur_opt[p] = *options_str; |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2357 p++; |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2358 } |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2359 options_str++; |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2360 } |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2361 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2362 if (!strcmp(cur_opt, "inband-tags")) |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2363 options->inband_tags = 1; |
| 300 | 2364 else if (!strcmp(cur_opt, "tags-ecc-off")){ |
| 2365 options->tags_ecc_on = 0; | |
| 2366 options->tags_ecc_overridden=1; | |
| 2367 } else if (!strcmp(cur_opt, "tags-ecc-on")){ | |
| 2368 options->tags_ecc_on = 1; | |
| 2369 options->tags_ecc_overridden = 1; | |
| 311 | 2370 } else if (!strcmp(cur_opt, "lazy-loading-off")){ |
| 2371 options->lazy_loading_enabled = 0; | |
| 2372 options->lazy_loading_overridden=1; | |
| 2373 } else if (!strcmp(cur_opt, "lazy-loading-on")){ | |
| 2374 options->lazy_loading_enabled = 1; | |
| 2375 options->lazy_loading_overridden = 1; | |
| 2376 } else if (!strcmp(cur_opt, "empty-lost-and-found-off")){ | |
| 2377 options->empty_lost_and_found = 0; | |
| 2378 options->empty_lost_and_found_overridden=1; | |
| 2379 } else if (!strcmp(cur_opt, "empty-lost-and-found-on")){ | |
| 2380 options->empty_lost_and_found = 1; | |
| 2381 options->empty_lost_and_found_overridden=1; | |
| 300 | 2382 } else if (!strcmp(cur_opt, "no-cache")) |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2383 options->no_cache = 1; |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2384 else if (!strcmp(cur_opt, "no-checkpoint-read")) |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2385 options->skip_checkpoint_read = 1; |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2386 else if (!strcmp(cur_opt, "no-checkpoint-write")) |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2387 options->skip_checkpoint_write = 1; |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2388 else if (!strcmp(cur_opt, "no-checkpoint")) { |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2389 options->skip_checkpoint_read = 1; |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2390 options->skip_checkpoint_write = 1; |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2391 } else { |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2392 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
|
2393 cur_opt); |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2394 error = 1; |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2395 } |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2396 } |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2397 |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2398 return error; |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2399 } |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2400 |
| 76 | 2401 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
|
2402 struct super_block *sb, |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2403 void *data, int silent) |
| 7 | 2404 { |
| 2405 int nBlocks; | |
| 76 | 2406 struct inode *inode = NULL; |
| 2407 struct dentry *root; | |
| 27 | 2408 yaffs_Device *dev = 0; |
| 76 | 2409 char devname_buf[BDEVNAME_SIZE + 1]; |
|
59
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
2410 struct mtd_info *mtd; |
| 7 | 2411 int err; |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2412 char *data_str = (char *)data; |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2413 struct yaffs_LinuxContext *context = NULL; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2414 yaffs_DeviceParam *param; |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2415 |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2416 yaffs_options options; |
| 76 | 2417 |
| 7 | 2418 sb->s_magic = YAFFS_MAGIC; |
| 2419 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
|
2420 sb->s_flags |= MS_NOATIME; |
| 76 | 2421 |
| 401 | 2422 #ifdef YAFFS_COMPILE_EXPORTFS |
| 398 | 2423 sb->s_export_op = &yaffs_export_ops; |
| 2424 #endif | |
| 2425 | |
| 76 | 2426 if (!sb) |
| 2427 printk(KERN_INFO "yaffs: sb is NULL\n"); | |
| 2428 else if (!sb->s_dev) | |
| 2429 printk(KERN_INFO "yaffs: sb->s_dev is NULL\n"); | |
| 2430 else if (!yaffs_devname(sb, devname_buf)) | |
| 2431 printk(KERN_INFO "yaffs: devname is NULL\n"); | |
| 7 | 2432 else |
| 76 | 2433 printk(KERN_INFO "yaffs: dev is %d name is \"%s\"\n", |
| 2434 sb->s_dev, | |
| 2435 yaffs_devname(sb, devname_buf)); | |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2436 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2437 if (!data_str) |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2438 data_str = ""; |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2439 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2440 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
|
2441 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2442 memset(&options, 0, sizeof(options)); |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2443 |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2444 if (yaffs_parse_options(&options, data_str)) { |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2445 /* Option parsing failed */ |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2446 return NULL; |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2447 } |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2448 |
| 7 | 2449 |
| 2450 sb->s_blocksize = PAGE_CACHE_SIZE; | |
| 2451 sb->s_blocksize_bits = PAGE_CACHE_SHIFT; | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2452 |
| 76 | 2453 T(YAFFS_TRACE_OS, |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2454 (TSTR("yaffs_read_super: Using yaffs%d\n"), yaffsVersion)); |
| 76 | 2455 T(YAFFS_TRACE_OS, |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2456 (TSTR("yaffs_read_super: block size %d\n"), |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2457 (int)(sb->s_blocksize))); |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2458 |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2459 T(YAFFS_TRACE_ALWAYS, |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2460 (TSTR("yaffs: Attempting MTD mount of %u.%u,\"%s\"\n"), |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2461 MAJOR(sb->s_dev), MINOR(sb->s_dev), |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2462 yaffs_devname(sb, devname_buf))); |
| 7 | 2463 |
| 76 | 2464 /* Check it's an mtd device..... */ |
| 273 | 2465 if (MAJOR(sb->s_dev) != MTD_BLOCK_MAJOR) |
| 76 | 2466 return NULL; /* This isn't an mtd device */ |
| 273 | 2467 |
| 76 | 2468 /* Get the device */ |
|
59
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
2469 mtd = get_mtd_device(NULL, MINOR(sb->s_dev)); |
| 76 | 2470 if (!mtd) { |
| 2471 T(YAFFS_TRACE_ALWAYS, | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2472 (TSTR("yaffs: MTD device #%u doesn't appear to exist\n"), |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2473 MINOR(sb->s_dev))); |
|
59
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
2474 return NULL; |
|
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
2475 } |
| 76 | 2476 /* Check it's NAND */ |
| 2477 if (mtd->type != MTD_NANDFLASH) { | |
| 2478 T(YAFFS_TRACE_ALWAYS, | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2479 (TSTR("yaffs: MTD device is not NAND it's type %d\n"), |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2480 mtd->type)); |
|
59
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
2481 return NULL; |
|
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
2482 } |
|
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
2483 |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2484 T(YAFFS_TRACE_OS, (TSTR(" erase %p\n"), mtd->erase)); |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2485 T(YAFFS_TRACE_OS, (TSTR(" read %p\n"), mtd->read)); |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2486 T(YAFFS_TRACE_OS, (TSTR(" write %p\n"), mtd->write)); |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2487 T(YAFFS_TRACE_OS, (TSTR(" readoob %p\n"), mtd->read_oob)); |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2488 T(YAFFS_TRACE_OS, (TSTR(" writeoob %p\n"), mtd->write_oob)); |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2489 T(YAFFS_TRACE_OS, (TSTR(" block_isbad %p\n"), mtd->block_isbad)); |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2490 T(YAFFS_TRACE_OS, (TSTR(" block_markbad %p\n"), mtd->block_markbad)); |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2491 T(YAFFS_TRACE_OS, (TSTR(" %s %d\n"), WRITE_SIZE_STR, WRITE_SIZE(mtd))); |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2492 T(YAFFS_TRACE_OS, (TSTR(" oobsize %d\n"), mtd->oobsize)); |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2493 T(YAFFS_TRACE_OS, (TSTR(" erasesize %d\n"), mtd->erasesize)); |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2494 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2495 T(YAFFS_TRACE_OS, (TSTR(" size %u\n"), mtd->size)); |
| 266 | 2496 #else |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2497 T(YAFFS_TRACE_OS, (TSTR(" size %lld\n"), mtd->size)); |
| 266 | 2498 #endif |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2499 |
| 109 | 2500 #ifdef CONFIG_YAFFS_AUTO_YAFFS2 |
| 108 | 2501 |
| 273 | 2502 if (yaffsVersion == 1 && WRITE_SIZE(mtd) >= 2048) { |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2503 T(YAFFS_TRACE_ALWAYS, |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2504 (TSTR("yaffs: auto selecting yaffs2\n"))); |
| 273 | 2505 yaffsVersion = 2; |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2506 } |
|
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2507 |
| 137 | 2508 /* Added NCB 26/5/2006 for completeness */ |
| 273 | 2509 if (yaffsVersion == 2 && !options.inband_tags && WRITE_SIZE(mtd) == 512) { |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2510 T(YAFFS_TRACE_ALWAYS, |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2511 (TSTR("yaffs: auto selecting yaffs1\n"))); |
| 273 | 2512 yaffsVersion = 1; |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2513 } |
| 137 | 2514 |
| 108 | 2515 #endif |
|
59
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
2516 |
| 76 | 2517 if (yaffsVersion == 2) { |
| 2518 /* Check for version 2 style functions */ | |
| 2519 if (!mtd->erase || | |
| 2520 !mtd->block_isbad || | |
| 2521 !mtd->block_markbad || | |
| 2522 !mtd->read || | |
| 2523 !mtd->write || | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2524 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17)) |
| 143 | 2525 !mtd->read_oob || !mtd->write_oob) { |
| 2526 #else | |
| 76 | 2527 !mtd->write_ecc || |
| 2528 !mtd->read_ecc || !mtd->read_oob || !mtd->write_oob) { | |
| 143 | 2529 #endif |
| 76 | 2530 T(YAFFS_TRACE_ALWAYS, |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2531 (TSTR("yaffs: MTD device does not support required " |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2532 "functions\n"))); |
| 7 | 2533 return NULL; |
| 2534 } | |
| 76 | 2535 |
|
204
0f70320a2274
Check in inband tags, some extra yaffs direct functions and some other changes
charles <charles>
parents:
198
diff
changeset
|
2536 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
|
2537 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
|
2538 !options.inband_tags) { |
| 76 | 2539 T(YAFFS_TRACE_ALWAYS, |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2540 (TSTR("yaffs: MTD device does not have the " |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2541 "right page sizes\n"))); |
|
59
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
2542 return NULL; |
| 7 | 2543 } |
| 76 | 2544 } else { |
| 2545 /* Check for V1 style functions */ | |
| 2546 if (!mtd->erase || | |
| 2547 !mtd->read || | |
| 2548 !mtd->write || | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2549 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17)) |
| 143 | 2550 !mtd->read_oob || !mtd->write_oob) { |
| 2551 #else | |
| 76 | 2552 !mtd->write_ecc || |
| 2553 !mtd->read_ecc || !mtd->read_oob || !mtd->write_oob) { | |
| 143 | 2554 #endif |
| 76 | 2555 T(YAFFS_TRACE_ALWAYS, |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2556 (TSTR("yaffs: MTD device does not support required " |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2557 "functions\n"))); |
| 76 | 2558 return NULL; |
| 2559 } | |
| 2560 | |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2561 if (WRITE_SIZE(mtd) < YAFFS_BYTES_PER_CHUNK || |
| 76 | 2562 mtd->oobsize != YAFFS_BYTES_PER_SPARE) { |
| 2563 T(YAFFS_TRACE_ALWAYS, | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2564 (TSTR("yaffs: MTD device does not support have the " |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2565 "right page sizes\n"))); |
|
59
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
2566 return NULL; |
|
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
2567 } |
|
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
2568 } |
| 7 | 2569 |
| 76 | 2570 /* OK, so if we got here, we have an MTD that's NAND and looks |
| 2571 * like it has the right capabilities | |
| 2572 * Set the yaffs_Device up for mtd | |
| 2573 */ | |
| 7 | 2574 |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2575 dev = kmalloc(sizeof(yaffs_Device), GFP_KERNEL); |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2576 context = kmalloc(sizeof(struct yaffs_LinuxContext),GFP_KERNEL); |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2577 |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2578 if(!dev || !context ){ |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2579 if(dev) |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2580 kfree(dev); |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2581 if(context) |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2582 kfree(context); |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2583 dev = NULL; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2584 context = NULL; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2585 } |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2586 |
| 76 | 2587 if (!dev) { |
| 2588 /* Deep shit could not allocate device structure */ | |
| 2589 T(YAFFS_TRACE_ALWAYS, | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2590 (TSTR("yaffs_read_super: Failed trying to allocate " |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2591 "yaffs_Device. \n"))); |
|
59
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
2592 return NULL; |
|
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
2593 } |
| 76 | 2594 memset(dev, 0, sizeof(yaffs_Device)); |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2595 param = &(dev->param); |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2596 |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2597 memset(context,0,sizeof(struct yaffs_LinuxContext)); |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2598 dev->context = context; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2599 YINIT_LIST_HEAD(&(context->contextList)); |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2600 context->dev = dev; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2601 context->superBlock = sb; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2602 |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2603 |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2604 |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2605 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0)) |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2606 sb->s_fs_info = dev; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2607 #else |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2608 sb->u.generic_sbp = dev; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2609 #endif |
|
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 yaffs_DeviceToContext(dev)->mtd = mtd; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2612 param->name = mtd->name; |
| 7 | 2613 |
| 76 | 2614 /* Set up the memory size parameters.... */ |
| 2615 | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2616 nBlocks = YCALCBLOCKS(mtd->size, (YAFFS_CHUNKS_PER_BLOCK * YAFFS_BYTES_PER_CHUNK)); |
| 266 | 2617 |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2618 param->startBlock = 0; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2619 param->endBlock = nBlocks - 1; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2620 param->nChunksPerBlock = YAFFS_CHUNKS_PER_BLOCK; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2621 param->totalBytesPerChunk = YAFFS_BYTES_PER_CHUNK; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2622 param->nReservedBlocks = 5; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2623 param->nShortOpCaches = (options.no_cache) ? 0 : 10; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2624 param->inbandTags = options.inband_tags; |
| 7 | 2625 |
|
303
a9dda7e5b822
Runtime disbale of lazy loading. Fix problem where resize was breading rename shadowing
charles <charles>
parents:
300
diff
changeset
|
2626 #ifdef CONFIG_YAFFS_DISABLE_LAZY_LOAD |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2627 param->disableLazyLoad = 1; |
|
303
a9dda7e5b822
Runtime disbale of lazy loading. Fix problem where resize was breading rename shadowing
charles <charles>
parents:
300
diff
changeset
|
2628 #endif |
| 311 | 2629 if(options.lazy_loading_overridden) |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2630 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
|
2631 |
| 300 | 2632 #ifdef CONFIG_YAFFS_DISABLE_TAGS_ECC |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2633 param->noTagsECC = 1; |
| 300 | 2634 #endif |
|
372
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2635 |
|
374
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
2636 #ifdef CONFIG_YAFFS_DISABLE_BACKGROUND |
|
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
2637 #else |
|
372
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2638 param->deferDirectoryUpdate = 1; |
|
374
043bd07468b6
Add conditional compilation for background processing
charles <charles>
parents:
372
diff
changeset
|
2639 #endif |
|
372
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2640 |
| 300 | 2641 if(options.tags_ecc_overridden) |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2642 param->noTagsECC = !options.tags_ecc_on; |
| 300 | 2643 |
| 311 | 2644 #ifdef CONFIG_YAFFS_EMPTY_LOST_AND_FOUND |
| 361 | 2645 param->emptyLostAndFound = 1; |
| 311 | 2646 #endif |
| 365 | 2647 |
| 2648 #ifdef CONFIG_YAFFS_DISABLE_BLOCK_REFRESHING | |
| 2649 param->refreshPeriod = 0; | |
| 2650 #else | |
|
418
ff48885b11fb
yaffs: Improve debug chunk erased checking, change refreshPeriod
Charles Manning <cdhmanning@gmail.com>
parents:
409
diff
changeset
|
2651 param->refreshPeriod = 500; |
| 365 | 2652 #endif |
| 2653 | |
| 311 | 2654 if(options.empty_lost_and_found_overridden) |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2655 param->emptyLostAndFound = options.empty_lost_and_found; |
| 311 | 2656 |
| 76 | 2657 /* ... and the functions. */ |
| 2658 if (yaffsVersion == 2) { | |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2659 param->writeChunkWithTagsToNAND = |
| 76 | 2660 nandmtd2_WriteChunkWithTagsToNAND; |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2661 param->readChunkWithTagsFromNAND = |
| 76 | 2662 nandmtd2_ReadChunkWithTagsFromNAND; |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2663 param->markNANDBlockBad = nandmtd2_MarkNANDBlockBad; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2664 param->queryNANDBlock = nandmtd2_QueryNANDBlock; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2665 yaffs_DeviceToContext(dev)->spareBuffer = YMALLOC(mtd->oobsize); |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2666 param->isYaffs2 = 1; |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2667 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17)) |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2668 param->totalBytesPerChunk = mtd->writesize; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2669 param->nChunksPerBlock = mtd->erasesize / mtd->writesize; |
| 143 | 2670 #else |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2671 param->totalBytesPerChunk = mtd->oobblock; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2672 param->nChunksPerBlock = mtd->erasesize / mtd->oobblock; |
| 143 | 2673 #endif |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2674 nBlocks = YCALCBLOCKS(mtd->size, mtd->erasesize); |
| 131 | 2675 |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2676 param->startBlock = 0; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2677 param->endBlock = nBlocks - 1; |
| 76 | 2678 } else { |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2679 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17)) |
| 179 | 2680 /* use the MTD interface in yaffs_mtdif1.c */ |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2681 param->writeChunkWithTagsToNAND = |
| 179 | 2682 nandmtd1_WriteChunkWithTagsToNAND; |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2683 param->readChunkWithTagsFromNAND = |
| 179 | 2684 nandmtd1_ReadChunkWithTagsFromNAND; |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2685 param->markNANDBlockBad = nandmtd1_MarkNANDBlockBad; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2686 param->queryNANDBlock = nandmtd1_QueryNANDBlock; |
| 179 | 2687 #else |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2688 param->writeChunkToNAND = nandmtd_WriteChunkToNAND; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2689 param->readChunkFromNAND = nandmtd_ReadChunkFromNAND; |
| 179 | 2690 #endif |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2691 param->isYaffs2 = 0; |
|
59
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
2692 } |
| 76 | 2693 /* ... and common functions */ |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2694 param->eraseBlockInNAND = nandmtd_EraseBlockInNAND; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2695 param->initialiseNAND = nandmtd_InitialiseNAND; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2696 |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2697 yaffs_DeviceToContext(dev)->putSuperFunc = yaffs_MTDPutSuper; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2698 |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2699 param->markSuperBlockDirty = yaffs_MarkSuperBlockDirty; |
| 388 | 2700 param->gcControl = yaffs_gc_control_callback; |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2701 |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2702 yaffs_DeviceToContext(dev)->superBlock= sb; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2703 |
| 76 | 2704 |
|
61
49f66fca0b09
newconfig: use YAFFS_DOES_ECC instead of USE_NANDECC
luc <luc>
parents:
59
diff
changeset
|
2705 #ifndef CONFIG_YAFFS_DOES_ECC |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2706 param->useNANDECC = 1; |
| 7 | 2707 #endif |
| 2708 | |
| 104 | 2709 #ifdef CONFIG_YAFFS_DISABLE_WIDE_TNODES |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2710 param->wideTnodesDisabled = 1; |
| 104 | 2711 #endif |
| 2712 | |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2713 param->skipCheckpointRead = options.skip_checkpoint_read; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2714 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
|
2715 |
| 27 | 2716 /* 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
|
2717 down(&yaffs_context_lock); |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2718 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
|
2719 up(&yaffs_context_lock); |
|
320
37b5b3fda7c0
Revert readdir locking fix that doesn't work properly
charles <charles>
parents:
319
diff
changeset
|
2720 |
| 321 | 2721 /* Directory search handling...*/ |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2722 YINIT_LIST_HEAD(&(yaffs_DeviceToContext(dev)->searchContexts)); |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2723 param->removeObjectCallback = yaffs_RemoveObjectCallback; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2724 |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2725 init_MUTEX(&(yaffs_DeviceToContext(dev)->grossLock)); |
|
320
37b5b3fda7c0
Revert readdir locking fix that doesn't work properly
charles <charles>
parents:
319
diff
changeset
|
2726 |
| 7 | 2727 yaffs_GrossLock(dev); |
| 76 | 2728 |
| 7 | 2729 err = yaffs_GutsInitialise(dev); |
| 2730 | |
| 76 | 2731 T(YAFFS_TRACE_OS, |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2732 (TSTR("yaffs_read_super: guts initialised %s\n"), |
| 76 | 2733 (err == YAFFS_OK) ? "OK" : "FAILED")); |
|
372
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2734 |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2735 if(err == YAFFS_OK) |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2736 yaffs_BackgroundStart(dev); |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2737 |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2738 if(!context->bgThread) |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2739 param->deferDirectoryUpdate = 0; |
|
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
2740 |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
2741 |
|
106
5b8f68c30468
Apply Reed's deadlocking fix (manually applied)
charles <charles>
parents:
104
diff
changeset
|
2742 /* Release lock before yaffs_get_inode() */ |
|
5b8f68c30468
Apply Reed's deadlocking fix (manually applied)
charles <charles>
parents:
104
diff
changeset
|
2743 yaffs_GrossUnlock(dev); |
| 7 | 2744 |
| 76 | 2745 /* Create root inode */ |
| 2746 if (err == YAFFS_OK) | |
| 2747 inode = yaffs_get_inode(sb, S_IFDIR | 0755, 0, | |
| 2748 yaffs_Root(dev)); | |
| 7 | 2749 |
| 2750 if (!inode) | |
| 2751 return NULL; | |
| 2752 | |
| 76 | 2753 inode->i_op = &yaffs_dir_inode_operations; |
| 2754 inode->i_fop = &yaffs_dir_operations; | |
| 2755 | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2756 T(YAFFS_TRACE_OS, (TSTR("yaffs_read_super: got root inode\n"))); |
| 7 | 2757 |
| 2758 root = d_alloc_root(inode); | |
| 2759 | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2760 T(YAFFS_TRACE_OS, (TSTR("yaffs_read_super: d_alloc_root done\n"))); |
| 7 | 2761 |
| 2762 if (!root) { | |
| 2763 iput(inode); | |
| 2764 return NULL; | |
| 2765 } | |
| 2766 sb->s_root = root; | |
| 249 | 2767 sb->s_dirt = !dev->isCheckpointed; |
| 2768 T(YAFFS_TRACE_ALWAYS, | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2769 (TSTR("yaffs_read_super: isCheckpointed %d\n"), |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2770 dev->isCheckpointed)); |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2771 |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2772 T(YAFFS_TRACE_OS, (TSTR("yaffs_read_super: done\n"))); |
| 7 | 2773 return sb; |
| 2774 } | |
| 2775 | |
|
32
e344a10a3a1e
Move the internals read_super() functions near the declaration of
luc <luc>
parents:
29
diff
changeset
|
2776 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2777 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0)) |
| 76 | 2778 static int yaffs_internal_read_super_mtd(struct super_block *sb, void *data, |
| 2779 int silent) | |
| 7 | 2780 { |
| 95 | 2781 return yaffs_internal_read_super(1, sb, data, silent) ? 0 : -EINVAL; |
| 7 | 2782 } |
| 2783 | |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2784 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17)) |
| 143 | 2785 static int yaffs_read_super(struct file_system_type *fs, |
| 2786 int flags, const char *dev_name, | |
| 2787 void *data, struct vfsmount *mnt) | |
| 2788 { | |
| 2789 | |
| 2790 return get_sb_bdev(fs, flags, dev_name, data, | |
| 2791 yaffs_internal_read_super_mtd, mnt); | |
| 2792 } | |
| 2793 #else | |
| 76 | 2794 static struct super_block *yaffs_read_super(struct file_system_type *fs, |
| 2795 int flags, const char *dev_name, | |
| 2796 void *data) | |
| 7 | 2797 { |
| 2798 | |
| 76 | 2799 return get_sb_bdev(fs, flags, dev_name, data, |
| 2800 yaffs_internal_read_super_mtd); | |
| 7 | 2801 } |
| 143 | 2802 #endif |
| 7 | 2803 |
| 2804 static struct file_system_type yaffs_fs_type = { | |
| 76 | 2805 .owner = THIS_MODULE, |
| 2806 .name = "yaffs", | |
| 2807 .get_sb = yaffs_read_super, | |
| 2808 .kill_sb = kill_block_super, | |
| 2809 .fs_flags = FS_REQUIRES_DEV, | |
| 7 | 2810 }; |
| 2811 #else | |
| 76 | 2812 static struct super_block *yaffs_read_super(struct super_block *sb, void *data, |
| 2813 int silent) | |
| 7 | 2814 { |
| 76 | 2815 return yaffs_internal_read_super(1, sb, data, silent); |
| 7 | 2816 } |
| 2817 | |
| 76 | 2818 static DECLARE_FSTYPE(yaffs_fs_type, "yaffs", yaffs_read_super, |
| 2819 FS_REQUIRES_DEV); | |
| 7 | 2820 #endif |
| 2821 | |
| 2822 | |
| 49 | 2823 #ifdef CONFIG_YAFFS_YAFFS2 |
| 7 | 2824 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2825 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0)) |
| 76 | 2826 static int yaffs2_internal_read_super_mtd(struct super_block *sb, void *data, |
| 2827 int silent) | |
|
32
e344a10a3a1e
Move the internals read_super() functions near the declaration of
luc <luc>
parents:
29
diff
changeset
|
2828 { |
| 95 | 2829 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
|
2830 } |
|
e344a10a3a1e
Move the internals read_super() functions near the declaration of
luc <luc>
parents:
29
diff
changeset
|
2831 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
2832 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17)) |
| 143 | 2833 static int yaffs2_read_super(struct file_system_type *fs, |
| 2834 int flags, const char *dev_name, void *data, | |
| 2835 struct vfsmount *mnt) | |
| 2836 { | |
| 2837 return get_sb_bdev(fs, flags, dev_name, data, | |
| 2838 yaffs2_internal_read_super_mtd, mnt); | |
| 2839 } | |
| 2840 #else | |
| 76 | 2841 static struct super_block *yaffs2_read_super(struct file_system_type *fs, |
| 2842 int flags, const char *dev_name, | |
| 2843 void *data) | |
| 7 | 2844 { |
| 2845 | |
| 76 | 2846 return get_sb_bdev(fs, flags, dev_name, data, |
| 2847 yaffs2_internal_read_super_mtd); | |
| 7 | 2848 } |
| 143 | 2849 #endif |
| 7 | 2850 |
| 2851 static struct file_system_type yaffs2_fs_type = { | |
| 76 | 2852 .owner = THIS_MODULE, |
| 2853 .name = "yaffs2", | |
| 2854 .get_sb = yaffs2_read_super, | |
| 2855 .kill_sb = kill_block_super, | |
| 2856 .fs_flags = FS_REQUIRES_DEV, | |
| 7 | 2857 }; |
| 2858 #else | |
| 76 | 2859 static struct super_block *yaffs2_read_super(struct super_block *sb, |
| 2860 void *data, int silent) | |
| 7 | 2861 { |
| 76 | 2862 return yaffs_internal_read_super(2, sb, data, silent); |
| 7 | 2863 } |
| 2864 | |
| 76 | 2865 static DECLARE_FSTYPE(yaffs2_fs_type, "yaffs2", yaffs2_read_super, |
| 2866 FS_REQUIRES_DEV); | |
| 7 | 2867 #endif |
| 2868 | |
| 76 | 2869 #endif /* CONFIG_YAFFS_YAFFS2 */ |
| 7 | 2870 |
| 2871 static struct proc_dir_entry *my_proc_entry; | |
|
385
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
2872 static struct proc_dir_entry *debug_proc_entry; |
| 7 | 2873 |
| 311 | 2874 static char *yaffs_dump_dev_part0(char *buf, yaffs_Device * dev) |
| 7 | 2875 { |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2876 buf += sprintf(buf, "startBlock......... %d\n", dev->param.startBlock); |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2877 buf += sprintf(buf, "endBlock........... %d\n", dev->param.endBlock); |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2878 buf += sprintf(buf, "totalBytesPerChunk. %d\n", dev->param.totalBytesPerChunk); |
| 365 | 2879 buf += sprintf(buf, "useNANDECC......... %d\n", dev->param.useNANDECC); |
| 2880 buf += sprintf(buf, "noTagsECC.......... %d\n", dev->param.noTagsECC); | |
| 2881 buf += sprintf(buf, "isYaffs2........... %d\n", dev->param.isYaffs2); | |
| 2882 buf += sprintf(buf, "inbandTags......... %d\n", dev->param.inbandTags); | |
| 2883 buf += sprintf(buf, "emptyLostAndFound.. %d\n", dev->param.emptyLostAndFound); | |
| 2884 buf += sprintf(buf, "disableLazyLoad.... %d\n", dev->param.disableLazyLoad); | |
| 2885 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
|
2886 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
|
2887 buf += sprintf(buf, "nReservedBlocks.... %d\n", dev->param.nReservedBlocks); |
| 365 | 2888 |
| 2889 buf += sprintf(buf, "\n"); | |
| 2890 | |
| 2891 return buf; | |
| 2892 } | |
| 2893 | |
| 2894 | |
| 2895 static char *yaffs_dump_dev_part1(char *buf, yaffs_Device * dev) | |
| 2896 { | |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2897 buf += sprintf(buf, "nDataBytesPerChunk. %d\n", dev->nDataBytesPerChunk); |
| 76 | 2898 buf += sprintf(buf, "chunkGroupBits..... %d\n", dev->chunkGroupBits); |
| 2899 buf += sprintf(buf, "chunkGroupSize..... %d\n", dev->chunkGroupSize); | |
| 2900 buf += sprintf(buf, "nErasedBlocks...... %d\n", dev->nErasedBlocks); | |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
2901 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
|
2902 buf += sprintf(buf, "\n"); |
| 76 | 2903 buf += sprintf(buf, "nTnodesCreated..... %d\n", dev->nTnodesCreated); |
| 2904 buf += sprintf(buf, "nFreeTnodes........ %d\n", dev->nFreeTnodes); | |
| 2905 buf += sprintf(buf, "nObjectsCreated.... %d\n", dev->nObjectsCreated); | |
| 2906 buf += sprintf(buf, "nFreeObjects....... %d\n", dev->nFreeObjects); | |
| 2907 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
|
2908 buf += sprintf(buf, "\n"); |
|
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2909 buf += sprintf(buf, "nPageWrites........ %u\n", dev->nPageWrites); |
|
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2910 buf += sprintf(buf, "nPageReads......... %u\n", dev->nPageReads); |
|
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2911 buf += sprintf(buf, "nBlockErasures..... %u\n", dev->nBlockErasures); |
|
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2912 buf += sprintf(buf, "nGCCopies.......... %u\n", dev->nGCCopies); |
|
404
792f3d959342
yaffs: More background gc tweaks.
Charles Manning <cdhmanning@gmail.com>
parents:
403
diff
changeset
|
2913 buf += sprintf(buf, "allGCs............. %u\n", dev->allGCs); |
|
792f3d959342
yaffs: More background gc tweaks.
Charles Manning <cdhmanning@gmail.com>
parents:
403
diff
changeset
|
2914 buf += sprintf(buf, "passiveGCs......... %u\n", dev->passiveGCs); |
|
792f3d959342
yaffs: More background gc tweaks.
Charles Manning <cdhmanning@gmail.com>
parents:
403
diff
changeset
|
2915 buf += sprintf(buf, "oldestDirtyGCs..... %u\n", dev->oldestDirtyGCs); |
|
792f3d959342
yaffs: More background gc tweaks.
Charles Manning <cdhmanning@gmail.com>
parents:
403
diff
changeset
|
2916 buf += sprintf(buf, "backgroundGCs...... %u\n", dev->backgroundGCs); |
|
384
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2917 buf += sprintf(buf, "nRetriedWrites..... %u\n", dev->nRetriedWrites); |
|
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2918 buf += sprintf(buf, "nRetireBlocks...... %u\n", dev->nRetiredBlocks); |
|
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2919 buf += sprintf(buf, "eccFixed........... %u\n", dev->eccFixed); |
|
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2920 buf += sprintf(buf, "eccUnfixed......... %u\n", dev->eccUnfixed); |
|
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2921 buf += sprintf(buf, "tagsEccFixed....... %u\n", dev->tagsEccFixed); |
|
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2922 buf += sprintf(buf, "tagsEccUnfixed..... %u\n", dev->tagsEccUnfixed); |
|
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2923 buf += sprintf(buf, "cacheHits.......... %u\n", dev->cacheHits); |
|
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2924 buf += sprintf(buf, "nDeletedFiles...... %u\n", dev->nDeletedFiles); |
|
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2925 buf += sprintf(buf, "nUnlinkedFiles..... %u\n", dev->nUnlinkedFiles); |
|
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2926 buf += sprintf(buf, "refreshCount....... %u\n", dev->refreshCount); |
| 76 | 2927 buf += |
|
384
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2928 sprintf(buf, "nBackgroudDeletions %u\n", dev->nBackgroundDeletions); |
| 311 | 2929 |
| 2930 return buf; | |
| 2931 } | |
| 2932 | |
| 76 | 2933 static int yaffs_proc_read(char *page, |
| 2934 char **start, | |
| 2935 off_t offset, int count, int *eof, void *data) | |
| 7 | 2936 { |
|
210
8a4f31e59ad8
Some cleanups, Linux 2.6.25 handling, fix handing of root permissions
charles <charles>
parents:
204
diff
changeset
|
2937 struct ylist_head *item; |
| 27 | 2938 char *buf = page; |
| 2939 int step = offset; | |
| 2940 int n = 0; | |
| 7 | 2941 |
| 27 | 2942 /* Get proc_file_read() to step 'offset' by one on each sucessive call. |
| 2943 * We use 'offset' (*ppos) to indicate where we are in devList. | |
| 2944 * This also assumes the user has posted a read buffer large | |
| 2945 * enough to hold the complete output; but that's life in /proc. | |
| 2946 */ | |
| 7 | 2947 |
| 27 | 2948 *(int *)start = 1; |
| 2949 | |
| 2950 /* Print header first */ | |
| 311 | 2951 if (step == 0) |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2952 buf += sprintf(buf, "YAFFS built:" __DATE__ " " __TIME__"\n"); |
| 311 | 2953 else if (step == 1) |
| 2954 buf += sprintf(buf,"\n"); | |
| 2955 else { | |
| 2956 step-=2; | |
| 2957 | |
|
384
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2958 down(&yaffs_context_lock); |
| 311 | 2959 |
| 2960 /* 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
|
2961 ylist_for_each(item, &yaffs_context_list) { |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2962 struct yaffs_LinuxContext *dc = ylist_entry(item, struct yaffs_LinuxContext, contextList); |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2963 yaffs_Device *dev = dc->dev; |
|
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2964 |
| 311 | 2965 if (n < (step & ~1)) { |
| 2966 n+=2; | |
| 2967 continue; | |
| 2968 } | |
| 2969 if((step & 1)==0){ | |
|
356
7ee0cc4ba753
Rationalise context and parameter handling
charles <charles>
parents:
350
diff
changeset
|
2970 buf += sprintf(buf, "\nDevice %d \"%s\"\n", n, dev->param.name); |
| 311 | 2971 buf = yaffs_dump_dev_part0(buf, dev); |
| 2972 } else | |
| 2973 buf = yaffs_dump_dev_part1(buf, dev); | |
| 2974 | |
| 2975 break; | |
| 2976 } | |
|
384
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
2977 up(&yaffs_context_lock); |
| 27 | 2978 } |
| 7 | 2979 |
| 76 | 2980 return buf - page < count ? buf - page : count; |
| 7 | 2981 } |
| 2982 | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
2983 static int yaffs_stats_proc_read(char *page, |
|
385
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
2984 char **start, |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
2985 off_t offset, int count, int *eof, void *data) |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
2986 { |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
2987 struct ylist_head *item; |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
2988 char *buf = page; |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
2989 int n = 0; |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
2990 |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
2991 down(&yaffs_context_lock); |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
2992 |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
2993 /* 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
|
2994 ylist_for_each(item, &yaffs_context_list) { |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
2995 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
|
2996 yaffs_Device *dev = dc->dev; |
| 387 | 2997 |
| 2998 int erasedChunks; | |
| 2999 int nObjects; | |
| 3000 int nTnodes; | |
| 3001 | |
| 3002 erasedChunks = dev->nErasedBlocks * dev->param.nChunksPerBlock; | |
| 3003 nObjects = dev->nObjectsCreated -dev->nFreeObjects; | |
| 3004 nTnodes = dev->nTnodesCreated - dev->nFreeTnodes; | |
|
385
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
3005 |
| 387 | 3006 |
|
404
792f3d959342
yaffs: More background gc tweaks.
Charles Manning <cdhmanning@gmail.com>
parents:
403
diff
changeset
|
3007 buf += sprintf(buf,"%d, %d, %d, %u, %u, %d, %d\n", |
| 387 | 3008 n, dev->nFreeChunks, erasedChunks, |
|
404
792f3d959342
yaffs: More background gc tweaks.
Charles Manning <cdhmanning@gmail.com>
parents:
403
diff
changeset
|
3009 dev->backgroundGCs, dev->oldestDirtyGCs, |
| 387 | 3010 nObjects, nTnodes); |
|
385
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
3011 } |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
3012 up(&yaffs_context_lock); |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
3013 |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
3014 |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
3015 return buf - page < count ? buf - page : count; |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
3016 } |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
3017 |
|
115
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 * 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
|
3020 * |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
3021 * 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
|
3022 */ |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3023 |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3024 static struct { |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3025 char *mask_name; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3026 unsigned mask_bitfield; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3027 } mask_flags[] = { |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3028 {"allocate", YAFFS_TRACE_ALLOCATE}, |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3029 {"always", YAFFS_TRACE_ALWAYS}, |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
3030 {"background", YAFFS_TRACE_BACKGROUND}, |
|
115
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3031 {"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
|
3032 {"buffers", YAFFS_TRACE_BUFFERS}, |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3033 {"bug", YAFFS_TRACE_BUG}, |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
3034 {"checkpt", YAFFS_TRACE_CHECKPOINT}, |
|
115
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3035 {"deletion", YAFFS_TRACE_DELETION}, |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3036 {"erase", YAFFS_TRACE_ERASE}, |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3037 {"error", YAFFS_TRACE_ERROR}, |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3038 {"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
|
3039 {"gc", YAFFS_TRACE_GC}, |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
3040 {"lock", YAFFS_TRACE_LOCK}, |
|
115
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3041 {"mtd", YAFFS_TRACE_MTD}, |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3042 {"nandaccess", YAFFS_TRACE_NANDACCESS}, |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3043 {"os", YAFFS_TRACE_OS}, |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3044 {"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
|
3045 {"scan", YAFFS_TRACE_SCAN}, |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3046 {"tracing", YAFFS_TRACE_TRACING}, |
| 342 | 3047 {"sync", YAFFS_TRACE_SYNC}, |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
3048 {"write", YAFFS_TRACE_WRITE}, |
|
372
952d0cdd1cbc
Add background processing of updated directories
charles <charles>
parents:
365
diff
changeset
|
3049 |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
3050 {"verify", YAFFS_TRACE_VERIFY}, |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
3051 {"verify_nand", YAFFS_TRACE_VERIFY_NAND}, |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
3052 {"verify_full", YAFFS_TRACE_VERIFY_FULL}, |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
3053 {"verify_all", YAFFS_TRACE_VERIFY_ALL}, |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
3054 |
|
115
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3055 {"all", 0xffffffff}, |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3056 {"none", 0}, |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3057 {NULL, 0}, |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3058 }; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3059 |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
3060 #define MAX_MASK_NAME_LENGTH 40 |
| 311 | 3061 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
|
3062 unsigned long count, void *data) |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3063 { |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3064 unsigned rg = 0, mask_bitfield; |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
3065 char *end; |
|
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
3066 char *mask_name; |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
3067 const char *x; |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
3068 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
|
3069 int i; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3070 int done = 0; |
| 166 | 3071 int add, len = 0; |
|
115
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3072 int pos = 0; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3073 |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3074 rg = yaffs_traceMask; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3075 |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3076 while (!done && (pos < count)) { |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3077 done = 1; |
| 273 | 3078 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
|
3079 pos++; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3080 |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3081 switch (buf[pos]) { |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3082 case '+': |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3083 case '-': |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3084 case '=': |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3085 add = buf[pos]; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3086 pos++; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3087 break; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3088 |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3089 default: |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3090 add = ' '; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3091 break; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3092 } |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3093 mask_name = NULL; |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
3094 |
|
115
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3095 mask_bitfield = simple_strtoul(buf + pos, &end, 0); |
| 273 | 3096 |
|
115
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3097 if (end > buf + pos) { |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3098 mask_name = "numeral"; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3099 len = end - (buf + pos); |
|
188
62921764ba1b
Fix infinite loop when parsing numeric trace flags written to /proc/yaffs.
imcd <imcd>
parents:
179
diff
changeset
|
3100 pos += len; |
|
115
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3101 done = 0; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3102 } else { |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
3103 for (x = buf + pos, i = 0; |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
3104 (*x == '_' || (*x >= 'a' && *x <= 'z')) && |
|
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
3105 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
|
3106 substring[i] = *x; |
|
176
570d9d4cac30
Adding checkpoint and robustness improvements
charles <charles>
parents:
175
diff
changeset
|
3107 substring[i] = '\0'; |
|
198
b7f785925166
Cleanup patch - Remove all trailing whitespace and fix a few typos.
wookey <wookey>
parents:
196
diff
changeset
|
3108 |
|
115
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3109 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
|
3110 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
|
3111 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
|
3112 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
|
3113 done = 0; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3114 break; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3115 } |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3116 } |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3117 } |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3118 |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3119 if (mask_name != NULL) { |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3120 done = 0; |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
3121 switch (add) { |
|
115
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3122 case '-': |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3123 rg &= ~mask_bitfield; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3124 break; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3125 case '+': |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3126 rg |= mask_bitfield; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3127 break; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3128 case '=': |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3129 rg = mask_bitfield; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3130 break; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3131 default: |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3132 rg |= mask_bitfield; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3133 break; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3134 } |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3135 } |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3136 } |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3137 |
| 165 | 3138 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
|
3139 |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
3140 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
|
3141 |
|
115
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3142 if (rg & YAFFS_TRACE_ALWAYS) { |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3143 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
|
3144 char flag; |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
3145 flag = ((rg & mask_flags[i].mask_bitfield) == |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
3146 mask_flags[i].mask_bitfield) ? '+' : '-'; |
|
271
c0dfae9e8073
Major whitespace/style changes to match Linux checkpatch.pl code style
wookey <wookey>
parents:
268
diff
changeset
|
3147 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
|
3148 } |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3149 } |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3150 |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3151 return count; |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3152 } |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3153 |
| 311 | 3154 |
| 3155 static int yaffs_proc_write(struct file *file, const char *buf, | |
| 3156 unsigned long count, void *data) | |
| 3157 { | |
| 3158 return yaffs_proc_write_trace_options(file, buf, count, data); | |
| 3159 } | |
| 3160 | |
| 76 | 3161 /* Stuff to handle installation of file systems */ |
| 3162 struct file_system_to_install { | |
| 3163 struct file_system_type *fst; | |
| 3164 int installed; | |
| 7 | 3165 }; |
| 3166 | |
| 76 | 3167 static struct file_system_to_install fs_to_install[] = { |
| 3168 {&yaffs_fs_type, 0}, | |
| 3169 {&yaffs2_fs_type, 0}, | |
| 3170 {NULL, 0} | |
| 7 | 3171 }; |
| 3172 | |
| 3173 static int __init init_yaffs_fs(void) | |
| 3174 { | |
| 3175 int error = 0; | |
| 76 | 3176 struct file_system_to_install *fsinst; |
| 7 | 3177 |
| 76 | 3178 T(YAFFS_TRACE_ALWAYS, |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
3179 (TSTR("yaffs built " __DATE__ " " __TIME__ " Installing. \n"))); |
| 7 | 3180 |
|
418
ff48885b11fb
yaffs: Improve debug chunk erased checking, change refreshPeriod
Charles Manning <cdhmanning@gmail.com>
parents:
409
diff
changeset
|
3181 #ifdef CONFIG_YAFFS_ALWAYS_CHECK_CHUNK_ERASED |
|
ff48885b11fb
yaffs: Improve debug chunk erased checking, change refreshPeriod
Charles Manning <cdhmanning@gmail.com>
parents:
409
diff
changeset
|
3182 T(YAFFS_TRACE_ALWAYS, |
|
ff48885b11fb
yaffs: Improve debug chunk erased checking, change refreshPeriod
Charles Manning <cdhmanning@gmail.com>
parents:
409
diff
changeset
|
3183 (TSTR(" \n\n\n\nYAFFS-WARNING CONFIG_YAFFS_ALWAYS_CHECK_CHUNK_ERASED selected.\n\n\n\n"))); |
|
ff48885b11fb
yaffs: Improve debug chunk erased checking, change refreshPeriod
Charles Manning <cdhmanning@gmail.com>
parents:
409
diff
changeset
|
3184 #endif |
|
ff48885b11fb
yaffs: Improve debug chunk erased checking, change refreshPeriod
Charles Manning <cdhmanning@gmail.com>
parents:
409
diff
changeset
|
3185 |
|
ff48885b11fb
yaffs: Improve debug chunk erased checking, change refreshPeriod
Charles Manning <cdhmanning@gmail.com>
parents:
409
diff
changeset
|
3186 |
|
ff48885b11fb
yaffs: Improve debug chunk erased checking, change refreshPeriod
Charles Manning <cdhmanning@gmail.com>
parents:
409
diff
changeset
|
3187 |
|
ff48885b11fb
yaffs: Improve debug chunk erased checking, change refreshPeriod
Charles Manning <cdhmanning@gmail.com>
parents:
409
diff
changeset
|
3188 |
|
384
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
3189 init_MUTEX(&yaffs_context_lock); |
|
c9e1700f2e05
Get rid of kernel lock, change stats to __u32
charles <charles>
parents:
374
diff
changeset
|
3190 |
|
385
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
3191 /* 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
|
3192 my_proc_entry = create_proc_entry("yaffs", |
| 76 | 3193 S_IRUGO | S_IFREG, |
|
212
0107f21a03fb
Fix compilation on Linux 2.6.26, fix compilation warnings
charles <charles>
parents:
210
diff
changeset
|
3194 YPROC_ROOT); |
|
115
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3195 |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3196 if (my_proc_entry) { |
|
06a072660af9
Add /proc interface for modifying debugging trace flags, from John M Cavallo.
tpoynor <tpoynor>
parents:
113
diff
changeset
|
3197 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
|
3198 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
|
3199 my_proc_entry->data = NULL; |
| 273 | 3200 } else |
| 76 | 3201 return -ENOMEM; |
| 3202 | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
3203 debug_proc_entry = create_proc_entry("yaffs_stats", |
|
385
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
3204 S_IRUGO | S_IFREG, |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
3205 YPROC_ROOT); |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
3206 |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
3207 if (debug_proc_entry) { |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
3208 debug_proc_entry->write_proc = NULL; |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
3209 debug_proc_entry->read_proc = yaffs_stats_proc_read; |
|
385
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
3210 debug_proc_entry->data = NULL; |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
3211 } else |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
3212 return -ENOMEM; |
|
d76a2de52a82
Add debug proc entry for gathering gc stats
charles <charles>
parents:
384
diff
changeset
|
3213 |
| 76 | 3214 /* Now add the file system entries */ |
| 3215 | |
| 3216 fsinst = fs_to_install; | |
| 7 | 3217 |
| 76 | 3218 while (fsinst->fst && !error) { |
| 3219 error = register_filesystem(fsinst->fst); | |
| 273 | 3220 if (!error) |
| 76 | 3221 fsinst->installed = 1; |
| 3222 fsinst++; | |
| 3223 } | |
| 3224 | |
| 3225 /* Any errors? uninstall */ | |
| 3226 if (error) { | |
| 3227 fsinst = fs_to_install; | |
| 3228 | |
| 3229 while (fsinst->fst) { | |
| 3230 if (fsinst->installed) { | |
| 3231 unregister_filesystem(fsinst->fst); | |
| 3232 fsinst->installed = 0; | |
| 3233 } | |
| 3234 fsinst++; | |
| 3235 } | |
| 3236 } | |
| 3237 | |
| 3238 return error; | |
| 7 | 3239 } |
| 3240 | |
| 3241 static void __exit exit_yaffs_fs(void) | |
| 3242 { | |
| 3243 | |
| 76 | 3244 struct file_system_to_install *fsinst; |
| 3245 | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
3246 T(YAFFS_TRACE_ALWAYS, |
|
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
3247 (TSTR("yaffs built " __DATE__ " " __TIME__ " removing. \n"))); |
| 76 | 3248 |
|
212
0107f21a03fb
Fix compilation on Linux 2.6.26, fix compilation warnings
charles <charles>
parents:
210
diff
changeset
|
3249 remove_proc_entry("yaffs", YPROC_ROOT); |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
3250 remove_proc_entry("yaffs_stats", YPROC_ROOT); |
| 7 | 3251 |
| 76 | 3252 fsinst = fs_to_install; |
| 3253 | |
| 3254 while (fsinst->fst) { | |
| 3255 if (fsinst->installed) { | |
| 3256 unregister_filesystem(fsinst->fst); | |
| 3257 fsinst->installed = 0; | |
| 3258 } | |
| 3259 fsinst++; | |
| 3260 } | |
| 7 | 3261 } |
| 3262 | |
| 3263 module_init(init_yaffs_fs) | |
| 3264 module_exit(exit_yaffs_fs) | |
| 3265 | |
| 3266 MODULE_DESCRIPTION("YAFFS2 - a NAND specific flash file system"); | |
|
409
b5309c9b6d7f
yaffs Some cleanups.
Charles Manning <cdhmanning@gmail.com>
parents:
407
diff
changeset
|
3267 MODULE_AUTHOR("Charles Manning, Aleph One Ltd., 2002-2010"); |
| 7 | 3268 MODULE_LICENSE("GPL"); |
