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