Annotation of dmsdos/patches/cvf.c-2.1.128, revision 1.1.1.1

1.1       root        1: /* 
                      2:  * CVF extensions for fat-based filesystems
                      3:  *
                      4:  * written 1997,1998 by Frank Gockel <[email protected]>
                      5:  *
                      6:  * please do not remove the next line, dmsdos needs it for verifying patches
                      7:  * CVF-FAT-VERSION-ID: 1.2.0
                      8:  *
                      9:  */
                     10:  
                     11: #include<linux/sched.h>
                     12: #include<linux/fs.h>
                     13: #include<linux/msdos_fs.h>
                     14: #include<linux/msdos_fs_sb.h>
                     15: #include<linux/string.h>
                     16: #include<linux/fat_cvf.h>
                     17: #include<linux/config.h>
                     18: #ifdef CONFIG_KMOD
                     19: #include<linux/kmod.h>
                     20: #endif
                     21: 
                     22: #define MAX_CVF_FORMATS 3
                     23: 
                     24: struct cvf_format *cvf_formats[MAX_CVF_FORMATS]={NULL,NULL,NULL};
                     25: int cvf_format_use_count[MAX_CVF_FORMATS]={0,0,0};
                     26: 
                     27: int register_cvf_format(struct cvf_format*cvf_format)
                     28: { int i,j;
                     29: 
                     30:   for(i=0;i<MAX_CVF_FORMATS;++i)
                     31:   { if(cvf_formats[i]==NULL)
                     32:     { /* free slot found, now check version */
                     33:       for(j=0;j<MAX_CVF_FORMATS;++j)
                     34:       { if(cvf_formats[j])
                     35:         { if(cvf_formats[j]->cvf_version==cvf_format->cvf_version)
                     36:           { printk("register_cvf_format: version %d already registered\n",
                     37:                    cvf_format->cvf_version);
                     38:             return -1;
                     39:           }
                     40:         }
                     41:       }
                     42:       cvf_formats[i]=cvf_format;
                     43:       cvf_format_use_count[i]=0;
                     44:       printk("CVF format %s (version id %d) successfully registered.\n",
                     45:              cvf_format->cvf_version_text,cvf_format->cvf_version);
                     46:       return 0;
                     47:     }
                     48:   }
                     49:   
                     50:   printk("register_cvf_format: too many formats\n");
                     51:   return -1;
                     52: }
                     53: 
                     54: int unregister_cvf_format(struct cvf_format*cvf_format)
                     55: { int i;
                     56: 
                     57:   for(i=0;i<MAX_CVF_FORMATS;++i)
                     58:   { if(cvf_formats[i])
                     59:     { if(cvf_formats[i]->cvf_version==cvf_format->cvf_version)
                     60:       { if(cvf_format_use_count[i])
                     61:         { printk("unregister_cvf_format: format %d in use, cannot remove!\n",
                     62:           cvf_formats[i]->cvf_version);
                     63:           return -1;
                     64:         }
                     65:       
                     66:         printk("CVF format %s (version id %d) successfully unregistered.\n",
                     67:         cvf_formats[i]->cvf_version_text,cvf_formats[i]->cvf_version);
                     68:         cvf_formats[i]=NULL;
                     69:         return 0;
                     70:       }
                     71:     }
                     72:   }
                     73:   
                     74:   printk("unregister_cvf_format: format %d is not registered\n",
                     75:          cvf_format->cvf_version);
                     76:   return -1;
                     77: }
                     78: 
                     79: void dec_cvf_format_use_count_by_version(int version)
                     80: { int i;
                     81: 
                     82:   for(i=0;i<MAX_CVF_FORMATS;++i)
                     83:   { if(cvf_formats[i])
                     84:     { if(cvf_formats[i]->cvf_version==version)
                     85:       { --cvf_format_use_count[i];
                     86:         if(cvf_format_use_count[i]<0)
                     87:         { cvf_format_use_count[i]=0;
                     88:           printk(KERN_EMERG "FAT FS/CVF: This is a bug in cvf_version_use_count\n");
                     89:         }
                     90:         return;
                     91:       }
                     92:     }
                     93:   }
                     94:   
                     95:   printk("dec_cvf_format_use_count_by_version: version %d not found ???\n",
                     96:          version);
                     97: }
                     98: 
                     99: int detect_cvf(struct super_block*sb,char*force)
                    100: { int i;
                    101:   int found=0;
                    102:   int found_i=-1;
                    103: 
                    104:   if(force)
                    105:     if(strcmp(force,"autoload")==0)
                    106:     {
                    107: #ifdef CONFIG_KMOD
                    108:       request_module("cvf_autoload");
                    109:       force=NULL;
                    110: #else
                    111:       printk("cannot autoload CVF modules: kmod support is not compiled into kernel\n");
                    112:       return -1;
                    113: #endif
                    114:     }
                    115:     
                    116: #ifdef CONFIG_KMOD
                    117:   if(force)
                    118:     if(*force)
                    119:       request_module(force);
                    120: #endif
                    121: 
                    122:   if(force)
                    123:   { if(*force)
                    124:     { for(i=0;i<MAX_CVF_FORMATS;++i)
                    125:       { if(cvf_formats[i])
                    126:         { if(!strcmp(cvf_formats[i]->cvf_version_text,force))
                    127:             return i;
                    128:         }
                    129:       }
                    130:       printk("CVF format %s unknown (module not loaded?)\n",force);
                    131:       return -1;
                    132:     }
                    133:   }
                    134: 
                    135:   for(i=0;i<MAX_CVF_FORMATS;++i)
                    136:   { if(cvf_formats[i])
                    137:     { if(cvf_formats[i]->detect_cvf(sb))
                    138:       { ++found;
                    139:         found_i=i;
                    140:       }
                    141:     }
                    142:   }
                    143:   
                    144:   if(found==1)return found_i;
                    145:   if(found>1)printk("CVF detection ambiguous, please use cvf_format=xxx option\n"); 
                    146:   return -1;
                    147: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.