Merge git://git.infradead.org/mtd-2.6

* git://git.infradead.org/mtd-2.6:
[MTD] [NOR] Fix deadlock in Intel chip driver caused by get_chip recursion
[JFFS2] Fix return value from jffs2_write_end()
[MTD] [OneNAND] Fix wrong free the static address in onenand_sim
[MTD] [NAND] Replace -1 with -EBADMSG in nand error correction code
[RSLIB] BUG() when passing illegal parameters to decode_rs8() or decode_rs16()
[MTD] [NAND] treat any negative return value from correct() as an error
[MTD] [NAND] nandsim: bugfix in initialization
[MTD] Fix typo in Alauda config option help text.
[MTD] [NAND] add s3c2440-specific read_buf/write_buf
[MTD] [OneNAND] onenand-sim: fix kernel-doc and typos
[JFFS2] Tidy up fix for ACL/permissions problem.

+226 -199
+77 -69
drivers/mtd/chips/cfi_cmdset_0001.c
··· 85 static void cfi_intelext_unpoint (struct mtd_info *mtd, u_char *addr, loff_t from, 86 size_t len); 87 88 static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr, int mode); 89 static void put_chip(struct map_info *map, struct flchip *chip, unsigned long adr); 90 #include "fwh_lock.h" ··· 642 /* 643 * *********** CHIP ACCESS FUNCTIONS *********** 644 */ 645 - 646 - static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr, int mode) 647 { 648 DECLARE_WAITQUEUE(wait, current); 649 struct cfi_private *cfi = map->fldrv_priv; 650 map_word status, status_OK = CMD(0x80), status_PWS = CMD(0x01); 651 - unsigned long timeo; 652 struct cfi_pri_intelext *cfip = cfi->cmdset_priv; 653 - 654 - resettime: 655 - timeo = jiffies + HZ; 656 - retry: 657 - if (chip->priv && (mode == FL_WRITING || mode == FL_ERASING || mode == FL_OTP_WRITE || mode == FL_SHUTDOWN)) { 658 - /* 659 - * OK. We have possibility for contension on the write/erase 660 - * operations which are global to the real chip and not per 661 - * partition. So let's fight it over in the partition which 662 - * currently has authority on the operation. 663 - * 664 - * The rules are as follows: 665 - * 666 - * - any write operation must own shared->writing. 667 - * 668 - * - any erase operation must own _both_ shared->writing and 669 - * shared->erasing. 670 - * 671 - * - contension arbitration is handled in the owner's context. 672 - * 673 - * The 'shared' struct can be read and/or written only when 674 - * its lock is taken. 675 - */ 676 - struct flchip_shared *shared = chip->priv; 677 - struct flchip *contender; 678 - spin_lock(&shared->lock); 679 - contender = shared->writing; 680 - if (contender && contender != chip) { 681 - /* 682 - * The engine to perform desired operation on this 683 - * partition is already in use by someone else. 684 - * Let's fight over it in the context of the chip 685 - * currently using it. If it is possible to suspend, 686 - * that other partition will do just that, otherwise 687 - * it'll happily send us to sleep. In any case, when 688 - * get_chip returns success we're clear to go ahead. 689 - */ 690 - int ret = spin_trylock(contender->mutex); 691 - spin_unlock(&shared->lock); 692 - if (!ret) 693 - goto retry; 694 - spin_unlock(chip->mutex); 695 - ret = get_chip(map, contender, contender->start, mode); 696 - spin_lock(chip->mutex); 697 - if (ret) { 698 - spin_unlock(contender->mutex); 699 - return ret; 700 - } 701 - timeo = jiffies + HZ; 702 - spin_lock(&shared->lock); 703 - spin_unlock(contender->mutex); 704 - } 705 - 706 - /* We now own it */ 707 - shared->writing = chip; 708 - if (mode == FL_ERASING) 709 - shared->erasing = chip; 710 - spin_unlock(&shared->lock); 711 - } 712 713 switch (chip->state) { 714 ··· 663 if (chip->priv && map_word_andequal(map, status, status_PWS, status_PWS)) 664 break; 665 666 - if (time_after(jiffies, timeo)) { 667 - printk(KERN_ERR "%s: Waiting for chip to be ready timed out. Status %lx\n", 668 - map->name, status.x[0]); 669 - return -EIO; 670 - } 671 spin_unlock(chip->mutex); 672 cfi_udelay(1); 673 spin_lock(chip->mutex); 674 /* Someone else might have been playing with it. */ 675 - goto retry; 676 } 677 678 case FL_READY: ··· 745 schedule(); 746 remove_wait_queue(&chip->wq, &wait); 747 spin_lock(chip->mutex); 748 - goto resettime; 749 } 750 } 751 752 static void put_chip(struct map_info *map, struct flchip *chip, unsigned long adr)
··· 85 static void cfi_intelext_unpoint (struct mtd_info *mtd, u_char *addr, loff_t from, 86 size_t len); 87 88 + static int chip_ready (struct map_info *map, struct flchip *chip, unsigned long adr, int mode); 89 static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr, int mode); 90 static void put_chip(struct map_info *map, struct flchip *chip, unsigned long adr); 91 #include "fwh_lock.h" ··· 641 /* 642 * *********** CHIP ACCESS FUNCTIONS *********** 643 */ 644 + static int chip_ready (struct map_info *map, struct flchip *chip, unsigned long adr, int mode) 645 { 646 DECLARE_WAITQUEUE(wait, current); 647 struct cfi_private *cfi = map->fldrv_priv; 648 map_word status, status_OK = CMD(0x80), status_PWS = CMD(0x01); 649 struct cfi_pri_intelext *cfip = cfi->cmdset_priv; 650 + unsigned long timeo = jiffies + HZ; 651 652 switch (chip->state) { 653 ··· 722 if (chip->priv && map_word_andequal(map, status, status_PWS, status_PWS)) 723 break; 724 725 spin_unlock(chip->mutex); 726 cfi_udelay(1); 727 spin_lock(chip->mutex); 728 /* Someone else might have been playing with it. */ 729 + return -EAGAIN; 730 } 731 732 case FL_READY: ··· 809 schedule(); 810 remove_wait_queue(&chip->wq, &wait); 811 spin_lock(chip->mutex); 812 + return -EAGAIN; 813 } 814 + } 815 + 816 + static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr, int mode) 817 + { 818 + int ret; 819 + 820 + retry: 821 + if (chip->priv && (mode == FL_WRITING || mode == FL_ERASING 822 + || mode == FL_OTP_WRITE || mode == FL_SHUTDOWN)) { 823 + /* 824 + * OK. We have possibility for contention on the write/erase 825 + * operations which are global to the real chip and not per 826 + * partition. So let's fight it over in the partition which 827 + * currently has authority on the operation. 828 + * 829 + * The rules are as follows: 830 + * 831 + * - any write operation must own shared->writing. 832 + * 833 + * - any erase operation must own _both_ shared->writing and 834 + * shared->erasing. 835 + * 836 + * - contention arbitration is handled in the owner's context. 837 + * 838 + * The 'shared' struct can be read and/or written only when 839 + * its lock is taken. 840 + */ 841 + struct flchip_shared *shared = chip->priv; 842 + struct flchip *contender; 843 + spin_lock(&shared->lock); 844 + contender = shared->writing; 845 + if (contender && contender != chip) { 846 + /* 847 + * The engine to perform desired operation on this 848 + * partition is already in use by someone else. 849 + * Let's fight over it in the context of the chip 850 + * currently using it. If it is possible to suspend, 851 + * that other partition will do just that, otherwise 852 + * it'll happily send us to sleep. In any case, when 853 + * get_chip returns success we're clear to go ahead. 854 + */ 855 + ret = spin_trylock(contender->mutex); 856 + spin_unlock(&shared->lock); 857 + if (!ret) 858 + goto retry; 859 + spin_unlock(chip->mutex); 860 + ret = chip_ready(map, contender, contender->start, mode); 861 + spin_lock(chip->mutex); 862 + 863 + if (ret == -EAGAIN) { 864 + spin_unlock(contender->mutex); 865 + goto retry; 866 + } 867 + if (ret) { 868 + spin_unlock(contender->mutex); 869 + return ret; 870 + } 871 + spin_lock(&shared->lock); 872 + spin_unlock(contender->mutex); 873 + } 874 + 875 + /* We now own it */ 876 + shared->writing = chip; 877 + if (mode == FL_ERASING) 878 + shared->erasing = chip; 879 + spin_unlock(&shared->lock); 880 + } 881 + ret = chip_ready(map, chip, adr, mode); 882 + if (ret == -EAGAIN) 883 + goto retry; 884 + 885 + return ret; 886 } 887 888 static void put_chip(struct map_info *map, struct flchip *chip, unsigned long adr)
+1 -1
drivers/mtd/nand/Kconfig
··· 300 via platform_data. 301 302 config MTD_ALAUDA 303 - tristate "MTD driver for Olympus MAUSB-10 and Fijufilm DPC-R1" 304 depends on MTD_NAND && USB 305 help 306 These two (and possibly other) Alauda-based cardreaders for
··· 300 via platform_data. 301 302 config MTD_ALAUDA 303 + tristate "MTD driver for Olympus MAUSB-10 and Fujifilm DPC-R1" 304 depends on MTD_NAND && USB 305 help 306 These two (and possibly other) Alauda-based cardreaders for
+2 -2
drivers/mtd/nand/diskonchip.c
··· 220 } 221 } 222 /* If the parity is wrong, no rescue possible */ 223 - return parity ? -1 : nerr; 224 } 225 226 static void DoC_Delay(struct doc_priv *doc, unsigned short cycles) ··· 1034 WriteDOC(DOC_ECC_DIS, docptr, Mplus_ECCConf); 1035 else 1036 WriteDOC(DOC_ECC_DIS, docptr, ECCConf); 1037 - if (no_ecc_failures && (ret == -1)) { 1038 printk(KERN_ERR "suppressing ECC failure\n"); 1039 ret = 0; 1040 }
··· 220 } 221 } 222 /* If the parity is wrong, no rescue possible */ 223 + return parity ? -EBADMSG : nerr; 224 } 225 226 static void DoC_Delay(struct doc_priv *doc, unsigned short cycles) ··· 1034 WriteDOC(DOC_ECC_DIS, docptr, Mplus_ECCConf); 1035 else 1036 WriteDOC(DOC_ECC_DIS, docptr, ECCConf); 1037 + if (no_ecc_failures && (ret == -EBADMSG)) { 1038 printk(KERN_ERR "suppressing ECC failure\n"); 1039 ret = 0; 1040 }
+3 -3
drivers/mtd/nand/nand_base.c
··· 789 int stat; 790 791 stat = chip->ecc.correct(mtd, p, &ecc_code[i], &ecc_calc[i]); 792 - if (stat == -1) 793 mtd->ecc_stats.failed++; 794 else 795 mtd->ecc_stats.corrected += stat; ··· 833 int stat; 834 835 stat = chip->ecc.correct(mtd, p, &ecc_code[i], &ecc_calc[i]); 836 - if (stat == -1) 837 mtd->ecc_stats.failed++; 838 else 839 mtd->ecc_stats.corrected += stat; ··· 874 chip->read_buf(mtd, oob, eccbytes); 875 stat = chip->ecc.correct(mtd, p, oob, NULL); 876 877 - if (stat == -1) 878 mtd->ecc_stats.failed++; 879 else 880 mtd->ecc_stats.corrected += stat;
··· 789 int stat; 790 791 stat = chip->ecc.correct(mtd, p, &ecc_code[i], &ecc_calc[i]); 792 + if (stat < 0) 793 mtd->ecc_stats.failed++; 794 else 795 mtd->ecc_stats.corrected += stat; ··· 833 int stat; 834 835 stat = chip->ecc.correct(mtd, p, &ecc_code[i], &ecc_calc[i]); 836 + if (stat < 0) 837 mtd->ecc_stats.failed++; 838 else 839 mtd->ecc_stats.corrected += stat; ··· 874 chip->read_buf(mtd, oob, eccbytes); 875 stat = chip->ecc.correct(mtd, p, oob, NULL); 876 877 + if (stat < 0) 878 mtd->ecc_stats.failed++; 879 else 880 mtd->ecc_stats.corrected += stat;
+1 -1
drivers/mtd/nand/nand_ecc.c
··· 189 if(countbits(s0 | ((uint32_t)s1 << 8) | ((uint32_t)s2 <<16)) == 1) 190 return 1; 191 192 - return -1; 193 } 194 EXPORT_SYMBOL(nand_correct_data); 195
··· 189 if(countbits(s0 | ((uint32_t)s1 << 8) | ((uint32_t)s2 <<16)) == 1) 190 return 1; 191 192 + return -EBADMSG; 193 } 194 EXPORT_SYMBOL(nand_correct_data); 195
+1 -1
drivers/mtd/nand/nandsim.c
··· 511 } 512 513 if (ns->options & OPT_SMALLPAGE) { 514 - if (ns->geom.totsz < (64 << 20)) { 515 ns->geom.pgaddrbytes = 3; 516 ns->geom.secaddrbytes = 2; 517 } else {
··· 511 } 512 513 if (ns->options & OPT_SMALLPAGE) { 514 + if (ns->geom.totsz < (32 << 20)) { 515 ns->geom.pgaddrbytes = 3; 516 ns->geom.secaddrbytes = 2; 517 } else {
+14
drivers/mtd/nand/s3c2410.c
··· 488 readsb(this->IO_ADDR_R, buf, len); 489 } 490 491 static void s3c2410_nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len) 492 { 493 struct nand_chip *this = mtd->priv; 494 writesb(this->IO_ADDR_W, buf, len); 495 } 496 497 /* device management functions */ ··· 616 info->sel_bit = S3C2440_NFCONT_nFCE; 617 chip->cmd_ctrl = s3c2440_nand_hwcontrol; 618 chip->dev_ready = s3c2440_nand_devready; 619 break; 620 621 case TYPE_S3C2412:
··· 488 readsb(this->IO_ADDR_R, buf, len); 489 } 490 491 + static void s3c2440_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len) 492 + { 493 + struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd); 494 + readsl(info->regs + S3C2440_NFDATA, buf, len / 4); 495 + } 496 + 497 static void s3c2410_nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len) 498 { 499 struct nand_chip *this = mtd->priv; 500 writesb(this->IO_ADDR_W, buf, len); 501 + } 502 + 503 + static void s3c2440_nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len) 504 + { 505 + struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd); 506 + writesl(info->regs + S3C2440_NFDATA, buf, len / 4); 507 } 508 509 /* device management functions */ ··· 604 info->sel_bit = S3C2440_NFCONT_nFCE; 605 chip->cmd_ctrl = s3c2440_nand_hwcontrol; 606 chip->dev_ready = s3c2440_nand_devready; 607 + chip->read_buf = s3c2440_nand_read_buf; 608 + chip->write_buf = s3c2440_nand_write_buf; 609 break; 610 611 case TYPE_S3C2412:
+25 -25
drivers/mtd/onenand/onenand_sim.c
··· 88 89 /** 90 * onenand_lock_handle - Handle Lock scheme 91 - * @param this OneNAND device structure 92 - * @param cmd The command to be sent 93 * 94 * Send lock command to OneNAND device. 95 - * The lock scheme is depends on chip type. 96 */ 97 static void onenand_lock_handle(struct onenand_chip *this, int cmd) 98 { ··· 131 132 /** 133 * onenand_bootram_handle - Handle BootRAM area 134 - * @param this OneNAND device structure 135 - * @param cmd The command to be sent 136 * 137 * Emulate BootRAM area. It is possible to do basic operation using BootRAM. 138 */ ··· 153 154 /** 155 * onenand_update_interrupt - Set interrupt register 156 - * @param this OneNAND device structure 157 - * @param cmd The command to be sent 158 * 159 - * Update interrupt register. The status is depends on command. 160 */ 161 static void onenand_update_interrupt(struct onenand_chip *this, int cmd) 162 { ··· 189 } 190 191 /** 192 - * onenand_check_overwrite - Check over-write if happend 193 - * @param dest The destination pointer 194 - * @param src The source pointer 195 - * @param count The length to be check 196 - * @return 0 on same, otherwise 1 197 * 198 * Compare the source with destination 199 */ ··· 214 215 /** 216 * onenand_data_handle - Handle OneNAND Core and DataRAM 217 - * @param this OneNAND device structure 218 - * @param cmd The command to be sent 219 - * @param dataram Which dataram used 220 - * @param offset The offset to OneNAND Core 221 * 222 * Copy data from OneNAND Core to DataRAM (read) 223 * Copy data from DataRAM to OneNAND Core (write) ··· 296 297 /** 298 * onenand_command_handle - Handle command 299 - * @param this OneNAND device structure 300 - * @param cmd The command to be sent 301 * 302 * Emulate OneNAND command. 303 */ ··· 351 352 /** 353 * onenand_writew - [OneNAND Interface] Emulate write operation 354 - * @param value value to write 355 - * @param addr address to write 356 * 357 * Write OneNAND register with value 358 */ ··· 374 375 /** 376 * flash_init - Initialize OneNAND simulator 377 - * @param flash OneNAND simulaotr data strucutres 378 * 379 * Initialize OneNAND simulator. 380 */ ··· 417 418 /** 419 * flash_exit - Clean up OneNAND simulator 420 - * @param flash OneNAND simulaotr data strucutres 421 * 422 * Clean up OneNAND simulator. 423 */ ··· 425 { 426 vfree(ONENAND_CORE(flash)); 427 kfree(flash->base); 428 - kfree(flash); 429 } 430 431 static int __init onenand_sim_init(void) ··· 449 info->onenand.write_word = onenand_writew; 450 451 if (flash_init(&info->flash)) { 452 - printk(KERN_ERR "Unable to allocat flash.\n"); 453 kfree(ffchars); 454 kfree(info); 455 return -ENOMEM;
··· 88 89 /** 90 * onenand_lock_handle - Handle Lock scheme 91 + * @this: OneNAND device structure 92 + * @cmd: The command to be sent 93 * 94 * Send lock command to OneNAND device. 95 + * The lock scheme depends on chip type. 96 */ 97 static void onenand_lock_handle(struct onenand_chip *this, int cmd) 98 { ··· 131 132 /** 133 * onenand_bootram_handle - Handle BootRAM area 134 + * @this: OneNAND device structure 135 + * @cmd: The command to be sent 136 * 137 * Emulate BootRAM area. It is possible to do basic operation using BootRAM. 138 */ ··· 153 154 /** 155 * onenand_update_interrupt - Set interrupt register 156 + * @this: OneNAND device structure 157 + * @cmd: The command to be sent 158 * 159 + * Update interrupt register. The status depends on command. 160 */ 161 static void onenand_update_interrupt(struct onenand_chip *this, int cmd) 162 { ··· 189 } 190 191 /** 192 + * onenand_check_overwrite - Check if over-write happened 193 + * @dest: The destination pointer 194 + * @src: The source pointer 195 + * @count: The length to be check 196 + * 197 + * Returns: 0 on same, otherwise 1 198 * 199 * Compare the source with destination 200 */ ··· 213 214 /** 215 * onenand_data_handle - Handle OneNAND Core and DataRAM 216 + * @this: OneNAND device structure 217 + * @cmd: The command to be sent 218 + * @dataram: Which dataram used 219 + * @offset: The offset to OneNAND Core 220 * 221 * Copy data from OneNAND Core to DataRAM (read) 222 * Copy data from DataRAM to OneNAND Core (write) ··· 295 296 /** 297 * onenand_command_handle - Handle command 298 + * @this: OneNAND device structure 299 + * @cmd: The command to be sent 300 * 301 * Emulate OneNAND command. 302 */ ··· 350 351 /** 352 * onenand_writew - [OneNAND Interface] Emulate write operation 353 + * @value: value to write 354 + * @addr: address to write 355 * 356 * Write OneNAND register with value 357 */ ··· 373 374 /** 375 * flash_init - Initialize OneNAND simulator 376 + * @flash: OneNAND simulator data strucutres 377 * 378 * Initialize OneNAND simulator. 379 */ ··· 416 417 /** 418 * flash_exit - Clean up OneNAND simulator 419 + * @flash: OneNAND simulator data structures 420 * 421 * Clean up OneNAND simulator. 422 */ ··· 424 { 425 vfree(ONENAND_CORE(flash)); 426 kfree(flash->base); 427 } 428 429 static int __init onenand_sim_init(void) ··· 449 info->onenand.write_word = onenand_writew; 450 451 if (flash_init(&info->flash)) { 452 + printk(KERN_ERR "Unable to allocate flash.\n"); 453 kfree(ffchars); 454 kfree(info); 455 return -ENOMEM;
+65 -36
fs/jffs2/acl.c
··· 228 return acl; 229 } 230 231 static int jffs2_set_acl(struct inode *inode, int type, struct posix_acl *acl) 232 { 233 struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode); 234 - size_t size = 0; 235 - char *value = NULL; 236 int rc, xprefix; 237 238 if (S_ISLNK(inode->i_mode)) ··· 284 default: 285 return -EINVAL; 286 } 287 - if (acl) { 288 - value = jffs2_acl_to_medium(acl, &size); 289 - if (IS_ERR(value)) 290 - return PTR_ERR(value); 291 - } 292 - 293 - rc = do_jffs2_setxattr(inode, xprefix, "", value, size, 0); 294 - if (!value && rc == -ENODATA) 295 - rc = 0; 296 - if (value) 297 - kfree(value); 298 if (!rc) { 299 switch(type) { 300 case ACL_TYPE_ACCESS: ··· 319 return generic_permission(inode, mask, jffs2_check_acl); 320 } 321 322 - int jffs2_init_acl(struct inode *inode, struct posix_acl *acl) 323 { 324 struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode); 325 - struct posix_acl *clone; 326 - mode_t mode; 327 - int rc = 0; 328 329 - f->i_acl_access = JFFS2_ACL_NOT_CACHED; 330 - f->i_acl_default = JFFS2_ACL_NOT_CACHED; 331 332 - if (acl) { 333 - if (S_ISDIR(inode->i_mode)) { 334 - rc = jffs2_set_acl(inode, ACL_TYPE_DEFAULT, acl); 335 - if (rc) 336 - goto cleanup; 337 - } 338 clone = posix_acl_clone(acl, GFP_KERNEL); 339 - rc = -ENOMEM; 340 if (!clone) 341 - goto cleanup; 342 - mode = inode->i_mode; 343 - rc = posix_acl_create_masq(clone, &mode); 344 - if (rc >= 0) { 345 - inode->i_mode = mode; 346 - if (rc > 0) 347 - rc = jffs2_set_acl(inode, ACL_TYPE_ACCESS, clone); 348 - } 349 posix_acl_release(clone); 350 } 351 - cleanup: 352 - posix_acl_release(acl); 353 return rc; 354 } 355
··· 228 return acl; 229 } 230 231 + static int __jffs2_set_acl(struct inode *inode, int xprefix, struct posix_acl *acl) 232 + { 233 + char *value = NULL; 234 + size_t size = 0; 235 + int rc; 236 + 237 + if (acl) { 238 + value = jffs2_acl_to_medium(acl, &size); 239 + if (IS_ERR(value)) 240 + return PTR_ERR(value); 241 + } 242 + rc = do_jffs2_setxattr(inode, xprefix, "", value, size, 0); 243 + if (!value && rc == -ENODATA) 244 + rc = 0; 245 + kfree(value); 246 + 247 + return rc; 248 + } 249 + 250 static int jffs2_set_acl(struct inode *inode, int type, struct posix_acl *acl) 251 { 252 struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode); 253 int rc, xprefix; 254 255 if (S_ISLNK(inode->i_mode)) ··· 267 default: 268 return -EINVAL; 269 } 270 + rc = __jffs2_set_acl(inode, xprefix, acl); 271 if (!rc) { 272 switch(type) { 273 case ACL_TYPE_ACCESS: ··· 312 return generic_permission(inode, mask, jffs2_check_acl); 313 } 314 315 + int jffs2_init_acl_pre(struct inode *dir_i, struct inode *inode, int *i_mode) 316 { 317 struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode); 318 + struct posix_acl *acl, *clone; 319 + int rc; 320 321 + f->i_acl_default = NULL; 322 + f->i_acl_access = NULL; 323 324 + if (S_ISLNK(*i_mode)) 325 + return 0; /* Symlink always has no-ACL */ 326 + 327 + acl = jffs2_get_acl(dir_i, ACL_TYPE_DEFAULT); 328 + if (IS_ERR(acl)) 329 + return PTR_ERR(acl); 330 + 331 + if (!acl) { 332 + *i_mode &= ~current->fs->umask; 333 + } else { 334 + if (S_ISDIR(*i_mode)) 335 + jffs2_iset_acl(inode, &f->i_acl_default, acl); 336 + 337 clone = posix_acl_clone(acl, GFP_KERNEL); 338 if (!clone) 339 + return -ENOMEM; 340 + rc = posix_acl_create_masq(clone, (mode_t *)i_mode); 341 + if (rc < 0) 342 + return rc; 343 + if (rc > 0) 344 + jffs2_iset_acl(inode, &f->i_acl_access, clone); 345 + 346 posix_acl_release(clone); 347 } 348 + return 0; 349 + } 350 + 351 + int jffs2_init_acl_post(struct inode *inode) 352 + { 353 + struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode); 354 + int rc; 355 + 356 + if (f->i_acl_default) { 357 + rc = __jffs2_set_acl(inode, JFFS2_XPREFIX_ACL_DEFAULT, f->i_acl_default); 358 + if (rc) 359 + return rc; 360 + } 361 + 362 + if (f->i_acl_access) { 363 + rc = __jffs2_set_acl(inode, JFFS2_XPREFIX_ACL_ACCESS, f->i_acl_access); 364 + if (rc) 365 + return rc; 366 + } 367 + 368 return rc; 369 } 370
+7 -5
fs/jffs2/acl.h
··· 31 extern struct posix_acl *jffs2_get_acl(struct inode *inode, int type); 32 extern int jffs2_permission(struct inode *, int, struct nameidata *); 33 extern int jffs2_acl_chmod(struct inode *); 34 - extern int jffs2_init_acl(struct inode *, struct posix_acl *); 35 extern void jffs2_clear_acl(struct jffs2_inode_info *); 36 37 extern struct xattr_handler jffs2_acl_access_xattr_handler; ··· 40 41 #else 42 43 - #define jffs2_get_acl(inode, type) (NULL) 44 - #define jffs2_permission NULL 45 - #define jffs2_acl_chmod(inode) (0) 46 - #define jffs2_init_acl(inode,dir) (0) 47 #define jffs2_clear_acl(f) 48 49 #endif /* CONFIG_JFFS2_FS_POSIX_ACL */
··· 31 extern struct posix_acl *jffs2_get_acl(struct inode *inode, int type); 32 extern int jffs2_permission(struct inode *, int, struct nameidata *); 33 extern int jffs2_acl_chmod(struct inode *); 34 + extern int jffs2_init_acl_pre(struct inode *, struct inode *, int *); 35 + extern int jffs2_init_acl_post(struct inode *); 36 extern void jffs2_clear_acl(struct jffs2_inode_info *); 37 38 extern struct xattr_handler jffs2_acl_access_xattr_handler; ··· 39 40 #else 41 42 + #define jffs2_get_acl(inode, type) (NULL) 43 + #define jffs2_permission (NULL) 44 + #define jffs2_acl_chmod(inode) (0) 45 + #define jffs2_init_acl_pre(dir_i,inode,mode) (0) 46 + #define jffs2_init_acl_post(inode) (0) 47 #define jffs2_clear_acl(f) 48 49 #endif /* CONFIG_JFFS2_FS_POSIX_ACL */
+7 -28
fs/jffs2/dir.c
··· 182 struct jffs2_inode_info *f, *dir_f; 183 struct jffs2_sb_info *c; 184 struct inode *inode; 185 - struct posix_acl *acl; 186 int ret; 187 188 ri = jffs2_alloc_raw_inode(); ··· 192 193 D1(printk(KERN_DEBUG "jffs2_create()\n")); 194 195 - inode = jffs2_new_inode(dir_i, mode, ri, &acl); 196 197 if (IS_ERR(inode)) { 198 D1(printk(KERN_DEBUG "jffs2_new_inode() failed\n")); ··· 210 211 ret = jffs2_do_create(c, dir_f, f, ri, 212 dentry->d_name.name, dentry->d_name.len); 213 - 214 - if (ret) 215 - goto fail_acl; 216 - 217 - ret = jffs2_init_security(inode, dir_i); 218 - if (ret) 219 - goto fail_acl; 220 - ret = jffs2_init_acl(inode, acl); 221 if (ret) 222 goto fail; 223 ··· 222 inode->i_ino, inode->i_mode, inode->i_nlink, f->inocache->nlink, inode->i_mapping->nrpages)); 223 return 0; 224 225 - fail_acl: 226 - posix_acl_release(acl); 227 fail: 228 make_bad_inode(inode); 229 iput(inode); ··· 298 struct jffs2_full_dirent *fd; 299 int namelen; 300 uint32_t alloclen; 301 - struct posix_acl *acl; 302 int ret, targetlen = strlen(target); 303 304 /* FIXME: If you care. We'd need to use frags for the target ··· 324 return ret; 325 } 326 327 - inode = jffs2_new_inode(dir_i, S_IFLNK | S_IRWXUGO, ri, &acl); 328 329 if (IS_ERR(inode)) { 330 jffs2_free_raw_inode(ri); ··· 354 up(&f->sem); 355 jffs2_complete_reservation(c); 356 jffs2_clear_inode(inode); 357 - posix_acl_release(acl); 358 return PTR_ERR(fn); 359 } 360 ··· 364 up(&f->sem); 365 jffs2_complete_reservation(c); 366 jffs2_clear_inode(inode); 367 - posix_acl_release(acl); 368 return -ENOMEM; 369 } 370 ··· 381 ret = jffs2_init_security(inode, dir_i); 382 if (ret) { 383 jffs2_clear_inode(inode); 384 - posix_acl_release(acl); 385 return ret; 386 } 387 - ret = jffs2_init_acl(inode, acl); 388 if (ret) { 389 jffs2_clear_inode(inode); 390 return ret; ··· 461 struct jffs2_full_dirent *fd; 462 int namelen; 463 uint32_t alloclen; 464 - struct posix_acl *acl; 465 int ret; 466 467 mode |= S_IFDIR; ··· 483 return ret; 484 } 485 486 - inode = jffs2_new_inode(dir_i, mode, ri, &acl); 487 488 if (IS_ERR(inode)) { 489 jffs2_free_raw_inode(ri); ··· 510 up(&f->sem); 511 jffs2_complete_reservation(c); 512 jffs2_clear_inode(inode); 513 - posix_acl_release(acl); 514 return PTR_ERR(fn); 515 } 516 /* No data here. Only a metadata node, which will be ··· 523 ret = jffs2_init_security(inode, dir_i); 524 if (ret) { 525 jffs2_clear_inode(inode); 526 - posix_acl_release(acl); 527 return ret; 528 } 529 - ret = jffs2_init_acl(inode, acl); 530 if (ret) { 531 jffs2_clear_inode(inode); 532 return ret; ··· 621 union jffs2_device_node dev; 622 int devlen = 0; 623 uint32_t alloclen; 624 - struct posix_acl *acl; 625 int ret; 626 627 if (!new_valid_dev(rdev)) ··· 647 return ret; 648 } 649 650 - inode = jffs2_new_inode(dir_i, mode, ri, &acl); 651 652 if (IS_ERR(inode)) { 653 jffs2_free_raw_inode(ri); ··· 676 up(&f->sem); 677 jffs2_complete_reservation(c); 678 jffs2_clear_inode(inode); 679 - posix_acl_release(acl); 680 return PTR_ERR(fn); 681 } 682 /* No data here. Only a metadata node, which will be ··· 689 ret = jffs2_init_security(inode, dir_i); 690 if (ret) { 691 jffs2_clear_inode(inode); 692 - posix_acl_release(acl); 693 return ret; 694 } 695 - ret = jffs2_init_acl(inode, acl); 696 if (ret) { 697 jffs2_clear_inode(inode); 698 return ret;
··· 182 struct jffs2_inode_info *f, *dir_f; 183 struct jffs2_sb_info *c; 184 struct inode *inode; 185 int ret; 186 187 ri = jffs2_alloc_raw_inode(); ··· 193 194 D1(printk(KERN_DEBUG "jffs2_create()\n")); 195 196 + inode = jffs2_new_inode(dir_i, mode, ri); 197 198 if (IS_ERR(inode)) { 199 D1(printk(KERN_DEBUG "jffs2_new_inode() failed\n")); ··· 211 212 ret = jffs2_do_create(c, dir_f, f, ri, 213 dentry->d_name.name, dentry->d_name.len); 214 if (ret) 215 goto fail; 216 ··· 231 inode->i_ino, inode->i_mode, inode->i_nlink, f->inocache->nlink, inode->i_mapping->nrpages)); 232 return 0; 233 234 fail: 235 make_bad_inode(inode); 236 iput(inode); ··· 309 struct jffs2_full_dirent *fd; 310 int namelen; 311 uint32_t alloclen; 312 int ret, targetlen = strlen(target); 313 314 /* FIXME: If you care. We'd need to use frags for the target ··· 336 return ret; 337 } 338 339 + inode = jffs2_new_inode(dir_i, S_IFLNK | S_IRWXUGO, ri); 340 341 if (IS_ERR(inode)) { 342 jffs2_free_raw_inode(ri); ··· 366 up(&f->sem); 367 jffs2_complete_reservation(c); 368 jffs2_clear_inode(inode); 369 return PTR_ERR(fn); 370 } 371 ··· 377 up(&f->sem); 378 jffs2_complete_reservation(c); 379 jffs2_clear_inode(inode); 380 return -ENOMEM; 381 } 382 ··· 395 ret = jffs2_init_security(inode, dir_i); 396 if (ret) { 397 jffs2_clear_inode(inode); 398 return ret; 399 } 400 + ret = jffs2_init_acl_post(inode); 401 if (ret) { 402 jffs2_clear_inode(inode); 403 return ret; ··· 476 struct jffs2_full_dirent *fd; 477 int namelen; 478 uint32_t alloclen; 479 int ret; 480 481 mode |= S_IFDIR; ··· 499 return ret; 500 } 501 502 + inode = jffs2_new_inode(dir_i, mode, ri); 503 504 if (IS_ERR(inode)) { 505 jffs2_free_raw_inode(ri); ··· 526 up(&f->sem); 527 jffs2_complete_reservation(c); 528 jffs2_clear_inode(inode); 529 return PTR_ERR(fn); 530 } 531 /* No data here. Only a metadata node, which will be ··· 540 ret = jffs2_init_security(inode, dir_i); 541 if (ret) { 542 jffs2_clear_inode(inode); 543 return ret; 544 } 545 + ret = jffs2_init_acl_post(inode); 546 if (ret) { 547 jffs2_clear_inode(inode); 548 return ret; ··· 639 union jffs2_device_node dev; 640 int devlen = 0; 641 uint32_t alloclen; 642 int ret; 643 644 if (!new_valid_dev(rdev)) ··· 666 return ret; 667 } 668 669 + inode = jffs2_new_inode(dir_i, mode, ri); 670 671 if (IS_ERR(inode)) { 672 jffs2_free_raw_inode(ri); ··· 695 up(&f->sem); 696 jffs2_complete_reservation(c); 697 jffs2_clear_inode(inode); 698 return PTR_ERR(fn); 699 } 700 /* No data here. Only a metadata node, which will be ··· 709 ret = jffs2_init_security(inode, dir_i); 710 if (ret) { 711 jffs2_clear_inode(inode); 712 return ret; 713 } 714 + ret = jffs2_init_acl_post(inode); 715 if (ret) { 716 jffs2_clear_inode(inode); 717 return ret;
+4 -7
fs/jffs2/file.c
··· 255 _whole_ page. This helps to reduce the number of 256 nodes in files which have many short writes, like 257 syslog files. */ 258 - start = aligned_start = 0; 259 } 260 261 ri = jffs2_alloc_raw_inode(); ··· 291 } 292 293 /* Adjust writtenlen for the padding we did, so we don't confuse our caller */ 294 - if (writtenlen < (start&3)) 295 - writtenlen = 0; 296 - else 297 - writtenlen -= (start&3); 298 299 if (writtenlen) { 300 - if (inode->i_size < (pg->index << PAGE_CACHE_SHIFT) + start + writtenlen) { 301 - inode->i_size = (pg->index << PAGE_CACHE_SHIFT) + start + writtenlen; 302 inode->i_blocks = (inode->i_size + 511) >> 9; 303 304 inode->i_ctime = inode->i_mtime = ITIME(je32_to_cpu(ri->ctime));
··· 255 _whole_ page. This helps to reduce the number of 256 nodes in files which have many short writes, like 257 syslog files. */ 258 + aligned_start = 0; 259 } 260 261 ri = jffs2_alloc_raw_inode(); ··· 291 } 292 293 /* Adjust writtenlen for the padding we did, so we don't confuse our caller */ 294 + writtenlen -= min(writtenlen, (start - aligned_start)); 295 296 if (writtenlen) { 297 + if (inode->i_size < pos + writtenlen) { 298 + inode->i_size = pos + writtenlen; 299 inode->i_blocks = (inode->i_size + 511) >> 9; 300 301 inode->i_ctime = inode->i_mtime = ITIME(je32_to_cpu(ri->ctime));
+6 -15
fs/jffs2/fs.c
··· 402 403 /* jffs2_new_inode: allocate a new inode and inocache, add it to the hash, 404 fill in the raw_inode while you're at it. */ 405 - struct inode *jffs2_new_inode (struct inode *dir_i, int mode, struct jffs2_raw_inode *ri, 406 - struct posix_acl **acl) 407 { 408 struct inode *inode; 409 struct super_block *sb = dir_i->i_sb; ··· 437 438 /* POSIX ACLs have to be processed now, at least partly. 439 The umask is only applied if there's no default ACL */ 440 - if (!S_ISLNK(mode)) { 441 - *acl = jffs2_get_acl(dir_i, ACL_TYPE_DEFAULT); 442 - if (IS_ERR(*acl)) { 443 - make_bad_inode(inode); 444 - iput(inode); 445 - inode = (void *)*acl; 446 - *acl = NULL; 447 - return inode; 448 - } 449 - if (!(*acl)) 450 - mode &= ~current->fs->umask; 451 - } else { 452 - *acl = NULL; 453 } 454 ret = jffs2_do_new_inode (c, f, mode, ri); 455 if (ret) {
··· 402 403 /* jffs2_new_inode: allocate a new inode and inocache, add it to the hash, 404 fill in the raw_inode while you're at it. */ 405 + struct inode *jffs2_new_inode (struct inode *dir_i, int mode, struct jffs2_raw_inode *ri) 406 { 407 struct inode *inode; 408 struct super_block *sb = dir_i->i_sb; ··· 438 439 /* POSIX ACLs have to be processed now, at least partly. 440 The umask is only applied if there's no default ACL */ 441 + ret = jffs2_init_acl_pre(dir_i, inode, &mode); 442 + if (ret) { 443 + make_bad_inode(inode); 444 + iput(inode); 445 + return ERR_PTR(ret); 446 } 447 ret = jffs2_do_new_inode (c, f, mode, ri); 448 if (ret) {
+1 -3
fs/jffs2/os-linux.h
··· 173 extern const struct inode_operations jffs2_symlink_inode_operations; 174 175 /* fs.c */ 176 - struct posix_acl; 177 - 178 int jffs2_setattr (struct dentry *, struct iattr *); 179 int jffs2_do_setattr (struct inode *, struct iattr *); 180 void jffs2_read_inode (struct inode *); 181 void jffs2_clear_inode (struct inode *); 182 void jffs2_dirty_inode(struct inode *inode); 183 struct inode *jffs2_new_inode (struct inode *dir_i, int mode, 184 - struct jffs2_raw_inode *ri, struct posix_acl **acl); 185 int jffs2_statfs (struct dentry *, struct kstatfs *); 186 void jffs2_write_super (struct super_block *); 187 int jffs2_remount_fs (struct super_block *, int *, char *);
··· 173 extern const struct inode_operations jffs2_symlink_inode_operations; 174 175 /* fs.c */ 176 int jffs2_setattr (struct dentry *, struct iattr *); 177 int jffs2_do_setattr (struct inode *, struct iattr *); 178 void jffs2_read_inode (struct inode *); 179 void jffs2_clear_inode (struct inode *); 180 void jffs2_dirty_inode(struct inode *inode); 181 struct inode *jffs2_new_inode (struct inode *dir_i, int mode, 182 + struct jffs2_raw_inode *ri); 183 int jffs2_statfs (struct dentry *, struct kstatfs *); 184 void jffs2_write_super (struct super_block *); 185 int jffs2_remount_fs (struct super_block *, int *, char *);
+8
fs/jffs2/write.c
··· 465 466 up(&f->sem); 467 jffs2_complete_reservation(c); 468 ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &alloclen, 469 ALLOC_NORMAL, JFFS2_SUMMARY_DIRENT_SIZE(namelen)); 470
··· 465 466 up(&f->sem); 467 jffs2_complete_reservation(c); 468 + 469 + ret = jffs2_init_security(&f->vfs_inode, &dir_f->vfs_inode); 470 + if (ret) 471 + return ret; 472 + ret = jffs2_init_acl_post(&f->vfs_inode); 473 + if (ret) 474 + return ret; 475 + 476 ret = jffs2_reserve_space(c, sizeof(*rd)+namelen, &alloclen, 477 ALLOC_NORMAL, JFFS2_SUMMARY_DIRENT_SIZE(namelen)); 478
+2 -3
lib/reed_solomon/decode_rs.c
··· 39 40 /* Check length parameter for validity */ 41 pad = nn - nroots - len; 42 - if (pad < 0 || pad >= nn) 43 - return -ERANGE; 44 45 /* Does the caller provide the syndrome ? */ 46 if (s != NULL) ··· 202 * deg(lambda) unequal to number of roots => uncorrectable 203 * error detected 204 */ 205 - count = -1; 206 goto finish; 207 } 208 /*
··· 39 40 /* Check length parameter for validity */ 41 pad = nn - nroots - len; 42 + BUG_ON(pad < 0 || pad >= nn); 43 44 /* Does the caller provide the syndrome ? */ 45 if (s != NULL) ··· 203 * deg(lambda) unequal to number of roots => uncorrectable 204 * error detected 205 */ 206 + count = -EBADMSG; 207 goto finish; 208 } 209 /*
+2
lib/reed_solomon/reed_solomon.c
··· 320 * The syndrome and parity uses a uint16_t data type to enable 321 * symbol size > 8. The calling code must take care of decoding of the 322 * syndrome result and the received parity before calling this code. 323 */ 324 int decode_rs8(struct rs_control *rs, uint8_t *data, uint16_t *par, int len, 325 uint16_t *s, int no_eras, int *eras_pos, uint16_t invmsk, ··· 364 * @corr: buffer to store correction bitmask on eras_pos 365 * 366 * Each field in the data array contains up to symbol size bits of valid data. 367 */ 368 int decode_rs16(struct rs_control *rs, uint16_t *data, uint16_t *par, int len, 369 uint16_t *s, int no_eras, int *eras_pos, uint16_t invmsk,
··· 320 * The syndrome and parity uses a uint16_t data type to enable 321 * symbol size > 8. The calling code must take care of decoding of the 322 * syndrome result and the received parity before calling this code. 323 + * Returns the number of corrected bits or -EBADMSG for uncorrectable errors. 324 */ 325 int decode_rs8(struct rs_control *rs, uint8_t *data, uint16_t *par, int len, 326 uint16_t *s, int no_eras, int *eras_pos, uint16_t invmsk, ··· 363 * @corr: buffer to store correction bitmask on eras_pos 364 * 365 * Each field in the data array contains up to symbol size bits of valid data. 366 + * Returns the number of corrected bits or -EBADMSG for uncorrectable errors. 367 */ 368 int decode_rs16(struct rs_control *rs, uint16_t *data, uint16_t *par, int len, 369 uint16_t *s, int no_eras, int *eras_pos, uint16_t invmsk,