|
|
1.1 ! root 1: diff -u -r -N linux-2.3.99-pre3/fs/fat/cvf.c linux-2.3.99-pre3-cvf-fat-2.0/fs/fat/cvf.c ! 2: --- linux-2.3.99-pre3/fs/fat/cvf.c Mon Aug 9 20:43:49 1999 ! 3: +++ linux-2.3.99-pre3-cvf-fat-2.0/fs/fat/cvf.c Fri Apr 14 13:17:46 2000 ! 4: @@ -4,7 +4,7 @@ ! 5: * written 1997,1998 by Frank Gockel <[email protected]> ! 6: * ! 7: * please do not remove the next line, dmsdos needs it for verifying patches ! 8: - * CVF-FAT-VERSION-ID: 1.2.0 ! 9: + * CVF-FAT-VERSION-ID: 2.0.0 ! 10: * ! 11: */ ! 12: ! 13: @@ -21,6 +21,7 @@ ! 14: ! 15: #define MAX_CVF_FORMATS 3 ! 16: ! 17: +extern struct address_space_operations fat_aops; ! 18: struct buffer_head *default_fat_bread(struct super_block *,int); ! 19: struct buffer_head *default_fat_getblk(struct super_block *, int); ! 20: struct buffer_head *bigblock_fat_bread(struct super_block *, int); ! 21: @@ -52,10 +53,10 @@ ! 22: size_t count, ! 23: loff_t *ppos); ! 24: ! 25: -struct cvf_format default_cvf = { ! 26: +struct cvf_format default_transparent = { ! 27: 0, /* version - who cares? */ ! 28: - "plain", ! 29: - 0, /* flags - who cares? */ ! 30: + "none-default", ! 31: + CVF_TRANSPARENT, /* flags - who cares? */ ! 32: NULL, ! 33: NULL, ! 34: NULL, ! 35: @@ -70,15 +71,17 @@ ! 36: NULL, ! 37: default_fat_bmap, ! 38: generic_file_read, ! 39: - default_fat_file_write, ! 40: + generic_file_write, ! 41: + generic_file_mmap, ! 42: + &fat_aops, ! 43: NULL, ! 44: NULL ! 45: }; ! 46: ! 47: -struct cvf_format bigblock_cvf = { ! 48: +struct cvf_format bigblock_transparent = { ! 49: 0, /* version - who cares? */ ! 50: - "big_blocks", ! 51: - 0, /* flags - who cares? */ ! 52: + "none-bigblocks", ! 53: + CVF_TRANSPARENT|CVF_BIGBLOCK, /* flags - who cares? */ ! 54: NULL, ! 55: NULL, ! 56: NULL, ! 57: @@ -92,8 +95,10 @@ ! 58: default_fat_access, ! 59: NULL, ! 60: default_fat_bmap, ! 61: - NULL, ! 62: - default_fat_file_write, ! 63: + generic_file_read, /* why not generic_file_read ?*/ ! 64: + generic_file_write, ! 65: + generic_file_mmap, ! 66: + &fat_aops, ! 67: NULL, ! 68: NULL ! 69: }; ! 70: diff -u -r -N linux-2.3.99-pre3/fs/fat/fatfs_syms.c linux-2.3.99-pre3-cvf-fat-2.0/fs/fat/fatfs_syms.c ! 71: --- linux-2.3.99-pre3/fs/fat/fatfs_syms.c Mon Mar 13 21:35:39 2000 ! 72: +++ linux-2.3.99-pre3-cvf-fat-2.0/fs/fat/fatfs_syms.c Fri Apr 14 13:17:46 2000 ! 73: @@ -52,6 +52,7 @@ ! 74: EXPORT_SYMBOL(unlock_fat); ! 75: EXPORT_SYMBOL(fat_dir_ioctl); ! 76: EXPORT_SYMBOL(fat_add_entries); ! 77: +EXPORT_SYMBOL(fat_add_cluster); ! 78: EXPORT_SYMBOL(fat_dir_empty); ! 79: EXPORT_SYMBOL(fat_truncate); ! 80: ! 81: diff -u -r -N linux-2.3.99-pre3/fs/fat/file.c linux-2.3.99-pre3-cvf-fat-2.0/fs/fat/file.c ! 82: --- linux-2.3.99-pre3/fs/fat/file.c Sun Feb 27 05:33:42 2000 ! 83: +++ linux-2.3.99-pre3-cvf-fat-2.0/fs/fat/file.c Fri Apr 14 13:17:46 2000 ! 84: @@ -33,7 +33,7 @@ ! 85: struct file_operations fat_file_operations = { ! 86: read: fat_file_read, ! 87: write: fat_file_write, ! 88: - mmap: generic_file_mmap, ! 89: + mmap: fat_file_mmap, ! 90: fsync: file_fsync, ! 91: }; ! 92: ! 93: @@ -90,22 +90,12 @@ ! 94: size_t count, ! 95: loff_t *ppos) ! 96: { ! 97: + int retval; ! 98: struct inode *inode = filp->f_dentry->d_inode; ! 99: struct super_block *sb = inode->i_sb; ! 100: - return MSDOS_SB(sb)->cvf_format ! 101: + retval = MSDOS_SB(sb)->cvf_format ! 102: ->cvf_file_write(filp,buf,count,ppos); ! 103: -} ! 104: - ! 105: -ssize_t default_fat_file_write( ! 106: - struct file *filp, ! 107: - const char *buf, ! 108: - size_t count, ! 109: - loff_t *ppos) ! 110: -{ ! 111: - struct inode *inode = filp->f_dentry->d_inode; ! 112: - int retval; ! 113: - ! 114: - retval = generic_file_write(filp, buf, count, ppos); ! 115: + ! 116: if (retval > 0) { ! 117: inode->i_mtime = inode->i_ctime = CURRENT_TIME; ! 118: MSDOS_I(inode)->i_attrs |= ATTR_ARCH; ! 119: @@ -131,3 +121,11 @@ ! 120: inode->i_ctime = inode->i_mtime = CURRENT_TIME; ! 121: mark_inode_dirty(inode); ! 122: } ! 123: + ! 124: +int fat_file_mmap(struct file * filp, struct vm_area_struct * vma) ! 125: +{ ! 126: + struct inode *inode = filp->f_dentry->d_inode; ! 127: + return MSDOS_SB(inode->i_sb)->cvf_format ! 128: + ->cvf_mmap(filp,vma); ! 129: + ! 130: +} ! 131: \ No newline at end of file ! 132: diff -u -r -N linux-2.3.99-pre3/fs/fat/inode.c linux-2.3.99-pre3-cvf-fat-2.0/fs/fat/inode.c ! 133: --- linux-2.3.99-pre3/fs/fat/inode.c Tue Mar 21 20:30:08 2000 ! 134: +++ linux-2.3.99-pre3-cvf-fat-2.0/fs/fat/inode.c Fri Apr 14 13:17:46 2000 ! 135: @@ -33,7 +33,7 @@ ! 136: #include <asm/uaccess.h> ! 137: #include <asm/unaligned.h> ! 138: ! 139: -extern struct cvf_format default_cvf, bigblock_cvf; ! 140: +extern struct cvf_format default_transparent, bigblock_transparent; ! 141: ! 142: /* #define FAT_PARANOIA 1 */ ! 143: #define DEBUG_LEVEL 0 ! 144: @@ -425,12 +425,15 @@ ! 145: struct msdos_sb_info *sbi = MSDOS_SB(sb); ! 146: char *p; ! 147: int data_sectors,logical_sector_size,sector_mult,fat_clusters=0; ! 148: - int debug,error,fat,cp; ! 149: + int debug; ! 150: + int error = 0; ! 151: + int fat,cp; ! 152: int blksize = 512; ! 153: int fat32; ! 154: struct fat_mount_options opts; ! 155: char buf[50]; ! 156: - int i; ! 157: + int cvf_index=-1; ! 158: + /* int i; */ ! 159: char cvf_format[21]; ! 160: char cvf_options[101]; ! 161: ! 162: @@ -501,14 +504,15 @@ ! 163: sbi->cluster_size = b->cluster_size*sector_mult; ! 164: if (!sbi->cluster_size || (sbi->cluster_size & (sbi->cluster_size-1))) { ! 165: printk("fatfs: bogus cluster size\n"); ! 166: - brelse(bh); ! 167: - goto out_invalid; ! 168: + error = 1; ! 169: + /* brelse(bh);goto out_invalid; */ ! 170: + }else{ ! 171: + for (sbi->cluster_bits=0; ! 172: + 1<<sbi->cluster_bits<sbi->cluster_size; ! 173: + sbi->cluster_bits++) ! 174: + ; ! 175: + sbi->cluster_bits += SECTOR_BITS; ! 176: } ! 177: - for (sbi->cluster_bits=0; ! 178: - 1<<sbi->cluster_bits<sbi->cluster_size; ! 179: - sbi->cluster_bits++) ! 180: - ; ! 181: - sbi->cluster_bits += SECTOR_BITS; ! 182: sbi->fats = b->fats; ! 183: sbi->fat_start = CF_LE_W(b->reserved)*sector_mult; ! 184: if (!b->fat_length && b->fat32_length) { ! 185: @@ -560,7 +564,7 @@ ! 186: data_sectors = CF_LE_L(b->total_sect); ! 187: } ! 188: data_sectors = data_sectors * sector_mult - sbi->data_start; ! 189: - error = !b->cluster_size || !sector_mult; ! 190: + error |= !sector_mult; ! 191: if (!error) { ! 192: sbi->clusters = b->cluster_size ? data_sectors/ ! 193: b->cluster_size/sector_mult : 0; ! 194: @@ -586,15 +590,18 @@ ! 195: /* on odd sectors. */ ! 196: sb->s_blocksize_bits = blksize == 512 ? 9 : (blksize == 1024 ? 10 : 11); ! 197: if (!strcmp(cvf_format,"none")) ! 198: - i = -1; ! 199: + cvf_index = -1; ! 200: else ! 201: - i = detect_cvf(sb,cvf_format); ! 202: - if (i >= 0) ! 203: - error = cvf_formats[i]->mount_cvf(sb,cvf_options); ! 204: + cvf_index = detect_cvf(sb,cvf_format); ! 205: + if (cvf_index >= 0) { ! 206: + ++cvf_format_use_count[cvf_index]; ! 207: + sbi->cvf_format = cvf_formats[cvf_index]; ! 208: + error = cvf_formats[cvf_index]->mount_cvf(sb,cvf_options); ! 209: + } ! 210: else if (sb->s_blocksize == 512) ! 211: - sbi->cvf_format = &default_cvf; ! 212: + sbi->cvf_format = &default_transparent; ! 213: else ! 214: - sbi->cvf_format = &bigblock_cvf; ! 215: + sbi->cvf_format = &bigblock_transparent; ! 216: if (error || debug) { ! 217: /* The MSDOS_CAN_BMAP is obsolete, but left just to remember */ ! 218: printk("[MS-DOS FS Rel. 12,FAT %d,check=%c,conv=%c," ! 219: @@ -614,7 +621,7 @@ ! 220: sbi->root_cluster,sbi->free_clusters); ! 221: printk ("Transaction block size = %d\n",blksize); ! 222: } ! 223: - if (i<0) if (sbi->clusters+2 > fat_clusters) ! 224: + if (cvf_index<0) if (sbi->clusters+2 > fat_clusters) ! 225: sbi->clusters = fat_clusters-2; ! 226: if (error) ! 227: goto out_invalid; ! 228: @@ -631,7 +638,7 @@ ! 229: if (! sbi->nls_disk) { ! 230: /* Fail only if explicit charset specified */ ! 231: if (opts.codepage != 0) ! 232: - goto out_fail; ! 233: + goto out_free_cvf; ! 234: sbi->options.codepage = 0; /* already 0?? */ ! 235: sbi->nls_disk = load_nls_default(); ! 236: } ! 237: @@ -659,10 +666,6 @@ ! 238: sb->s_root = d_alloc_root(root_inode); ! 239: if (!sb->s_root) ! 240: goto out_no_root; ! 241: - if(i>=0) { ! 242: - sbi->cvf_format = cvf_formats[i]; ! 243: - ++cvf_format_use_count[i]; ! 244: - } ! 245: return sb; ! 246: ! 247: out_no_root: ! 248: @@ -671,8 +674,15 @@ ! 249: unload_nls(sbi->nls_io); ! 250: out_unload_nls: ! 251: unload_nls(sbi->nls_disk); ! 252: +out_free_cvf: ! 253: + if(cvf_index>=0) { ! 254: + cvf_formats[cvf_index]->unmount_cvf(sb); ! 255: + --cvf_format_use_count[cvf_index]; ! 256: + } ! 257: goto out_fail; ! 258: out_invalid: ! 259: + if(cvf_index>=0) ! 260: + --cvf_format_use_count[cvf_index]; ! 261: if (!silent) ! 262: printk("VFS: Can't find a valid MSDOS filesystem on dev %s.\n", ! 263: kdevname(sb->s_dev)); ! 264: @@ -746,7 +756,7 @@ ! 265: { ! 266: return generic_block_bmap(mapping,block,fat_get_block); ! 267: } ! 268: -static struct address_space_operations fat_aops = { ! 269: +struct address_space_operations fat_aops = { ! 270: readpage: fat_readpage, ! 271: writepage: fat_writepage, ! 272: prepare_write: fat_prepare_write, ! 273: @@ -815,7 +825,8 @@ ! 274: inode->i_size = CF_LE_L(de->size); ! 275: inode->i_op = &fat_file_inode_operations; ! 276: inode->i_fop = &fat_file_operations; ! 277: - inode->i_mapping->a_ops = &fat_aops; ! 278: + /*inode->i_mapping->a_ops = &fat_aops;*/ ! 279: + inode->i_mapping->a_ops=MSDOS_SB(inode->i_sb)->cvf_format->cvf_aops; ! 280: MSDOS_I(inode)->mmu_private = inode->i_size; ! 281: } ! 282: if(de->attr & ATTR_SYS) ! 283: diff -u -r -N linux-2.3.99-pre3/fs/fat/misc.c linux-2.3.99-pre3-cvf-fat-2.0/fs/fat/misc.c ! 284: --- linux-2.3.99-pre3/fs/fat/misc.c Thu Feb 10 21:16:58 2000 ! 285: +++ linux-2.3.99-pre3-cvf-fat-2.0/fs/fat/misc.c Fri Apr 14 13:17:34 2000 ! 286: @@ -279,9 +279,11 @@ ! 287: sector = MSDOS_SB(sb)->data_start+(nr-2)*cluster_size; ! 288: last_sector = sector + cluster_size; ! 289: if (MSDOS_SB(sb)->cvf_format && ! 290: - MSDOS_SB(sb)->cvf_format->zero_out_cluster) ! 291: + MSDOS_SB(sb)->cvf_format->zero_out_cluster) { ! 292: + /* CVF zeroes full cluster only */ ! 293: MSDOS_SB(sb)->cvf_format->zero_out_cluster(inode,nr); ! 294: - else ! 295: + res=fat_bread(sb,fat_bmap(inode,inode->i_blocks)); ! 296: + }else ! 297: for ( ; sector < last_sector; sector++) { ! 298: #ifdef DEBUG ! 299: printk("zeroing sector %d\n",sector); ! 300: diff -u -r -N linux-2.3.99-pre3/include/linux/fat_cvf.h linux-2.3.99-pre3-cvf-fat-2.0/include/linux/fat_cvf.h ! 301: --- linux-2.3.99-pre3/include/linux/fat_cvf.h Mon Aug 9 20:43:49 1999 ! 302: +++ linux-2.3.99-pre3-cvf-fat-2.0/include/linux/fat_cvf.h Fri Apr 14 13:17:46 2000 ! 303: @@ -2,6 +2,8 @@ ! 304: #define _FAT_CVF ! 305: ! 306: #define CVF_USE_READPAGE 0x0001 ! 307: +#define CVF_TRANSPARENT 0x8000 ! 308: +#define CVF_BIGBLOCK 0x4000 ! 309: ! 310: struct cvf_format ! 311: { int cvf_version; ! 312: @@ -30,8 +32,7 @@ ! 313: ssize_t (*cvf_file_read) ( struct file *, char *, size_t, loff_t *); ! 314: ssize_t (*cvf_file_write) ( struct file *, const char *, size_t, loff_t *); ! 315: int (*cvf_mmap) (struct file *, struct vm_area_struct *); ! 316: - int (*cvf_readpage) (struct inode *, struct page *); ! 317: - int (*cvf_writepage) (struct inode *, struct page *); ! 318: + struct address_space_operations*cvf_aops; ! 319: int (*cvf_dir_ioctl) (struct inode * inode, struct file * filp, ! 320: unsigned int cmd, unsigned long arg); ! 321: void (*zero_out_cluster) (struct inode*, int clusternr); ! 322: diff -u -r -N linux-2.3.99-pre3/include/linux/msdos_fs.h linux-2.3.99-pre3-cvf-fat-2.0/include/linux/msdos_fs.h ! 323: --- linux-2.3.99-pre3/include/linux/msdos_fs.h Mon Mar 13 21:35:39 2000 ! 324: +++ linux-2.3.99-pre3-cvf-fat-2.0/include/linux/msdos_fs.h Fri Apr 14 13:17:46 2000 ! 325: @@ -271,6 +271,7 @@ ! 326: extern ssize_t fat_file_read(struct file *, char *, size_t, loff_t *); ! 327: extern ssize_t fat_file_write(struct file *, const char *, size_t, loff_t *); ! 328: extern void fat_truncate(struct inode *inode); ! 329: +extern int fat_file_mmap(struct file * filp, struct vm_area_struct * vma); ! 330: ! 331: /* msdos.c */ ! 332: extern struct super_block *msdos_read_super(struct super_block *sb,void *data, int silent); ! 333: diff -u -r -N linux-2.3.99-pre3/Documentation/filesystems/fat_cvf.txt linux-2.3.99-pre3-cvf-fat-2.0/Documentation/filesystems/fat_cvf.txt ! 334: --- linux-2.3.99-pre3/Documentation/filesystems/fat_cvf.txt Fri Nov 20 18:19:46 1998 ! 335: +++ linux-2.3.99-pre3-cvf-fat-2.0/Documentation/filesystems/fat_cvf.txt Tue Apr 18 11:35:01 2000 ! 336: @@ -1,5 +1,5 @@ ! 337: -This is the main documentation for the CVF-FAT filesystem extension. 18Nov1998 ! 338: - ! 339: +This is the main documentation for the CVF-FAT filesystem extension. 15Apr2000 ! 340: +CVF-FAT-VERSION-ID: 2.0.0 ! 341: ! 342: Table of Contents: ! 343: ! 344: @@ -32,14 +32,13 @@ ! 345: 2. Restrictions ! 346: ------------------------------------------------------------------------------ ! 347: ! 348: -- BMAP problems ! 349: +- BMAP/MMAP problems ! 350: ! 351: CVF filesystems cannot do bmap. It's impossible in principle. Thus ! 352: all actions that require bmap do not work (swapping, writable mmapping). ! 353: - Read-only mmapping works because the FAT driver has a hack for this ! 354: - situation :) Well, writable mmapping should now work using the readpage ! 355: - interface function which has been hacked into the FAT driver just for ! 356: - CVF-FAT :) ! 357: + Writable mmap could work through large address_operations hacks, but ! 358: + they have not yet been implemented in CVF-FAT for kernel 2.3.99. So ! 359: + mmap is read-only and you have to live with it for now :) ! 360: ! 361: - attention, DOSEmu users ! 362: ! 363: @@ -127,12 +126,15 @@ ! 364: describing the CVF format the module implements. This text is used ! 365: for the cvf_format option. This name must also be unique. ! 366: - flags: ! 367: - Bit coded flags, currently only used for a readpage/mmap hack that ! 368: - provides both mmap and readpage functionality. If CVF_USE_READPAGE ! 369: - is set, mmap is set to generic_file_mmap and readpage is caught ! 370: - and redirected to the cvf_readpage function. If it is not set, ! 371: - readpage is set to generic_readpage and mmap is caught and redirected ! 372: - to cvf_mmap. (If you want writable mmap use the readpage interface.) ! 373: + Currently without function. Only used for information purpose. ! 374: + CVF_TRANSPARENT: marks a cvf structure for transparent access (i.e. ! 375: + plain FAT filesystem). ! 376: + CVF_BIGBLOCK: indicates that the cvf module is capable of handling ! 377: + block sizes larger than 512 bytes. *As the loop ! 378: + driver can do blocksize conversion, a cvf module ! 379: + usually does not need to handle this.* ! 380: + CVF_USE_READPAGE: indicates that mmap uses the new readpage interface ! 381: + and thus supports writable mmap. ! 382: - detect_cvf: ! 383: A function that is called to decide whether the filesystem is a CVF of ! 384: the type the module supports. The detect_cvf function must return 0 ! 385: @@ -158,23 +160,22 @@ ! 386: - [...]: ! 387: All other interface functions are "caught" FAT driver functions, i.e. ! 388: are executed by the FAT driver *instead* of the original FAT driver ! 389: - functions. NULL means use the original FAT driver functions instead. ! 390: + functions. If you want to use the original FAT driver functions, ! 391: + hang then in here (please no longer use NULL for this purpose). ! 392: If you really want "no action", write a function that does nothing and ! 393: - hang it in instead. ! 394: + hang it in instead. Consider the meaning of NULL undefined. ! 395: - cvf_zero_cluster: ! 396: The cvf_zero_cluster function is called when the fat driver wants to ! 397: zero out a (new) cluster. This is important for directories (mkdir). ! 398: If it is NULL, the FAT driver defaults to overwriting the whole ! 399: cluster with zeros. Note that clusternr is absolute, not relative ! 400: - to the provided inode. ! 401: + to the provided inode. Note that since kernel 2.3.99, this function is ! 402: + only called when a *directory* cluster is handled. ! 403: ! 404: Notes: ! 405: - 1. The cvf_bmap function should be ignored. It really should never ! 406: + The cvf_bmap function should be ignored. It really should never ! 407: get called from somewhere. I recommend redirecting it to a panic ! 408: or fatal error message so bugs show up immediately. ! 409: - 2. The cvf_writepage function is ignored. This is because the fat ! 410: - driver doesn't support it. This might change in future. I recommend ! 411: - setting it to NULL (i.e use default). ! 412: ! 413: int register_cvf_format(struct cvf_format*cvf_format); ! 414: If you have just set up a variable containing the above structure,
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.