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