Mercurial > yaffs-ecoscentric-gpl
annotate yaffs_fs.c @ 109:b9876f8c4b48
Fix conditional
| author | charles <charles> |
|---|---|
| date | Thu, 15 Dec 2005 20:27:56 +0000 |
| parents | 4a8113f1c36b |
| children | 0f8838615001 |
| rev | line source |
|---|---|
| 7 | 1 /* |
| 2 * YAFFS: Yet another FFS. A NAND-flash specific file system. | |
| 3 * yaffs_fs.c | |
| 4 * | |
| 5 * Copyright (C) 2002 Aleph One Ltd. | |
| 6 * for Toby Churchill Ltd and Brightstar Engineering | |
| 7 * | |
| 8 * Created by Charles Manning <charles@aleph1.co.uk> | |
| 9 * | |
| 10 * This program is free software; you can redistribute it and/or modify | |
| 11 * it under the terms of the GNU General Public License version 2 as | |
| 12 * published by the Free Software Foundation. | |
| 13 * | |
| 14 * This is the file system front-end to YAFFS that hooks it up to | |
| 15 * the VFS. | |
| 16 * | |
| 17 * Special notes: | |
| 76 | 18 * >> 2.4: sb->u.generic_sbp points to the yaffs_Device associated with |
| 19 * this superblock | |
| 20 * >> 2.6: sb->s_fs_info points to the yaffs_Device associated with this | |
| 21 * superblock | |
| 7 | 22 * >> inode->u.generic_ip points to the associated yaffs_Object. |
| 23 * | |
| 24 * Acknowledgements: | |
| 25 * * Luc van OostenRyck for numerous patches. | |
| 26 * * Nick Bane for numerous patches. | |
| 27 * * Nick Bane for 2.5/2.6 integration. | |
| 28 * * Andras Toth for mknod rdev issue. | |
| 29 * * Michael Fischer for finding the problem with inode inconsistency. | |
| 30 * * Some code bodily lifted from JFFS2. | |
| 31 */ | |
| 32 | |
| 76 | 33 const char *yaffs_fs_c_version = |
| 109 | 34 "$Id: yaffs_fs.c,v 1.38 2005-12-15 20:27:56 charles Exp $"; |
| 7 | 35 extern const char *yaffs_guts_c_version; |
| 36 | |
| 37 #include <linux/config.h> | |
| 38 #include <linux/kernel.h> | |
| 39 #include <linux/module.h> | |
| 40 #include <linux/version.h> | |
| 41 #include <linux/slab.h> | |
| 42 #include <linux/init.h> | |
| 43 #include <linux/list.h> | |
| 44 #include <linux/fs.h> | |
| 45 #include <linux/proc_fs.h> | |
| 27 | 46 #include <linux/smp_lock.h> |
| 7 | 47 #include <linux/pagemap.h> |
| 48 #include <linux/mtd/mtd.h> | |
| 49 #include <linux/interrupt.h> | |
| 50 #include <linux/string.h> | |
| 51 | |
| 52 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) | |
| 53 | |
| 54 #include <linux/statfs.h> /* Added NCB 15-8-2003 */ | |
| 55 #include <asm/statfs.h> | |
| 56 #define UnlockPage(p) unlock_page(p) | |
| 57 #define Page_Uptodate(page) test_bit(PG_uptodate, &(page)->flags) | |
| 76 | 58 |
| 59 /* FIXME: use sb->s_id instead ? */ | |
| 60 #define yaffs_devname(sb, buf) bdevname(sb->s_bdev, buf) | |
| 7 | 61 |
| 62 #else | |
| 63 | |
| 64 #include <linux/locks.h> | |
|
37
843d9d0add74
Fix devname which was faked by always using "(unavailable)".
luc <luc>
parents:
36
diff
changeset
|
65 #define BDEVNAME_SIZE 0 |
|
843d9d0add74
Fix devname which was faked by always using "(unavailable)".
luc <luc>
parents:
36
diff
changeset
|
66 #define yaffs_devname(sb, buf) kdevname(sb->s_dev) |
| 7 | 67 |
| 68 #endif | |
| 69 | |
| 70 #include <asm/uaccess.h> | |
| 71 | |
| 72 #include "yportenv.h" | |
| 73 #include "yaffs_guts.h" | |
| 74 | |
| 83 | 75 unsigned yaffs_traceMask = YAFFS_TRACE_ALWAYS | YAFFS_TRACE_BAD_BLOCKS /* | 0xFFFFFFFF */; |
| 7 | 76 |
| 77 #include <linux/mtd/mtd.h> | |
| 78 #include "yaffs_mtdif.h" | |
| 79 #include "yaffs_mtdif2.h" | |
| 80 | |
| 76 | 81 /*#define T(x) printk x */ |
| 7 | 82 |
| 83 #define yaffs_InodeToObject(iptr) ((yaffs_Object *)((iptr)->u.generic_ip)) | |
| 84 #define yaffs_DentryToObject(dptr) yaffs_InodeToObject((dptr)->d_inode) | |
| 85 | |
| 86 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) | |
| 87 #define yaffs_SuperToDevice(sb) ((yaffs_Device *)sb->s_fs_info) | |
| 88 #else | |
| 89 #define yaffs_SuperToDevice(sb) ((yaffs_Device *)sb->u.generic_sbp) | |
| 90 #endif | |
| 91 | |
| 92 static void yaffs_put_super(struct super_block *sb); | |
| 93 | |
| 76 | 94 static ssize_t yaffs_file_write(struct file *f, const char *buf, size_t n, |
| 95 loff_t * pos); | |
| 7 | 96 |
| 76 | 97 static int yaffs_file_flush(struct file *file); |
| 7 | 98 |
| 76 | 99 static int yaffs_sync_object(struct file *file, struct dentry *dentry, |
| 100 int datasync); | |
| 7 | 101 |
| 102 static int yaffs_readdir(struct file *f, void *dirent, filldir_t filldir); | |
| 103 | |
| 104 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) | |
| 76 | 105 static int yaffs_create(struct inode *dir, struct dentry *dentry, int mode, |
| 106 struct nameidata *n); | |
| 107 static struct dentry *yaffs_lookup(struct inode *dir, struct dentry *dentry, | |
| 108 struct nameidata *n); | |
| 7 | 109 #else |
| 110 static int yaffs_create(struct inode *dir, struct dentry *dentry, int mode); | |
| 76 | 111 static struct dentry *yaffs_lookup(struct inode *dir, struct dentry *dentry); |
| 7 | 112 #endif |
| 76 | 113 static int yaffs_link(struct dentry *old_dentry, struct inode *dir, |
| 114 struct dentry *dentry); | |
| 115 static int yaffs_unlink(struct inode *dir, struct dentry *dentry); | |
| 116 static int yaffs_symlink(struct inode *dir, struct dentry *dentry, | |
| 117 const char *symname); | |
| 118 static int yaffs_mkdir(struct inode *dir, struct dentry *dentry, int mode); | |
| 7 | 119 |
| 120 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) | |
| 76 | 121 static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode, |
| 122 dev_t dev); | |
| 7 | 123 #else |
| 76 | 124 static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode, |
| 125 int dev); | |
| 7 | 126 #endif |
| 76 | 127 static int yaffs_rename(struct inode *old_dir, struct dentry *old_dentry, |
| 128 struct inode *new_dir, struct dentry *new_dentry); | |
| 7 | 129 static int yaffs_setattr(struct dentry *dentry, struct iattr *attr); |
| 130 | |
| 131 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) | |
| 132 static int yaffs_statfs(struct super_block *sb, struct kstatfs *buf); | |
| 133 #else | |
| 134 static int yaffs_statfs(struct super_block *sb, struct statfs *buf); | |
| 135 #endif | |
| 76 | 136 static void yaffs_read_inode(struct inode *inode); |
| 7 | 137 |
| 76 | 138 static void yaffs_put_inode(struct inode *inode); |
| 7 | 139 static void yaffs_delete_inode(struct inode *); |
| 140 static void yaffs_clear_inode(struct inode *); | |
| 141 | |
| 76 | 142 static int yaffs_readpage(struct file *file, struct page *page); |
| 23 | 143 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) |
| 144 static int yaffs_writepage(struct page *page, struct writeback_control *wbc); | |
| 145 #else | |
| 7 | 146 static int yaffs_writepage(struct page *page); |
| 23 | 147 #endif |
| 76 | 148 static int yaffs_prepare_write(struct file *f, struct page *pg, |
| 149 unsigned offset, unsigned to); | |
| 150 static int yaffs_commit_write(struct file *f, struct page *pg, unsigned offset, | |
| 151 unsigned to); | |
| 7 | 152 |
| 76 | 153 static int yaffs_readlink(struct dentry *dentry, char __user * buffer, |
| 154 int buflen); | |
| 99 | 155 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,13)) |
| 156 static void *yaffs_follow_link(struct dentry *dentry, struct nameidata *nd); | |
| 157 #else | |
| 7 | 158 static int yaffs_follow_link(struct dentry *dentry, struct nameidata *nd); |
| 99 | 159 #endif |
| 7 | 160 |
| 161 static struct address_space_operations yaffs_file_address_operations = { | |
| 76 | 162 .readpage = yaffs_readpage, |
| 163 .writepage = yaffs_writepage, | |
| 164 .prepare_write = yaffs_prepare_write, | |
| 165 .commit_write = yaffs_commit_write, | |
| 7 | 166 }; |
| 167 | |
| 168 static struct file_operations yaffs_file_operations = { | |
| 76 | 169 .read = generic_file_read, |
| 170 .write = generic_file_write, | |
| 171 .mmap = generic_file_mmap, | |
| 172 .flush = yaffs_file_flush, | |
| 173 .fsync = yaffs_sync_object, | |
| 7 | 174 }; |
| 175 | |
| 176 static struct inode_operations yaffs_file_inode_operations = { | |
| 76 | 177 .setattr = yaffs_setattr, |
| 7 | 178 }; |
| 179 | |
| 76 | 180 static struct inode_operations yaffs_symlink_inode_operations = { |
| 181 .readlink = yaffs_readlink, | |
| 182 .follow_link = yaffs_follow_link, | |
| 183 .setattr = yaffs_setattr, | |
| 7 | 184 }; |
| 185 | |
| 186 static struct inode_operations yaffs_dir_inode_operations = { | |
| 76 | 187 .create = yaffs_create, |
| 188 .lookup = yaffs_lookup, | |
| 189 .link = yaffs_link, | |
| 190 .unlink = yaffs_unlink, | |
| 191 .symlink = yaffs_symlink, | |
| 192 .mkdir = yaffs_mkdir, | |
| 193 .rmdir = yaffs_unlink, | |
| 194 .mknod = yaffs_mknod, | |
| 195 .rename = yaffs_rename, | |
| 196 .setattr = yaffs_setattr, | |
| 7 | 197 }; |
| 198 | |
| 199 static struct file_operations yaffs_dir_operations = { | |
| 76 | 200 .read = generic_read_dir, |
| 201 .readdir = yaffs_readdir, | |
| 202 .fsync = yaffs_sync_object, | |
| 7 | 203 }; |
| 204 | |
| 205 static struct super_operations yaffs_super_ops = { | |
| 76 | 206 .statfs = yaffs_statfs, |
| 207 .read_inode = yaffs_read_inode, | |
| 208 .put_inode = yaffs_put_inode, | |
| 209 .put_super = yaffs_put_super, | |
| 210 .delete_inode = yaffs_delete_inode, | |
| 211 .clear_inode = yaffs_clear_inode, | |
| 7 | 212 }; |
| 213 | |
| 76 | 214 static void yaffs_GrossLock(yaffs_Device * dev) |
| 7 | 215 { |
| 76 | 216 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs locking\n")); |
| 7 | 217 |
| 218 down(&dev->grossLock); | |
| 219 } | |
| 220 | |
| 76 | 221 static void yaffs_GrossUnlock(yaffs_Device * dev) |
| 7 | 222 { |
| 76 | 223 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs unlocking\n")); |
| 7 | 224 up(&dev->grossLock); |
| 225 | |
| 226 } | |
| 227 | |
| 76 | 228 static int yaffs_readlink(struct dentry *dentry, char __user * buffer, |
| 229 int buflen) | |
| 7 | 230 { |
| 231 unsigned char *alias; | |
| 232 int ret; | |
| 233 | |
| 234 yaffs_Device *dev = yaffs_DentryToObject(dentry)->myDev; | |
| 235 | |
| 76 | 236 yaffs_GrossLock(dev); |
| 7 | 237 |
| 238 alias = yaffs_GetSymlinkAlias(yaffs_DentryToObject(dentry)); | |
| 76 | 239 |
| 7 | 240 yaffs_GrossUnlock(dev); |
| 76 | 241 |
| 242 if (!alias) | |
| 7 | 243 return -ENOMEM; |
| 244 | |
| 245 ret = vfs_readlink(dentry, buffer, buflen, alias); | |
| 246 kfree(alias); | |
| 247 return ret; | |
| 248 } | |
| 249 | |
| 99 | 250 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,13)) |
| 251 static void *yaffs_follow_link(struct dentry *dentry, struct nameidata *nd) | |
| 252 #else | |
| 7 | 253 static int yaffs_follow_link(struct dentry *dentry, struct nameidata *nd) |
| 99 | 254 #endif |
| 7 | 255 { |
| 256 unsigned char *alias; | |
| 257 int ret; | |
| 258 yaffs_Device *dev = yaffs_DentryToObject(dentry)->myDev; | |
| 259 | |
| 260 yaffs_GrossLock(dev); | |
| 261 | |
| 262 alias = yaffs_GetSymlinkAlias(yaffs_DentryToObject(dentry)); | |
| 76 | 263 |
| 7 | 264 yaffs_GrossUnlock(dev); |
| 76 | 265 |
| 266 if (!alias) | |
| 99 | 267 { |
| 268 ret = -ENOMEM; | |
| 269 goto out; | |
| 270 } | |
| 7 | 271 |
| 76 | 272 ret = vfs_follow_link(nd, alias); |
| 7 | 273 kfree(alias); |
| 99 | 274 out: |
| 275 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,13)) | |
| 276 return ERR_PTR (ret); | |
| 277 #else | |
| 7 | 278 return ret; |
| 99 | 279 #endif |
| 7 | 280 } |
| 281 | |
| 76 | 282 struct inode *yaffs_get_inode(struct super_block *sb, int mode, int dev, |
| 283 yaffs_Object * obj); | |
| 7 | 284 |
| 285 /* | |
| 286 * Lookup is used to find objects in the fs | |
| 287 */ | |
| 288 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) | |
| 289 | |
| 76 | 290 static struct dentry *yaffs_lookup(struct inode *dir, struct dentry *dentry, |
| 291 struct nameidata *n) | |
| 7 | 292 #else |
| 76 | 293 static struct dentry *yaffs_lookup(struct inode *dir, struct dentry *dentry) |
| 7 | 294 #endif |
| 295 { | |
| 296 yaffs_Object *obj; | |
| 76 | 297 struct inode *inode = NULL; /* NCB 2.5/2.6 needs NULL here */ |
| 298 | |
| 7 | 299 yaffs_Device *dev = yaffs_InodeToObject(dir)->myDev; |
| 300 | |
| 301 yaffs_GrossLock(dev); | |
| 302 | |
| 76 | 303 T(YAFFS_TRACE_OS, |
| 304 (KERN_DEBUG "yaffs_lookup for %d:%s\n", | |
| 305 yaffs_InodeToObject(dir)->objectId, dentry->d_name.name)); | |
| 306 | |
| 307 obj = | |
| 308 yaffs_FindObjectByName(yaffs_InodeToObject(dir), | |
| 309 dentry->d_name.name); | |
| 310 | |
| 311 obj = yaffs_GetEquivalentObject(obj); /* in case it was a hardlink */ | |
|
106
5b8f68c30468
Apply Reed's deadlocking fix (manually applied)
charles <charles>
parents:
104
diff
changeset
|
312 |
|
5b8f68c30468
Apply Reed's deadlocking fix (manually applied)
charles <charles>
parents:
104
diff
changeset
|
313 /* Can't hold gross lock when calling yaffs_get_inode() */ |
|
5b8f68c30468
Apply Reed's deadlocking fix (manually applied)
charles <charles>
parents:
104
diff
changeset
|
314 yaffs_GrossUnlock(dev); |
| 7 | 315 |
| 76 | 316 if (obj) { |
| 317 T(YAFFS_TRACE_OS, | |
| 318 (KERN_DEBUG "yaffs_lookup found %d\n", obj->objectId)); | |
| 319 | |
| 320 inode = yaffs_get_inode(dir->i_sb, obj->yst_mode, 0, obj); | |
| 321 | |
| 322 if (inode) { | |
| 323 T(YAFFS_TRACE_OS, | |
| 324 (KERN_DEBUG "yaffs_loookup dentry \n")); | |
| 325 /* #if 0 asserted by NCB for 2.5/6 compatability - falls through to | |
| 326 * d_add even if NULL inode */ | |
| 7 | 327 #if 0 |
| 76 | 328 /*dget(dentry); // try to solve directory bug */ |
| 329 d_add(dentry, inode); | |
| 330 | |
| 331 /* return dentry; */ | |
| 7 | 332 return NULL; |
| 333 #endif | |
| 334 } | |
| 335 | |
| 76 | 336 } else { |
| 337 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_lookup not found\n")); | |
| 338 | |
| 7 | 339 } |
| 340 | |
| 76 | 341 /* added NCB for 2.5/6 compatability - forces add even if inode is |
| 342 * NULL which creates dentry hash */ | |
| 343 d_add(dentry, inode); | |
| 344 | |
| 7 | 345 return NULL; |
| 76 | 346 /* return (ERR_PTR(-EIO)); */ |
| 347 | |
| 7 | 348 } |
| 349 | |
| 76 | 350 /* For now put inode is just for debugging |
| 351 * Put inode is called when the inode **structure** is put. | |
| 352 */ | |
| 7 | 353 static void yaffs_put_inode(struct inode *inode) |
| 354 { | |
| 76 | 355 T(YAFFS_TRACE_OS, |
| 356 ("yaffs_put_inode: ino %d, count %d\n", (int)inode->i_ino, | |
| 357 atomic_read(&inode->i_count))); | |
| 358 | |
| 7 | 359 } |
| 360 | |
| 76 | 361 /* clear is called to tell the fs to release any per-inode data it holds */ |
| 7 | 362 static void yaffs_clear_inode(struct inode *inode) |
| 363 { | |
| 364 yaffs_Object *obj; | |
| 365 yaffs_Device *dev; | |
| 76 | 366 |
| 7 | 367 obj = yaffs_InodeToObject(inode); |
| 368 | |
| 76 | 369 T(YAFFS_TRACE_OS, |
| 370 ("yaffs_clear_inode: ino %d, count %d %s\n", (int)inode->i_ino, | |
| 371 atomic_read(&inode->i_count), | |
| 372 obj ? "object exists" : "null object")); | |
| 373 | |
| 374 if (obj) { | |
| 7 | 375 dev = obj->myDev; |
| 376 yaffs_GrossLock(dev); | |
| 76 | 377 |
| 378 /* Clear the association between the inode and | |
| 379 * the yaffs_Object. | |
| 380 */ | |
| 7 | 381 obj->myInode = NULL; |
| 382 inode->u.generic_ip = NULL; | |
| 76 | 383 |
| 384 /* If the object freeing was deferred, then the real | |
| 385 * free happens now. | |
| 386 * This should fix the inode inconsistency problem. | |
| 387 */ | |
| 388 | |
| 7 | 389 yaffs_HandleDeferedFree(obj); |
| 76 | 390 |
| 7 | 391 yaffs_GrossUnlock(dev); |
| 392 } | |
| 76 | 393 |
| 7 | 394 } |
| 395 | |
| 76 | 396 /* delete is called when the link count is zero and the inode |
| 397 * is put (ie. nobody wants to know about it anymore, time to | |
| 398 * delete the file). | |
| 399 * NB Must call clear_inode() | |
| 400 */ | |
| 7 | 401 static void yaffs_delete_inode(struct inode *inode) |
| 402 { | |
| 403 yaffs_Object *obj = yaffs_InodeToObject(inode); | |
| 404 yaffs_Device *dev; | |
| 405 | |
| 76 | 406 T(YAFFS_TRACE_OS, |
| 407 ("yaffs_delete_inode: ino %d, count %d %s\n", (int)inode->i_ino, | |
| 408 atomic_read(&inode->i_count), | |
| 409 obj ? "object exists" : "null object")); | |
| 410 | |
| 411 if (obj) { | |
| 412 dev = obj->myDev; | |
| 7 | 413 yaffs_GrossLock(dev); |
| 414 yaffs_DeleteFile(obj); | |
| 415 yaffs_GrossUnlock(dev); | |
| 416 } | |
| 99 | 417 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,13)) |
| 418 truncate_inode_pages (&inode->i_data, 0); | |
| 419 #endif | |
| 7 | 420 clear_inode(inode); |
| 421 } | |
| 422 | |
| 76 | 423 static int yaffs_file_flush(struct file *file) |
| 7 | 424 { |
| 425 yaffs_Object *obj = yaffs_DentryToObject(file->f_dentry); | |
| 76 | 426 |
| 7 | 427 yaffs_Device *dev = obj->myDev; |
| 76 | 428 |
| 429 T(YAFFS_TRACE_OS, | |
| 430 (KERN_DEBUG "yaffs_file_flush object %d (%s)\n", obj->objectId, | |
| 431 obj->dirty ? "dirty" : "clean")); | |
| 7 | 432 |
| 433 yaffs_GrossLock(dev); | |
| 76 | 434 |
| 435 yaffs_FlushFile(obj, 1); | |
| 7 | 436 |
| 437 yaffs_GrossUnlock(dev); | |
| 438 | |
| 76 | 439 return 0; |
| 7 | 440 } |
| 441 | |
| 76 | 442 static int yaffs_readpage_nolock(struct file *f, struct page *pg) |
| 443 { | |
| 444 /* Lifted from jffs2 */ | |
| 7 | 445 |
| 446 yaffs_Object *obj; | |
| 447 unsigned char *pg_buf; | |
| 448 int ret; | |
| 449 | |
| 450 yaffs_Device *dev; | |
| 451 | |
| 76 | 452 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_readpage at %08x, size %08x\n", |
| 453 (unsigned)(pg->index << PAGE_CACHE_SHIFT), | |
| 454 (unsigned)PAGE_CACHE_SIZE)); | |
| 7 | 455 |
| 76 | 456 obj = yaffs_DentryToObject(f->f_dentry); |
| 7 | 457 |
| 458 dev = obj->myDev; | |
| 76 | 459 |
| 23 | 460 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) |
| 76 | 461 BUG_ON(!PageLocked(pg)); |
| 23 | 462 #else |
| 7 | 463 if (!PageLocked(pg)) |
| 76 | 464 PAGE_BUG(pg); |
| 23 | 465 #endif |
| 7 | 466 |
| 467 pg_buf = kmap(pg); | |
| 468 /* FIXME: Can kmap fail? */ | |
| 469 | |
| 470 yaffs_GrossLock(dev); | |
| 76 | 471 |
| 472 ret = | |
| 473 yaffs_ReadDataFromFile(obj, pg_buf, pg->index << PAGE_CACHE_SHIFT, | |
| 474 PAGE_CACHE_SIZE); | |
| 7 | 475 |
| 476 yaffs_GrossUnlock(dev); | |
| 76 | 477 |
| 478 if (ret >= 0) | |
| 479 ret = 0; | |
| 7 | 480 |
| 481 if (ret) { | |
| 482 ClearPageUptodate(pg); | |
| 483 SetPageError(pg); | |
| 484 } else { | |
| 485 SetPageUptodate(pg); | |
| 486 ClearPageError(pg); | |
| 487 } | |
| 488 | |
| 489 flush_dcache_page(pg); | |
| 490 kunmap(pg); | |
| 491 | |
| 76 | 492 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_readpage done\n")); |
| 7 | 493 return ret; |
| 494 } | |
| 495 | |
| 496 static int yaffs_readpage_unlock(struct file *f, struct page *pg) | |
| 497 { | |
| 76 | 498 int ret = yaffs_readpage_nolock(f, pg); |
| 7 | 499 UnlockPage(pg); |
| 500 return ret; | |
| 501 } | |
| 502 | |
| 76 | 503 static int yaffs_readpage(struct file *f, struct page *pg) |
| 7 | 504 { |
| 76 | 505 return yaffs_readpage_unlock(f, pg); |
| 7 | 506 } |
| 507 | |
| 76 | 508 /* writepage inspired by/stolen from smbfs */ |
| 7 | 509 |
| 23 | 510 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) |
| 511 static int yaffs_writepage(struct page *page, struct writeback_control *wbc) | |
| 512 #else | |
| 7 | 513 static int yaffs_writepage(struct page *page) |
| 23 | 514 #endif |
| 7 | 515 { |
| 516 struct address_space *mapping = page->mapping; | |
| 76 | 517 loff_t offset = (loff_t) page->index << PAGE_CACHE_SHIFT; |
| 7 | 518 struct inode *inode; |
| 519 unsigned long end_index; | |
| 520 char *buffer; | |
| 521 yaffs_Object *obj; | |
| 522 int nWritten = 0; | |
| 523 unsigned nBytes; | |
| 524 | |
| 525 if (!mapping) | |
| 526 BUG(); | |
| 527 inode = mapping->host; | |
| 528 if (!inode) | |
| 529 BUG(); | |
| 530 | |
| 76 | 531 if (offset > inode->i_size) { |
| 532 T(YAFFS_TRACE_OS, | |
| 533 (KERN_DEBUG | |
| 534 "yaffs_writepage at %08x, inode size = %08x!!!\n", | |
| 535 (unsigned)(page->index << PAGE_CACHE_SHIFT), | |
| 536 (unsigned)inode->i_size)); | |
| 537 T(YAFFS_TRACE_OS, | |
| 538 (KERN_DEBUG " -> don't care!!\n")); | |
|
67
cb8afec5ad31
Fix an error in writepage when a file is extended.
luc <luc>
parents:
61
diff
changeset
|
539 unlock_page(page); |
|
cb8afec5ad31
Fix an error in writepage when a file is extended.
luc <luc>
parents:
61
diff
changeset
|
540 return 0; |
|
cb8afec5ad31
Fix an error in writepage when a file is extended.
luc <luc>
parents:
61
diff
changeset
|
541 } |
|
cb8afec5ad31
Fix an error in writepage when a file is extended.
luc <luc>
parents:
61
diff
changeset
|
542 |
| 7 | 543 end_index = inode->i_size >> PAGE_CACHE_SHIFT; |
| 544 | |
| 545 /* easy case */ | |
| 76 | 546 if (page->index < end_index) { |
| 7 | 547 nBytes = PAGE_CACHE_SIZE; |
| 76 | 548 } else { |
| 549 nBytes = inode->i_size & (PAGE_CACHE_SIZE - 1); | |
| 7 | 550 } |
| 551 | |
| 552 get_page(page); | |
| 553 | |
| 554 buffer = kmap(page); | |
| 555 | |
| 556 obj = yaffs_InodeToObject(inode); | |
| 557 yaffs_GrossLock(obj->myDev); | |
| 558 | |
| 76 | 559 T(YAFFS_TRACE_OS, |
| 560 (KERN_DEBUG "yaffs_writepage at %08x, size %08x\n", | |
| 561 (unsigned)(page->index << PAGE_CACHE_SHIFT), nBytes)); | |
| 562 T(YAFFS_TRACE_OS, | |
| 563 (KERN_DEBUG "writepag0: obj = %05x, ino = %05x\n", | |
| 564 (int)obj->variant.fileVariant.fileSize, (int)inode->i_size)); | |
| 7 | 565 |
| 76 | 566 nWritten = |
| 567 yaffs_WriteDataToFile(obj, buffer, page->index << PAGE_CACHE_SHIFT, | |
| 568 nBytes, 0); | |
| 7 | 569 |
| 76 | 570 T(YAFFS_TRACE_OS, |
| 571 (KERN_DEBUG "writepag1: obj = %05x, ino = %05x\n", | |
| 572 (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
|
573 |
| 7 | 574 yaffs_GrossUnlock(obj->myDev); |
| 76 | 575 |
| 7 | 576 kunmap(page); |
| 577 SetPageUptodate(page); | |
| 578 UnlockPage(page); | |
| 579 put_page(page); | |
| 580 | |
| 76 | 581 return (nWritten == nBytes) ? 0 : -ENOSPC; |
| 7 | 582 } |
| 583 | |
| 76 | 584 static int yaffs_prepare_write(struct file *f, struct page *pg, |
| 585 unsigned offset, unsigned to) | |
| 7 | 586 { |
| 587 | |
| 76 | 588 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_prepair_write\n")); |
| 589 if (!Page_Uptodate(pg) && (offset || to < PAGE_CACHE_SIZE)) | |
| 590 return yaffs_readpage_nolock(f, pg); | |
| 7 | 591 |
| 592 return 0; | |
| 76 | 593 |
| 7 | 594 } |
| 595 | |
| 76 | 596 static int yaffs_commit_write(struct file *f, struct page *pg, unsigned offset, |
| 597 unsigned to) | |
| 7 | 598 { |
| 599 | |
| 600 void *addr = page_address(pg) + offset; | |
| 76 | 601 loff_t pos = (((loff_t) pg->index) << PAGE_CACHE_SHIFT) + offset; |
| 7 | 602 int nBytes = to - offset; |
| 603 int nWritten; | |
| 76 | 604 |
| 7 | 605 unsigned spos = pos; |
| 606 unsigned saddr = (unsigned)addr; | |
| 607 | |
| 76 | 608 T(YAFFS_TRACE_OS, |
| 609 (KERN_DEBUG "yaffs_commit_write addr %x pos %x nBytes %d\n", saddr, | |
| 610 spos, nBytes)); | |
| 611 | |
| 612 nWritten = yaffs_file_write(f, addr, nBytes, &pos); | |
| 613 | |
| 614 if (nWritten != nBytes) { | |
| 615 T(YAFFS_TRACE_OS, | |
| 616 (KERN_DEBUG | |
| 617 "yaffs_commit_write not same size nWritten %d nBytes %d\n", | |
| 618 nWritten, nBytes)); | |
| 7 | 619 SetPageError(pg); |
| 620 ClearPageUptodate(pg); | |
| 76 | 621 } else { |
| 7 | 622 SetPageUptodate(pg); |
| 623 } | |
| 624 | |
| 76 | 625 T(YAFFS_TRACE_OS, |
| 94 | 626 (KERN_DEBUG "yaffs_commit_write returning %d\n", |
| 627 nWritten == nBytes ? 0 : -1)); | |
| 76 | 628 |
| 94 | 629 return nWritten == nBytes ? 0 : -1; |
| 7 | 630 |
| 631 } | |
| 632 | |
| 76 | 633 static void yaffs_FillInodeFromObject(struct inode *inode, yaffs_Object * obj) |
| 7 | 634 { |
| 76 | 635 if (inode && obj) { |
| 7 | 636 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
|
637 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
|
638 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
|
639 inode->i_gid = obj->yst_gid; |
| 7 | 640 inode->i_blksize = inode->i_sb->s_blocksize; |
| 641 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) | |
| 642 | |
|
22
0b57027b96fe
Some improvements to garbage collection and st_xxx to yst_xxx changes
charles <charles>
parents:
19
diff
changeset
|
643 inode->i_rdev = old_decode_dev(obj->yst_rdev); |
| 76 | 644 inode->i_atime.tv_sec = (time_t) (obj->yst_atime); |
| 7 | 645 inode->i_atime.tv_nsec = 0; |
| 76 | 646 inode->i_mtime.tv_sec = (time_t) obj->yst_mtime; |
| 647 inode->i_mtime.tv_nsec = 0; | |
| 648 inode->i_ctime.tv_sec = (time_t) obj->yst_ctime; | |
| 7 | 649 inode->i_ctime.tv_nsec = 0; |
| 650 #else | |
|
22
0b57027b96fe
Some improvements to garbage collection and st_xxx to yst_xxx changes
charles <charles>
parents:
19
diff
changeset
|
651 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
|
652 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
|
653 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
|
654 inode->i_ctime = obj->yst_ctime; |
| 7 | 655 #endif |
| 656 inode->i_size = yaffs_GetObjectFileLength(obj); | |
| 657 inode->i_blocks = (inode->i_size + 511) >> 9; | |
| 658 | |
| 659 inode->i_nlink = yaffs_GetObjectLinkCount(obj); | |
| 76 | 660 |
| 661 T(YAFFS_TRACE_OS, | |
| 662 (KERN_DEBUG | |
| 663 "yaffs_FillInode mode %x uid %d gid %d size %d count %d\n", | |
| 664 inode->i_mode, inode->i_uid, inode->i_gid, | |
| 665 (int)inode->i_size, atomic_read(&inode->i_count))); | |
| 666 | |
| 667 switch (obj->yst_mode & S_IFMT) { | |
| 668 default: /* fifo, device or socket */ | |
| 12 | 669 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) |
| 76 | 670 init_special_inode(inode, obj->yst_mode, |
| 671 old_decode_dev(obj->yst_rdev)); | |
| 12 | 672 #else |
| 76 | 673 init_special_inode(inode, obj->yst_mode, |
| 674 (dev_t) (obj->yst_rdev)); | |
| 675 #endif | |
| 676 break; | |
| 677 case S_IFREG: /* file */ | |
| 678 inode->i_op = &yaffs_file_inode_operations; | |
| 679 inode->i_fop = &yaffs_file_operations; | |
| 680 inode->i_mapping->a_ops = | |
| 681 &yaffs_file_address_operations; | |
| 682 break; | |
| 683 case S_IFDIR: /* directory */ | |
| 684 inode->i_op = &yaffs_dir_inode_operations; | |
| 685 inode->i_fop = &yaffs_dir_operations; | |
| 686 break; | |
| 687 case S_IFLNK: /* symlink */ | |
| 688 inode->i_op = &yaffs_symlink_inode_operations; | |
| 689 break; | |
| 7 | 690 } |
| 76 | 691 |
| 7 | 692 inode->u.generic_ip = obj; |
| 693 obj->myInode = inode; | |
| 76 | 694 |
| 695 } else { | |
| 696 T(YAFFS_TRACE_OS, | |
| 697 (KERN_DEBUG "yaffs_FileInode invalid parameters\n")); | |
| 7 | 698 } |
| 699 | |
| 700 } | |
| 701 | |
| 76 | 702 struct inode *yaffs_get_inode(struct super_block *sb, int mode, int dev, |
| 703 yaffs_Object * obj) | |
| 7 | 704 { |
| 76 | 705 struct inode *inode; |
| 706 | |
| 707 if (!sb) { | |
| 708 T(YAFFS_TRACE_OS, | |
| 709 (KERN_DEBUG "yaffs_get_inode for NULL super_block!!\n")); | |
| 710 return NULL; | |
| 711 | |
| 7 | 712 } |
| 76 | 713 |
| 714 if (!obj) { | |
| 715 T(YAFFS_TRACE_OS, | |
| 716 (KERN_DEBUG "yaffs_get_inode for NULL object!!\n")); | |
| 717 return NULL; | |
| 718 | |
| 7 | 719 } |
| 76 | 720 |
| 721 T(YAFFS_TRACE_OS, | |
| 722 (KERN_DEBUG "yaffs_get_inode for object %d\n", obj->objectId)); | |
| 7 | 723 |
| 76 | 724 inode = iget(sb, obj->objectId); |
| 7 | 725 |
| 76 | 726 /* NB Side effect: iget calls back to yaffs_read_inode(). */ |
| 727 /* iget also increments the inode's i_count */ | |
|
106
5b8f68c30468
Apply Reed's deadlocking fix (manually applied)
charles <charles>
parents:
104
diff
changeset
|
728 /* NB You can't be holding grossLock or deadlock will happen! */ |
| 76 | 729 |
| 7 | 730 return inode; |
| 731 } | |
| 732 | |
| 76 | 733 static ssize_t yaffs_file_write(struct file *f, const char *buf, size_t n, |
| 734 loff_t * pos) | |
| 7 | 735 { |
| 736 yaffs_Object *obj; | |
| 76 | 737 int nWritten, ipos; |
| 7 | 738 struct inode *inode; |
| 739 yaffs_Device *dev; | |
| 76 | 740 |
| 741 obj = yaffs_DentryToObject(f->f_dentry); | |
| 742 | |
| 7 | 743 dev = obj->myDev; |
| 76 | 744 |
| 7 | 745 yaffs_GrossLock(dev); |
| 746 | |
| 747 inode = f->f_dentry->d_inode; | |
| 748 | |
| 76 | 749 if (!S_ISBLK(inode->i_mode) && f->f_flags & O_APPEND) { |
| 7 | 750 ipos = inode->i_size; |
| 76 | 751 } else { |
| 7 | 752 ipos = *pos; |
| 753 } | |
| 76 | 754 |
| 755 if (!obj) { | |
| 756 T(YAFFS_TRACE_OS, | |
| 757 (KERN_DEBUG "yaffs_file_write: hey obj is null!\n")); | |
| 758 } else { | |
| 759 T(YAFFS_TRACE_OS, | |
| 760 (KERN_DEBUG | |
| 761 "yaffs_file_write about to write writing %d bytes" | |
| 762 "to object %d at %d\n", | |
| 763 n, obj->objectId, ipos)); | |
| 7 | 764 } |
| 765 | |
| 76 | 766 nWritten = yaffs_WriteDataToFile(obj, buf, ipos, n, 0); |
| 7 | 767 |
| 76 | 768 T(YAFFS_TRACE_OS, |
| 769 (KERN_DEBUG "yaffs_file_write writing %d bytes, %d written at %d\n", | |
| 770 n, nWritten, ipos)); | |
| 771 if (nWritten > 0) { | |
| 7 | 772 ipos += nWritten; |
| 773 *pos = ipos; | |
| 76 | 774 if (ipos > inode->i_size) { |
| 7 | 775 inode->i_size = ipos; |
| 76 | 776 inode->i_blocks = (ipos + 511) >> 9; |
| 777 | |
| 778 T(YAFFS_TRACE_OS, | |
| 779 (KERN_DEBUG | |
| 780 "yaffs_file_write size updated to %d bytes, " | |
| 781 "%d blocks\n", | |
| 782 ipos, (int)(inode->i_blocks))); | |
| 7 | 783 } |
| 76 | 784 |
| 7 | 785 } |
| 786 yaffs_GrossUnlock(dev); | |
| 76 | 787 |
| 7 | 788 return nWritten != n ? -ENOSPC : nWritten; |
| 789 } | |
| 790 | |
| 791 static int yaffs_readdir(struct file *f, void *dirent, filldir_t filldir) | |
| 792 { | |
| 793 yaffs_Object *obj; | |
| 794 yaffs_Device *dev; | |
| 795 struct inode *inode = f->f_dentry->d_inode; | |
| 796 unsigned long offset, curoffs; | |
| 76 | 797 struct list_head *i; |
| 7 | 798 yaffs_Object *l; |
| 76 | 799 |
| 800 char name[YAFFS_MAX_NAME_LENGTH + 1]; | |
| 801 | |
| 802 obj = yaffs_DentryToObject(f->f_dentry); | |
| 7 | 803 dev = obj->myDev; |
| 76 | 804 |
| 7 | 805 yaffs_GrossLock(dev); |
| 76 | 806 |
| 7 | 807 offset = f->f_pos; |
| 76 | 808 |
| 809 T(YAFFS_TRACE_OS, ("yaffs_readdir: starting at %d\n", (int)offset)); | |
| 810 | |
| 811 if (offset == 0) { | |
| 812 T(YAFFS_TRACE_OS, | |
| 813 (KERN_DEBUG "yaffs_readdir: entry . ino %d \n", | |
| 814 (int)inode->i_ino)); | |
| 815 if (filldir(dirent, ".", 1, offset, inode->i_ino, DT_DIR) | |
| 816 < 0) { | |
| 7 | 817 goto out; |
| 818 } | |
| 819 offset++; | |
| 820 f->f_pos++; | |
| 821 } | |
| 76 | 822 if (offset == 1) { |
| 823 T(YAFFS_TRACE_OS, | |
| 824 (KERN_DEBUG "yaffs_readdir: entry .. ino %d \n", | |
| 825 (int)f->f_dentry->d_parent->d_inode->i_ino)); | |
| 826 if (filldir | |
| 827 (dirent, "..", 2, offset, | |
| 828 f->f_dentry->d_parent->d_inode->i_ino, DT_DIR) < 0) { | |
| 7 | 829 goto out; |
| 830 } | |
| 831 offset++; | |
| 832 f->f_pos++; | |
| 833 } | |
| 76 | 834 |
| 7 | 835 curoffs = 1; |
| 76 | 836 |
| 837 list_for_each(i, &obj->variant.directoryVariant.children) { | |
| 7 | 838 curoffs++; |
| 76 | 839 if (curoffs >= offset) { |
| 840 l = list_entry(i, yaffs_Object, siblings); | |
| 841 | |
| 842 yaffs_GetObjectName(l, name, | |
| 843 YAFFS_MAX_NAME_LENGTH + 1); | |
| 844 T(YAFFS_TRACE_OS, | |
| 845 (KERN_DEBUG "yaffs_readdir: %s inode %d\n", name, | |
| 846 yaffs_GetObjectInode(l))); | |
| 847 | |
| 848 if (filldir(dirent, | |
| 849 name, | |
| 850 strlen(name), | |
| 851 offset, | |
| 852 yaffs_GetObjectInode(l), | |
| 853 yaffs_GetObjectType(l)) | |
| 854 < 0) { | |
| 7 | 855 goto up_and_out; |
| 856 } | |
| 76 | 857 |
| 7 | 858 offset++; |
| 76 | 859 f->f_pos++; |
| 7 | 860 } |
| 861 } | |
| 862 | |
| 76 | 863 up_and_out: |
| 864 out: | |
| 865 | |
| 866 yaffs_GrossUnlock(dev); | |
| 867 | |
| 7 | 868 return 0; |
| 869 } | |
| 870 | |
| 871 /* | |
| 872 * File creation. Allocate an inode, and we're done.. | |
| 873 */ | |
| 874 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) | |
| 76 | 875 static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode, |
| 876 dev_t rdev) | |
| 7 | 877 #else |
| 76 | 878 static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode, |
| 879 int rdev) | |
| 7 | 880 #endif |
| 881 { | |
| 882 struct inode *inode; | |
| 76 | 883 |
| 7 | 884 yaffs_Object *obj = NULL; |
| 885 yaffs_Device *dev; | |
| 76 | 886 |
| 7 | 887 yaffs_Object *parent = yaffs_InodeToObject(dir); |
| 76 | 888 |
| 7 | 889 int error = -ENOSPC; |
|
36
e98ab6dcd6b7
Set the correct uid/gid of newly created files when: use fsuid & fsgid and take care when the SGID bit is set on the parent directory.
luc <luc>
parents:
32
diff
changeset
|
890 uid_t uid = current->fsuid; |
|
e98ab6dcd6b7
Set the correct uid/gid of newly created files when: use fsuid & fsgid and take care when the SGID bit is set on the parent directory.
luc <luc>
parents:
32
diff
changeset
|
891 gid_t gid = (dir->i_mode & S_ISGID) ? dir->i_gid : current->fsgid; |
| 7 | 892 |
| 76 | 893 if (parent) { |
| 894 T(YAFFS_TRACE_OS, | |
| 895 (KERN_DEBUG "yaffs_mknod: parent object %d type %d\n", | |
| 896 parent->objectId, parent->variantType)); | |
| 897 } else { | |
| 898 T(YAFFS_TRACE_OS, | |
| 899 (KERN_DEBUG "yaffs_mknod: could not get parent object\n")); | |
| 7 | 900 return -EPERM; |
| 901 } | |
| 76 | 902 |
| 903 T(YAFFS_TRACE_OS, ("yaffs_mknod: making oject for %s, " | |
| 904 "mode %x dev %x\n", | |
| 905 dentry->d_name.name, mode, rdev)); | |
| 7 | 906 |
| 907 dev = parent->myDev; | |
| 76 | 908 |
| 7 | 909 yaffs_GrossLock(dev); |
| 910 | |
| 76 | 911 switch (mode & S_IFMT) { |
| 912 default: | |
| 913 /* Special (socket, fifo, device...) */ | |
| 914 T(YAFFS_TRACE_OS, (KERN_DEBUG | |
| 915 "yaffs_mknod: making special\n")); | |
| 12 | 916 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) |
| 76 | 917 obj = |
| 918 yaffs_MknodSpecial(parent, dentry->d_name.name, mode, uid, | |
| 919 gid, old_encode_dev(rdev)); | |
| 12 | 920 #else |
| 76 | 921 obj = |
| 922 yaffs_MknodSpecial(parent, dentry->d_name.name, mode, uid, | |
| 923 gid, rdev); | |
| 924 #endif | |
| 925 break; | |
| 926 case S_IFREG: /* file */ | |
| 927 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_mknod: making file\n")); | |
| 928 obj = | |
| 929 yaffs_MknodFile(parent, dentry->d_name.name, mode, uid, | |
| 930 gid); | |
| 931 break; | |
| 932 case S_IFDIR: /* directory */ | |
| 933 T(YAFFS_TRACE_OS, | |
| 934 (KERN_DEBUG "yaffs_mknod: making directory\n")); | |
| 935 obj = | |
| 936 yaffs_MknodDirectory(parent, dentry->d_name.name, mode, | |
| 937 uid, gid); | |
| 938 break; | |
| 939 case S_IFLNK: /* symlink */ | |
| 940 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_mknod: making file\n")); | |
| 941 obj = NULL; /* Do we ever get here? */ | |
| 942 break; | |
| 7 | 943 } |
|
106
5b8f68c30468
Apply Reed's deadlocking fix (manually applied)
charles <charles>
parents:
104
diff
changeset
|
944 |
|
5b8f68c30468
Apply Reed's deadlocking fix (manually applied)
charles <charles>
parents:
104
diff
changeset
|
945 /* Can not call yaffs_get_inode() with gross lock held */ |
|
5b8f68c30468
Apply Reed's deadlocking fix (manually applied)
charles <charles>
parents:
104
diff
changeset
|
946 yaffs_GrossUnlock(dev); |
| 76 | 947 |
| 948 if (obj) { | |
| 7 | 949 inode = yaffs_get_inode(dir->i_sb, mode, rdev, obj); |
| 950 d_instantiate(dentry, inode); | |
| 76 | 951 T(YAFFS_TRACE_OS, |
| 952 (KERN_DEBUG "yaffs_mknod created object %d count = %d\n", | |
| 953 obj->objectId, atomic_read(&inode->i_count))); | |
| 7 | 954 error = 0; |
| 76 | 955 } else { |
| 956 T(YAFFS_TRACE_OS, | |
| 957 (KERN_DEBUG "yaffs_mknod failed making object\n")); | |
| 7 | 958 error = -ENOMEM; |
| 959 } | |
| 960 | |
| 961 return error; | |
| 962 } | |
| 963 | |
| 76 | 964 static int yaffs_mkdir(struct inode *dir, struct dentry *dentry, int mode) |
| 7 | 965 { |
| 966 int retVal; | |
| 76 | 967 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_mkdir\n")); |
| 968 retVal = yaffs_mknod(dir, dentry, mode | S_IFDIR, 0); | |
| 7 | 969 #if 0 |
| 76 | 970 /* attempt to fix dir bug - didn't work */ |
| 971 if (!retVal) { | |
| 7 | 972 dget(dentry); |
| 973 } | |
| 974 #endif | |
| 975 return retVal; | |
| 976 } | |
| 977 | |
| 978 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) | |
| 76 | 979 static int yaffs_create(struct inode *dir, struct dentry *dentry, int mode, |
| 980 struct nameidata *n) | |
| 7 | 981 #else |
| 982 static int yaffs_create(struct inode *dir, struct dentry *dentry, int mode) | |
| 983 #endif | |
| 984 { | |
| 76 | 985 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_create\n")); |
| 7 | 986 return yaffs_mknod(dir, dentry, mode | S_IFREG, 0); |
| 987 } | |
| 988 | |
| 76 | 989 static int yaffs_unlink(struct inode *dir, struct dentry *dentry) |
| 7 | 990 { |
| 991 int retVal; | |
| 76 | 992 |
| 7 | 993 yaffs_Device *dev; |
| 76 | 994 |
| 995 T(YAFFS_TRACE_OS, | |
| 996 (KERN_DEBUG "yaffs_unlink %d:%s\n", (int)(dir->i_ino), | |
| 997 dentry->d_name.name)); | |
| 998 | |
| 7 | 999 dev = yaffs_InodeToObject(dir)->myDev; |
| 76 | 1000 |
| 7 | 1001 yaffs_GrossLock(dev); |
| 76 | 1002 |
| 1003 retVal = yaffs_Unlink(yaffs_InodeToObject(dir), dentry->d_name.name); | |
| 1004 | |
| 7 | 1005 yaffs_GrossUnlock(dev); |
| 76 | 1006 |
| 1007 if (retVal == YAFFS_OK) { | |
| 7 | 1008 dentry->d_inode->i_nlink--; |
| 1009 mark_inode_dirty(dentry->d_inode); | |
| 1010 return 0; | |
| 76 | 1011 } else { |
| 7 | 1012 return -ENOTEMPTY; |
| 1013 } | |
| 1014 } | |
| 1015 | |
| 1016 /* | |
| 1017 * Create a link... | |
| 1018 */ | |
| 76 | 1019 static int yaffs_link(struct dentry *old_dentry, struct inode *dir, |
| 1020 struct dentry *dentry) | |
| 7 | 1021 { |
| 1022 struct inode *inode = old_dentry->d_inode; | |
| 1023 yaffs_Object *obj = NULL; | |
| 76 | 1024 yaffs_Object *link = NULL; |
| 7 | 1025 yaffs_Device *dev; |
| 76 | 1026 |
| 1027 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_link\n")); | |
| 1028 | |
| 7 | 1029 obj = yaffs_InodeToObject(inode); |
| 1030 dev = obj->myDev; | |
| 76 | 1031 |
| 7 | 1032 yaffs_GrossLock(dev); |
| 1033 | |
| 76 | 1034 if (!S_ISDIR(inode->i_mode)) /* Don't link directories */ |
| 7 | 1035 { |
| 76 | 1036 link = |
| 1037 yaffs_Link(yaffs_InodeToObject(dir), dentry->d_name.name, | |
| 1038 obj); | |
| 7 | 1039 } |
| 1040 | |
| 76 | 1041 if (link) { |
| 1042 old_dentry->d_inode->i_nlink = yaffs_GetObjectLinkCount(obj); | |
| 7 | 1043 d_instantiate(dentry, old_dentry->d_inode); |
| 1044 atomic_inc(&old_dentry->d_inode->i_count); | |
| 76 | 1045 T(YAFFS_TRACE_OS, |
| 1046 (KERN_DEBUG "yaffs_link link count %d i_count %d\n", | |
| 1047 old_dentry->d_inode->i_nlink, | |
| 1048 atomic_read(&old_dentry->d_inode->i_count))); | |
| 1049 | |
| 7 | 1050 } |
| 76 | 1051 |
| 7 | 1052 yaffs_GrossUnlock(dev); |
| 1053 | |
| 76 | 1054 if (link) { |
| 1055 | |
| 7 | 1056 return 0; |
| 1057 } | |
| 76 | 1058 |
| 1059 return -EPERM; | |
| 7 | 1060 } |
| 1061 | |
| 76 | 1062 static int yaffs_symlink(struct inode *dir, struct dentry *dentry, |
| 1063 const char *symname) | |
| 7 | 1064 { |
| 1065 yaffs_Object *obj; | |
| 1066 yaffs_Device *dev; | |
|
36
e98ab6dcd6b7
Set the correct uid/gid of newly created files when: use fsuid & fsgid and take care when the SGID bit is set on the parent directory.
luc <luc>
parents:
32
diff
changeset
|
1067 uid_t uid = current->fsuid; |
|
e98ab6dcd6b7
Set the correct uid/gid of newly created files when: use fsuid & fsgid and take care when the SGID bit is set on the parent directory.
luc <luc>
parents:
32
diff
changeset
|
1068 gid_t gid = (dir->i_mode & S_ISGID) ? dir->i_gid : current->fsgid; |
| 76 | 1069 |
| 1070 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_symlink\n")); | |
| 1071 | |
| 7 | 1072 dev = yaffs_InodeToObject(dir)->myDev; |
| 1073 yaffs_GrossLock(dev); | |
| 76 | 1074 obj = yaffs_MknodSymLink(yaffs_InodeToObject(dir), dentry->d_name.name, |
| 1075 S_IFLNK | S_IRWXUGO, uid, gid, symname); | |
| 7 | 1076 yaffs_GrossUnlock(dev); |
| 1077 | |
| 76 | 1078 if (obj) { |
| 7 | 1079 |
| 76 | 1080 struct inode *inode; |
| 1081 | |
|
22
0b57027b96fe
Some improvements to garbage collection and st_xxx to yst_xxx changes
charles <charles>
parents:
19
diff
changeset
|
1082 inode = yaffs_get_inode(dir->i_sb, obj->yst_mode, 0, obj); |
| 7 | 1083 d_instantiate(dentry, inode); |
| 76 | 1084 T(YAFFS_TRACE_OS, (KERN_DEBUG "symlink created OK\n")); |
| 7 | 1085 return 0; |
| 76 | 1086 } else { |
| 1087 T(YAFFS_TRACE_OS, (KERN_DEBUG "symlink not created\n")); | |
| 7 | 1088 |
| 1089 } | |
| 76 | 1090 |
| 7 | 1091 return -ENOMEM; |
| 1092 } | |
| 1093 | |
| 76 | 1094 static int yaffs_sync_object(struct file *file, struct dentry *dentry, |
| 1095 int datasync) | |
| 7 | 1096 { |
| 1097 | |
| 1098 yaffs_Object *obj; | |
| 1099 yaffs_Device *dev; | |
| 76 | 1100 |
| 7 | 1101 obj = yaffs_DentryToObject(dentry); |
| 1102 | |
| 1103 dev = obj->myDev; | |
| 76 | 1104 |
| 1105 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_sync_object\n")); | |
| 7 | 1106 yaffs_GrossLock(dev); |
| 76 | 1107 yaffs_FlushFile(obj, 1); |
| 7 | 1108 yaffs_GrossUnlock(dev); |
| 1109 return 0; | |
| 1110 } | |
| 1111 | |
| 1112 /* | |
| 1113 * The VFS layer already does all the dentry stuff for rename. | |
| 1114 * | |
| 1115 * NB: POSIX says you can rename an object over an old object of the same name | |
| 1116 */ | |
| 76 | 1117 static int yaffs_rename(struct inode *old_dir, struct dentry *old_dentry, |
| 1118 struct inode *new_dir, struct dentry *new_dentry) | |
| 7 | 1119 { |
| 1120 yaffs_Device *dev; | |
| 1121 int retVal = YAFFS_FAIL; | |
| 1122 yaffs_Object *target; | |
| 76 | 1123 |
| 83 | 1124 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_rename\n")); |
| 7 | 1125 dev = yaffs_InodeToObject(old_dir)->myDev; |
| 1126 | |
| 1127 yaffs_GrossLock(dev); | |
| 76 | 1128 |
| 1129 /* Check if the target is an existing directory that is not empty. */ | |
| 1130 target = | |
| 1131 yaffs_FindObjectByName(yaffs_InodeToObject(new_dir), | |
| 1132 new_dentry->d_name.name); | |
| 83 | 1133 |
| 1134 | |
| 76 | 1135 |
| 1136 if (target && | |
| 1137 target->variantType == YAFFS_OBJECT_TYPE_DIRECTORY && | |
| 1138 !list_empty(&target->variant.directoryVariant.children)) { | |
| 83 | 1139 |
| 1140 T(YAFFS_TRACE_OS, (KERN_DEBUG "target is non-empty dir\n")); | |
| 1141 | |
| 7 | 1142 retVal = YAFFS_FAIL; |
| 76 | 1143 } else { |
| 1144 | |
| 1145 /* Now does unlinking internally using shadowing mechanism */ | |
| 83 | 1146 T(YAFFS_TRACE_OS, (KERN_DEBUG "calling yaffs_RenameObject\n")); |
| 1147 | |
| 76 | 1148 retVal = |
| 1149 yaffs_RenameObject(yaffs_InodeToObject(old_dir), | |
| 1150 old_dentry->d_name.name, | |
| 1151 yaffs_InodeToObject(new_dir), | |
| 1152 new_dentry->d_name.name); | |
| 1153 | |
| 7 | 1154 } |
| 1155 yaffs_GrossUnlock(dev); | |
| 76 | 1156 |
| 1157 if (retVal == YAFFS_OK) { | |
| 88 | 1158 if(target) { |
| 1159 new_dentry->d_inode->i_nlink--; | |
| 1160 mark_inode_dirty(new_dentry->d_inode); | |
| 1161 } | |
| 76 | 1162 |
| 7 | 1163 return 0; |
| 76 | 1164 } else { |
| 7 | 1165 return -ENOTEMPTY; |
| 1166 } | |
| 1167 | |
| 1168 } | |
| 1169 | |
| 1170 static int yaffs_setattr(struct dentry *dentry, struct iattr *attr) | |
| 1171 { | |
| 1172 struct inode *inode = dentry->d_inode; | |
| 1173 int error; | |
| 1174 yaffs_Device *dev; | |
| 76 | 1175 |
| 1176 T(YAFFS_TRACE_OS, | |
| 1177 (KERN_DEBUG "yaffs_setattr of object %d\n", | |
| 1178 yaffs_InodeToObject(inode)->objectId)); | |
| 1179 | |
| 1180 if ((error = inode_change_ok(inode, attr)) == 0) { | |
| 1181 | |
| 7 | 1182 dev = yaffs_InodeToObject(inode)->myDev; |
| 1183 yaffs_GrossLock(dev); | |
| 76 | 1184 if (yaffs_SetAttributes(yaffs_InodeToObject(inode), attr) == |
| 1185 YAFFS_OK) { | |
| 7 | 1186 error = 0; |
| 76 | 1187 } else { |
| 7 | 1188 error = -EPERM; |
| 1189 } | |
| 1190 yaffs_GrossUnlock(dev); | |
| 23 | 1191 if (!error) |
| 76 | 1192 error = inode_setattr(inode, attr); |
| 7 | 1193 } |
| 1194 return error; | |
| 1195 } | |
| 1196 | |
| 1197 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) | |
| 1198 static int yaffs_statfs(struct super_block *sb, struct kstatfs *buf) | |
| 1199 #else | |
| 1200 static int yaffs_statfs(struct super_block *sb, struct statfs *buf) | |
| 1201 #endif | |
| 1202 { | |
| 15 | 1203 |
| 7 | 1204 yaffs_Device *dev = yaffs_SuperToDevice(sb); |
| 76 | 1205 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_statfs\n")); |
| 7 | 1206 |
| 1207 yaffs_GrossLock(dev); | |
| 76 | 1208 |
| 7 | 1209 buf->f_type = YAFFS_MAGIC; |
| 1210 buf->f_bsize = sb->s_blocksize; | |
| 1211 buf->f_namelen = 255; | |
| 76 | 1212 if (sb->s_blocksize > dev->nBytesPerChunk) { |
| 1213 | |
| 1214 buf->f_blocks = | |
| 1215 (dev->endBlock - dev->startBlock + | |
| 1216 1) * dev->nChunksPerBlock / (sb->s_blocksize / | |
| 1217 dev->nBytesPerChunk); | |
| 1218 buf->f_bfree = | |
| 1219 yaffs_GetNumberOfFreeChunks(dev) / (sb->s_blocksize / | |
| 1220 dev->nBytesPerChunk); | |
| 1221 } else { | |
| 1222 | |
| 1223 buf->f_blocks = | |
| 1224 (dev->endBlock - dev->startBlock + | |
| 1225 1) * dev->nChunksPerBlock * (dev->nBytesPerChunk / | |
| 1226 sb->s_blocksize); | |
| 1227 buf->f_bfree = | |
| 1228 yaffs_GetNumberOfFreeChunks(dev) * (dev->nBytesPerChunk / | |
| 1229 sb->s_blocksize); | |
| 15 | 1230 } |
| 7 | 1231 buf->f_files = 0; |
| 1232 buf->f_ffree = 0; | |
| 76 | 1233 buf->f_bavail = buf->f_bfree; |
| 1234 | |
| 7 | 1235 yaffs_GrossUnlock(dev); |
| 1236 return 0; | |
| 1237 } | |
| 1238 | |
| 76 | 1239 static void yaffs_read_inode(struct inode *inode) |
| 7 | 1240 { |
|
106
5b8f68c30468
Apply Reed's deadlocking fix (manually applied)
charles <charles>
parents:
104
diff
changeset
|
1241 /* NB This is called as a side effect of other functions, but |
|
5b8f68c30468
Apply Reed's deadlocking fix (manually applied)
charles <charles>
parents:
104
diff
changeset
|
1242 * we had to release the lock to prevent deadlocks, so |
|
5b8f68c30468
Apply Reed's deadlocking fix (manually applied)
charles <charles>
parents:
104
diff
changeset
|
1243 * need to lock again. |
| 76 | 1244 */ |
| 1245 | |
| 1246 yaffs_Object *obj; | |
| 7 | 1247 yaffs_Device *dev = yaffs_SuperToDevice(inode->i_sb); |
| 76 | 1248 |
| 1249 T(YAFFS_TRACE_OS, | |
| 1250 (KERN_DEBUG "yaffs_read_inode for %d\n", (int)inode->i_ino)); | |
| 7 | 1251 |
|
106
5b8f68c30468
Apply Reed's deadlocking fix (manually applied)
charles <charles>
parents:
104
diff
changeset
|
1252 yaffs_GrossLock(dev); |
|
5b8f68c30468
Apply Reed's deadlocking fix (manually applied)
charles <charles>
parents:
104
diff
changeset
|
1253 |
| 76 | 1254 obj = yaffs_FindObjectByNumber(dev, inode->i_ino); |
| 1255 | |
| 1256 yaffs_FillInodeFromObject(inode, obj); | |
| 7 | 1257 |
|
106
5b8f68c30468
Apply Reed's deadlocking fix (manually applied)
charles <charles>
parents:
104
diff
changeset
|
1258 yaffs_GrossUnlock(dev); |
| 7 | 1259 } |
| 1260 | |
| 27 | 1261 static LIST_HEAD(yaffs_dev_list); |
| 7 | 1262 |
| 1263 static void yaffs_put_super(struct super_block *sb) | |
| 1264 { | |
| 1265 yaffs_Device *dev = yaffs_SuperToDevice(sb); | |
| 76 | 1266 |
| 7 | 1267 yaffs_GrossLock(dev); |
| 76 | 1268 if (dev->putSuperFunc) { |
| 1269 dev->putSuperFunc(sb); | |
| 7 | 1270 } |
| 1271 yaffs_Deinitialise(dev); | |
| 1272 yaffs_GrossUnlock(dev); | |
| 1273 | |
| 27 | 1274 /* we assume this is protected by lock_kernel() in mount/umount */ |
| 1275 list_del(&dev->devList); | |
| 1276 | |
| 7 | 1277 kfree(dev); |
| 1278 } | |
| 1279 | |
| 1280 | |
| 76 | 1281 static void yaffs_MTDPutSuper(struct super_block *sb) |
| 7 | 1282 { |
| 76 | 1283 |
| 7 | 1284 struct mtd_info *mtd = yaffs_SuperToDevice(sb)->genericDevice; |
| 76 | 1285 |
| 1286 if (mtd->sync) { | |
| 7 | 1287 mtd->sync(mtd); |
| 1288 } | |
| 76 | 1289 |
| 7 | 1290 put_mtd_device(mtd); |
| 1291 } | |
| 1292 | |
| 1293 | |
| 76 | 1294 static struct super_block *yaffs_internal_read_super(int yaffsVersion, |
| 1295 struct super_block *sb, | |
| 1296 void *data, int silent) | |
| 7 | 1297 { |
| 1298 int nBlocks; | |
| 76 | 1299 struct inode *inode = NULL; |
| 1300 struct dentry *root; | |
| 27 | 1301 yaffs_Device *dev = 0; |
| 76 | 1302 char devname_buf[BDEVNAME_SIZE + 1]; |
|
59
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
1303 struct mtd_info *mtd; |
| 7 | 1304 int err; |
| 76 | 1305 |
| 7 | 1306 sb->s_magic = YAFFS_MAGIC; |
| 1307 sb->s_op = &yaffs_super_ops; | |
| 76 | 1308 |
| 1309 if (!sb) | |
| 1310 printk(KERN_INFO "yaffs: sb is NULL\n"); | |
| 1311 else if (!sb->s_dev) | |
| 1312 printk(KERN_INFO "yaffs: sb->s_dev is NULL\n"); | |
| 1313 else if (!yaffs_devname(sb, devname_buf)) | |
| 1314 printk(KERN_INFO "yaffs: devname is NULL\n"); | |
| 7 | 1315 else |
| 76 | 1316 printk(KERN_INFO "yaffs: dev is %d name is \"%s\"\n", |
| 1317 sb->s_dev, | |
| 1318 yaffs_devname(sb, devname_buf)); | |
| 7 | 1319 |
| 1320 sb->s_blocksize = PAGE_CACHE_SIZE; | |
| 1321 sb->s_blocksize_bits = PAGE_CACHE_SHIFT; | |
| 76 | 1322 T(YAFFS_TRACE_OS, ("yaffs_read_super: Using yaffs%d\n", yaffsVersion)); |
| 1323 T(YAFFS_TRACE_OS, | |
| 1324 ("yaffs_read_super: block size %d\n", (int)(sb->s_blocksize))); | |
| 7 | 1325 |
| 1326 #ifdef CONFIG_YAFFS_DISABLE_WRITE_VERIFY | |
| 76 | 1327 T(YAFFS_TRACE_OS, |
| 1328 ("yaffs: Write verification disabled. All guarantees " | |
| 1329 "null and void\n")); | |
| 7 | 1330 #endif |
| 1331 | |
| 76 | 1332 T(YAFFS_TRACE_ALWAYS, ("yaffs: Attempting MTD mount on %u.%u, " |
| 1333 "\"%s\"\n", | |
| 1334 MAJOR(sb->s_dev), MINOR(sb->s_dev), | |
| 1335 yaffs_devname(sb, devname_buf))); | |
| 7 | 1336 |
| 76 | 1337 /* Check it's an mtd device..... */ |
| 1338 if (MAJOR(sb->s_dev) != MTD_BLOCK_MAJOR) { | |
| 1339 return NULL; /* This isn't an mtd device */ | |
| 1340 } | |
| 1341 /* Get the device */ | |
|
59
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
1342 mtd = get_mtd_device(NULL, MINOR(sb->s_dev)); |
| 76 | 1343 if (!mtd) { |
| 1344 T(YAFFS_TRACE_ALWAYS, | |
| 1345 ("yaffs: MTD device #%u doesn't appear to exist\n", | |
| 1346 MINOR(sb->s_dev))); | |
|
59
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
1347 return NULL; |
|
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
1348 } |
| 76 | 1349 /* Check it's NAND */ |
| 1350 if (mtd->type != MTD_NANDFLASH) { | |
| 1351 T(YAFFS_TRACE_ALWAYS, | |
| 1352 ("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
|
1353 return NULL; |
|
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
1354 } |
|
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
1355 |
| 76 | 1356 T(YAFFS_TRACE_OS, (" erase %p\n", mtd->erase)); |
| 1357 T(YAFFS_TRACE_OS, (" read %p\n", mtd->read)); | |
| 1358 T(YAFFS_TRACE_OS, (" write %p\n", mtd->write)); | |
| 1359 T(YAFFS_TRACE_OS, (" readoob %p\n", mtd->read_oob)); | |
| 1360 T(YAFFS_TRACE_OS, (" writeoob %p\n", mtd->write_oob)); | |
| 1361 T(YAFFS_TRACE_OS, (" block_isbad %p\n", mtd->block_isbad)); | |
| 1362 T(YAFFS_TRACE_OS, (" block_markbad %p\n", mtd->block_markbad)); | |
| 1363 T(YAFFS_TRACE_OS, (" oobblock %d\n", mtd->oobblock)); | |
| 1364 T(YAFFS_TRACE_OS, (" oobsize %d\n", mtd->oobsize)); | |
| 1365 T(YAFFS_TRACE_OS, (" erasesize %d\n", mtd->erasesize)); | |
| 1366 T(YAFFS_TRACE_OS, (" size %d\n", mtd->size)); | |
| 108 | 1367 |
| 109 | 1368 #ifdef CONFIG_YAFFS_AUTO_YAFFS2 |
| 108 | 1369 |
| 1370 if (yaffsVersion == 1 && | |
| 1371 mtd->oobblock >= 2048) { | |
| 1372 T(YAFFS_TRACE_ALWAYS,("yaffs: auto selecting yaffs2\n")); | |
| 1373 yaffsVersion = 2; | |
| 1374 } | |
| 1375 #endif | |
|
59
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
1376 |
| 76 | 1377 if (yaffsVersion == 2) { |
| 1378 /* Check for version 2 style functions */ | |
| 1379 if (!mtd->erase || | |
| 1380 !mtd->block_isbad || | |
| 1381 !mtd->block_markbad || | |
| 1382 !mtd->read || | |
| 1383 !mtd->write || | |
| 1384 !mtd->write_ecc || | |
| 1385 !mtd->read_ecc || !mtd->read_oob || !mtd->write_oob) { | |
| 1386 T(YAFFS_TRACE_ALWAYS, | |
| 1387 ("yaffs: MTD device does not support required " | |
| 1388 "functions\n"));; | |
| 7 | 1389 return NULL; |
| 1390 } | |
| 76 | 1391 |
| 1392 if (mtd->oobblock < YAFFS_MIN_YAFFS2_CHUNK_SIZE || | |
| 1393 mtd->oobsize < YAFFS_MIN_YAFFS2_SPARE_SIZE) { | |
| 1394 T(YAFFS_TRACE_ALWAYS, | |
| 1395 ("yaffs: MTD device does not support have the " | |
| 1396 "right page sizes\n")); | |
|
59
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
1397 return NULL; |
| 7 | 1398 } |
| 76 | 1399 } else { |
| 1400 /* Check for V1 style functions */ | |
| 1401 if (!mtd->erase || | |
| 1402 !mtd->read || | |
| 1403 !mtd->write || | |
| 1404 !mtd->write_ecc || | |
| 1405 !mtd->read_ecc || !mtd->read_oob || !mtd->write_oob) { | |
| 1406 T(YAFFS_TRACE_ALWAYS, | |
| 1407 ("yaffs: MTD device does not support required " | |
| 1408 "functions\n"));; | |
| 1409 return NULL; | |
| 1410 } | |
| 1411 | |
| 1412 if (mtd->oobblock != YAFFS_BYTES_PER_CHUNK || | |
| 1413 mtd->oobsize != YAFFS_BYTES_PER_SPARE) { | |
| 1414 T(YAFFS_TRACE_ALWAYS, | |
| 1415 ("yaffs: MTD device does not support have the " | |
| 1416 "right page sizes\n")); | |
|
59
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
1417 return NULL; |
|
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
1418 } |
|
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
1419 } |
| 7 | 1420 |
| 76 | 1421 /* OK, so if we got here, we have an MTD that's NAND and looks |
| 1422 * like it has the right capabilities | |
| 1423 * Set the yaffs_Device up for mtd | |
| 1424 */ | |
| 7 | 1425 |
| 1426 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) | |
| 76 | 1427 sb->s_fs_info = dev = kmalloc(sizeof(yaffs_Device), GFP_KERNEL); |
| 7 | 1428 #else |
| 76 | 1429 sb->u.generic_sbp = dev = kmalloc(sizeof(yaffs_Device), GFP_KERNEL); |
| 7 | 1430 #endif |
| 76 | 1431 if (!dev) { |
| 1432 /* Deep shit could not allocate device structure */ | |
| 1433 T(YAFFS_TRACE_ALWAYS, | |
| 1434 ("yaffs_read_super: Failed trying to allocate " | |
| 1435 "yaffs_Device. \n")); | |
|
59
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
1436 return NULL; |
|
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
1437 } |
|
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
1438 |
| 76 | 1439 memset(dev, 0, sizeof(yaffs_Device)); |
| 1440 dev->genericDevice = mtd; | |
|
59
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
1441 dev->name = mtd->name; |
| 7 | 1442 |
| 76 | 1443 /* Set up the memory size parameters.... */ |
| 1444 | |
|
59
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
1445 nBlocks = mtd->size / (YAFFS_CHUNKS_PER_BLOCK * YAFFS_BYTES_PER_CHUNK); |
|
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
1446 dev->startBlock = 0; |
|
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
1447 dev->endBlock = nBlocks - 1; |
|
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
1448 dev->nChunksPerBlock = YAFFS_CHUNKS_PER_BLOCK; |
|
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
1449 dev->nBytesPerChunk = YAFFS_BYTES_PER_CHUNK; |
|
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
1450 dev->nReservedBlocks = 5; |
| 76 | 1451 dev->nShortOpCaches = 10; /* Enable short op caching */ |
| 7 | 1452 |
| 76 | 1453 /* ... and the functions. */ |
| 1454 if (yaffsVersion == 2) { | |
| 1455 dev->writeChunkWithTagsToNAND = | |
| 1456 nandmtd2_WriteChunkWithTagsToNAND; | |
| 1457 dev->readChunkWithTagsFromNAND = | |
| 1458 nandmtd2_ReadChunkWithTagsFromNAND; | |
|
59
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
1459 dev->markNANDBlockBad = nandmtd2_MarkNANDBlockBad; |
|
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
1460 dev->queryNANDBlock = nandmtd2_QueryNANDBlock; |
|
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
1461 dev->spareBuffer = YMALLOC(mtd->oobsize); |
|
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
1462 dev->isYaffs2 = 1; |
|
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
1463 dev->nBytesPerChunk = mtd->oobblock; |
|
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
1464 dev->nChunksPerBlock = mtd->erasesize / mtd->oobblock; |
|
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
1465 nBlocks = mtd->size / mtd->erasesize; |
| 19 | 1466 dev->startBlock = 0; |
| 7 | 1467 dev->endBlock = nBlocks - 1; |
| 76 | 1468 } else { |
|
59
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
1469 dev->writeChunkToNAND = nandmtd_WriteChunkToNAND; |
|
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
1470 dev->readChunkFromNAND = nandmtd_ReadChunkFromNAND; |
|
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
1471 dev->isYaffs2 = 0; |
|
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
1472 } |
| 76 | 1473 /* ... and common functions */ |
|
59
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
1474 dev->eraseBlockInNAND = nandmtd_EraseBlockInNAND; |
|
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
1475 dev->initialiseNAND = nandmtd_InitialiseNAND; |
| 76 | 1476 |
|
59
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
1477 dev->putSuperFunc = yaffs_MTDPutSuper; |
| 76 | 1478 |
|
61
49f66fca0b09
newconfig: use YAFFS_DOES_ECC instead of USE_NANDECC
luc <luc>
parents:
59
diff
changeset
|
1479 #ifndef CONFIG_YAFFS_DOES_ECC |
|
59
d6ff669317b8
Adapt the code structure after removing of the yaffsram support.
luc <luc>
parents:
58
diff
changeset
|
1480 dev->useNANDECC = 1; |
| 7 | 1481 #endif |
| 1482 | |
| 104 | 1483 #ifdef CONFIG_YAFFS_DISABLE_WIDE_TNODES |
| 1484 dev->wideTnodesDisabled = 1; | |
| 1485 #endif | |
| 1486 | |
| 27 | 1487 /* we assume this is protected by lock_kernel() in mount/umount */ |
| 1488 list_add_tail(&dev->devList, &yaffs_dev_list); | |
| 1489 | |
| 7 | 1490 init_MUTEX(&dev->grossLock); |
| 76 | 1491 |
| 7 | 1492 yaffs_GrossLock(dev); |
| 76 | 1493 |
| 7 | 1494 err = yaffs_GutsInitialise(dev); |
| 1495 | |
| 76 | 1496 T(YAFFS_TRACE_OS, |
| 1497 ("yaffs_read_super: guts initialised %s\n", | |
| 1498 (err == YAFFS_OK) ? "OK" : "FAILED")); | |
|
106
5b8f68c30468
Apply Reed's deadlocking fix (manually applied)
charles <charles>
parents:
104
diff
changeset
|
1499 |
|
5b8f68c30468
Apply Reed's deadlocking fix (manually applied)
charles <charles>
parents:
104
diff
changeset
|
1500 /* Release lock before yaffs_get_inode() */ |
|
5b8f68c30468
Apply Reed's deadlocking fix (manually applied)
charles <charles>
parents:
104
diff
changeset
|
1501 yaffs_GrossUnlock(dev); |
| 7 | 1502 |
| 76 | 1503 /* Create root inode */ |
| 1504 if (err == YAFFS_OK) | |
| 1505 inode = yaffs_get_inode(sb, S_IFDIR | 0755, 0, | |
| 1506 yaffs_Root(dev)); | |
| 7 | 1507 |
| 1508 if (!inode) | |
| 1509 return NULL; | |
| 1510 | |
| 76 | 1511 inode->i_op = &yaffs_dir_inode_operations; |
| 1512 inode->i_fop = &yaffs_dir_operations; | |
| 1513 | |
| 1514 T(YAFFS_TRACE_OS, ("yaffs_read_super: got root inode\n")); | |
| 7 | 1515 |
| 1516 root = d_alloc_root(inode); | |
| 1517 | |
| 76 | 1518 T(YAFFS_TRACE_OS, ("yaffs_read_super: d_alloc_root done\n")); |
| 7 | 1519 |
| 1520 if (!root) { | |
| 1521 iput(inode); | |
| 1522 return NULL; | |
| 1523 } | |
| 1524 sb->s_root = root; | |
| 1525 | |
| 76 | 1526 T(YAFFS_TRACE_OS, ("yaffs_read_super: done\n")); |
| 7 | 1527 return sb; |
| 1528 } | |
| 1529 | |
|
32
e344a10a3a1e
Move the internals read_super() functions near the declaration of
luc <luc>
parents:
29
diff
changeset
|
1530 |
|
e344a10a3a1e
Move the internals read_super() functions near the declaration of
luc <luc>
parents:
29
diff
changeset
|
1531 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) |
| 76 | 1532 static int yaffs_internal_read_super_mtd(struct super_block *sb, void *data, |
| 1533 int silent) | |
| 7 | 1534 { |
| 95 | 1535 return yaffs_internal_read_super(1, sb, data, silent) ? 0 : -EINVAL; |
| 7 | 1536 } |
| 1537 | |
| 76 | 1538 static struct super_block *yaffs_read_super(struct file_system_type *fs, |
| 1539 int flags, const char *dev_name, | |
| 1540 void *data) | |
| 7 | 1541 { |
| 1542 | |
| 76 | 1543 return get_sb_bdev(fs, flags, dev_name, data, |
| 1544 yaffs_internal_read_super_mtd); | |
| 7 | 1545 } |
| 1546 | |
| 1547 static struct file_system_type yaffs_fs_type = { | |
| 76 | 1548 .owner = THIS_MODULE, |
| 1549 .name = "yaffs", | |
| 1550 .get_sb = yaffs_read_super, | |
| 1551 .kill_sb = kill_block_super, | |
| 1552 .fs_flags = FS_REQUIRES_DEV, | |
| 7 | 1553 }; |
| 1554 #else | |
| 76 | 1555 static struct super_block *yaffs_read_super(struct super_block *sb, void *data, |
| 1556 int silent) | |
| 7 | 1557 { |
| 76 | 1558 return yaffs_internal_read_super(1, sb, data, silent); |
| 7 | 1559 } |
| 1560 | |
| 76 | 1561 static DECLARE_FSTYPE(yaffs_fs_type, "yaffs", yaffs_read_super, |
| 1562 FS_REQUIRES_DEV); | |
| 7 | 1563 #endif |
| 1564 | |
| 1565 | |
| 49 | 1566 #ifdef CONFIG_YAFFS_YAFFS2 |
| 7 | 1567 |
| 1568 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) | |
| 76 | 1569 static int yaffs2_internal_read_super_mtd(struct super_block *sb, void *data, |
| 1570 int silent) | |
|
32
e344a10a3a1e
Move the internals read_super() functions near the declaration of
luc <luc>
parents:
29
diff
changeset
|
1571 { |
| 95 | 1572 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
|
1573 } |
|
e344a10a3a1e
Move the internals read_super() functions near the declaration of
luc <luc>
parents:
29
diff
changeset
|
1574 |
| 76 | 1575 static struct super_block *yaffs2_read_super(struct file_system_type *fs, |
| 1576 int flags, const char *dev_name, | |
| 1577 void *data) | |
| 7 | 1578 { |
| 1579 | |
| 76 | 1580 return get_sb_bdev(fs, flags, dev_name, data, |
| 1581 yaffs2_internal_read_super_mtd); | |
| 7 | 1582 } |
| 1583 | |
| 1584 static struct file_system_type yaffs2_fs_type = { | |
| 76 | 1585 .owner = THIS_MODULE, |
| 1586 .name = "yaffs2", | |
| 1587 .get_sb = yaffs2_read_super, | |
| 1588 .kill_sb = kill_block_super, | |
| 1589 .fs_flags = FS_REQUIRES_DEV, | |
| 7 | 1590 }; |
| 1591 #else | |
| 76 | 1592 static struct super_block *yaffs2_read_super(struct super_block *sb, |
| 1593 void *data, int silent) | |
| 7 | 1594 { |
| 76 | 1595 return yaffs_internal_read_super(2, sb, data, silent); |
| 7 | 1596 } |
| 1597 | |
| 76 | 1598 static DECLARE_FSTYPE(yaffs2_fs_type, "yaffs2", yaffs2_read_super, |
| 1599 FS_REQUIRES_DEV); | |
| 7 | 1600 #endif |
| 1601 | |
| 76 | 1602 #endif /* CONFIG_YAFFS_YAFFS2 */ |
| 7 | 1603 |
| 1604 static struct proc_dir_entry *my_proc_entry; | |
| 1605 | |
| 76 | 1606 static char *yaffs_dump_dev(char *buf, yaffs_Device * dev) |
| 7 | 1607 { |
| 76 | 1608 buf += sprintf(buf, "startBlock......... %d\n", dev->startBlock); |
| 1609 buf += sprintf(buf, "endBlock........... %d\n", dev->endBlock); | |
| 1610 buf += sprintf(buf, "chunkGroupBits..... %d\n", dev->chunkGroupBits); | |
| 1611 buf += sprintf(buf, "chunkGroupSize..... %d\n", dev->chunkGroupSize); | |
| 1612 buf += sprintf(buf, "nErasedBlocks...... %d\n", dev->nErasedBlocks); | |
| 1613 buf += sprintf(buf, "nTnodesCreated..... %d\n", dev->nTnodesCreated); | |
| 1614 buf += sprintf(buf, "nFreeTnodes........ %d\n", dev->nFreeTnodes); | |
| 1615 buf += sprintf(buf, "nObjectsCreated.... %d\n", dev->nObjectsCreated); | |
| 1616 buf += sprintf(buf, "nFreeObjects....... %d\n", dev->nFreeObjects); | |
| 1617 buf += sprintf(buf, "nFreeChunks........ %d\n", dev->nFreeChunks); | |
| 1618 buf += sprintf(buf, "nPageWrites........ %d\n", dev->nPageWrites); | |
| 1619 buf += sprintf(buf, "nPageReads......... %d\n", dev->nPageReads); | |
| 1620 buf += sprintf(buf, "nBlockErasures..... %d\n", dev->nBlockErasures); | |
| 1621 buf += sprintf(buf, "nGCCopies.......... %d\n", dev->nGCCopies); | |
| 1622 buf += | |
| 1623 sprintf(buf, "garbageCollections. %d\n", dev->garbageCollections); | |
| 1624 buf += | |
| 1625 sprintf(buf, "passiveGCs......... %d\n", | |
| 1626 dev->passiveGarbageCollections); | |
| 1627 buf += sprintf(buf, "nRetriedWrites..... %d\n", dev->nRetriedWrites); | |
| 1628 buf += sprintf(buf, "nRetireBlocks...... %d\n", dev->nRetiredBlocks); | |
| 1629 buf += sprintf(buf, "eccFixed........... %d\n", dev->eccFixed); | |
| 1630 buf += sprintf(buf, "eccUnfixed......... %d\n", dev->eccUnfixed); | |
| 1631 buf += sprintf(buf, "tagsEccFixed....... %d\n", dev->tagsEccFixed); | |
| 1632 buf += sprintf(buf, "tagsEccUnfixed..... %d\n", dev->tagsEccUnfixed); | |
| 1633 buf += sprintf(buf, "cacheHits.......... %d\n", dev->cacheHits); | |
| 1634 buf += sprintf(buf, "nDeletedFiles...... %d\n", dev->nDeletedFiles); | |
| 1635 buf += sprintf(buf, "nUnlinkedFiles..... %d\n", dev->nUnlinkedFiles); | |
| 1636 buf += | |
| 1637 sprintf(buf, "nBackgroudDeletions %d\n", dev->nBackgroundDeletions); | |
| 1638 buf += sprintf(buf, "useNANDECC......... %d\n", dev->useNANDECC); | |
| 1639 buf += sprintf(buf, "isYaffs2........... %d\n", dev->isYaffs2); | |
| 7 | 1640 |
| 76 | 1641 return buf; |
| 7 | 1642 } |
| 1643 | |
| 76 | 1644 static int yaffs_proc_read(char *page, |
| 1645 char **start, | |
| 1646 off_t offset, int count, int *eof, void *data) | |
| 7 | 1647 { |
| 27 | 1648 struct list_head *item; |
| 1649 char *buf = page; | |
| 1650 int step = offset; | |
| 1651 int n = 0; | |
| 7 | 1652 |
| 27 | 1653 /* Get proc_file_read() to step 'offset' by one on each sucessive call. |
| 1654 * We use 'offset' (*ppos) to indicate where we are in devList. | |
| 1655 * This also assumes the user has posted a read buffer large | |
| 1656 * enough to hold the complete output; but that's life in /proc. | |
| 1657 */ | |
| 7 | 1658 |
| 27 | 1659 *(int *)start = 1; |
| 1660 | |
| 1661 /* Print header first */ | |
| 1662 if (step == 0) { | |
| 76 | 1663 buf += sprintf(buf, "YAFFS built:" __DATE__ " " __TIME__ |
| 1664 "\n%s\n%s\n", yaffs_fs_c_version, | |
| 1665 yaffs_guts_c_version); | |
| 27 | 1666 } |
| 7 | 1667 |
| 27 | 1668 /* hold lock_kernel while traversing yaffs_dev_list */ |
| 1669 lock_kernel(); | |
| 7 | 1670 |
| 27 | 1671 /* Locate and print the Nth entry. Order N-squared but N is small. */ |
| 1672 list_for_each(item, &yaffs_dev_list) { | |
| 1673 yaffs_Device *dev = list_entry(item, yaffs_Device, devList); | |
| 1674 if (n < step) { | |
| 1675 n++; | |
| 1676 continue; | |
| 1677 } | |
| 76 | 1678 buf += sprintf(buf, "\nDevice %d \"%s\"\n", n, dev->name); |
| 27 | 1679 buf = yaffs_dump_dev(buf, dev); |
| 1680 break; | |
| 1681 } | |
| 1682 unlock_kernel(); | |
| 1683 | |
| 76 | 1684 return buf - page < count ? buf - page : count; |
| 7 | 1685 } |
| 1686 | |
| 76 | 1687 /* Stuff to handle installation of file systems */ |
| 1688 struct file_system_to_install { | |
| 1689 struct file_system_type *fst; | |
| 1690 int installed; | |
| 7 | 1691 }; |
| 1692 | |
| 76 | 1693 static struct file_system_to_install fs_to_install[] = { |
| 83 | 1694 //#ifdef CONFIG_YAFFS_YAFFS1 |
| 76 | 1695 {&yaffs_fs_type, 0}, |
| 83 | 1696 //#endif |
| 1697 //#ifdef CONFIG_YAFFS_YAFFS2 | |
| 76 | 1698 {&yaffs2_fs_type, 0}, |
| 83 | 1699 //#endif |
| 76 | 1700 {NULL, 0} |
| 7 | 1701 }; |
| 1702 | |
| 1703 static int __init init_yaffs_fs(void) | |
| 1704 { | |
| 1705 int error = 0; | |
| 76 | 1706 struct file_system_to_install *fsinst; |
| 7 | 1707 |
| 76 | 1708 T(YAFFS_TRACE_ALWAYS, |
| 1709 ("yaffs " __DATE__ " " __TIME__ " Installing. \n")); | |
| 7 | 1710 |
| 76 | 1711 /* Install the proc_fs entry */ |
| 1712 my_proc_entry = create_proc_read_entry("yaffs", | |
| 1713 S_IRUGO | S_IFREG, | |
| 1714 &proc_root, | |
| 1715 yaffs_proc_read, NULL); | |
| 1716 if (!my_proc_entry) { | |
| 1717 return -ENOMEM; | |
| 1718 } | |
| 1719 | |
| 1720 /* Now add the file system entries */ | |
| 1721 | |
| 1722 fsinst = fs_to_install; | |
| 7 | 1723 |
| 76 | 1724 while (fsinst->fst && !error) { |
| 1725 error = register_filesystem(fsinst->fst); | |
| 1726 if (!error) { | |
| 1727 fsinst->installed = 1; | |
| 1728 } | |
| 1729 fsinst++; | |
| 1730 } | |
| 1731 | |
| 1732 /* Any errors? uninstall */ | |
| 1733 if (error) { | |
| 1734 fsinst = fs_to_install; | |
| 1735 | |
| 1736 while (fsinst->fst) { | |
| 1737 if (fsinst->installed) { | |
| 1738 unregister_filesystem(fsinst->fst); | |
| 1739 fsinst->installed = 0; | |
| 1740 } | |
| 1741 fsinst++; | |
| 1742 } | |
| 1743 } | |
| 1744 | |
| 1745 return error; | |
| 7 | 1746 } |
| 1747 | |
| 1748 static void __exit exit_yaffs_fs(void) | |
| 1749 { | |
| 1750 | |
| 76 | 1751 struct file_system_to_install *fsinst; |
| 1752 | |
| 1753 T(YAFFS_TRACE_ALWAYS, ("yaffs " __DATE__ " " __TIME__ | |
| 1754 " removing. \n")); | |
| 1755 | |
| 1756 remove_proc_entry("yaffs", &proc_root); | |
| 7 | 1757 |
| 76 | 1758 fsinst = fs_to_install; |
| 1759 | |
| 1760 while (fsinst->fst) { | |
| 1761 if (fsinst->installed) { | |
| 1762 unregister_filesystem(fsinst->fst); | |
| 1763 fsinst->installed = 0; | |
| 1764 } | |
| 1765 fsinst++; | |
| 1766 } | |
| 7 | 1767 |
| 1768 } | |
| 1769 | |
| 1770 module_init(init_yaffs_fs) | |
| 1771 module_exit(exit_yaffs_fs) | |
| 1772 | |
| 1773 MODULE_DESCRIPTION("YAFFS2 - a NAND specific flash file system"); | |
| 1774 MODULE_AUTHOR("Charles Manning, Aleph One Ltd., 2002,2003,2004"); | |
| 1775 MODULE_LICENSE("GPL"); |
