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