/[pupa]/pupa/fs/fat.c
ViewVC logotype

Diff of /pupa/fs/fat.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by okuji, Thu Jan 2 23:46:21 2003 UTC revision 1.4 by okuji, Mon Jan 6 00:01:35 2003 UTC
# Line 126  struct pupa_fat_data Line 126  struct pupa_fat_data
126    pupa_uint32_t cur_cluster;    pupa_uint32_t cur_cluster;
127  };  };
128    
129    #ifndef PUPA_UTIL
130    static pupa_dl_t my_mod;
131    #endif
132    
133  static int  static int
134  log2 (unsigned x)  log2 (unsigned x)
135  {  {
# Line 675  static pupa_err_t Line 679  static pupa_err_t
679  pupa_fat_dir (pupa_device_t device, const char *path,  pupa_fat_dir (pupa_device_t device, const char *path,
680                int (*hook) (const char *filename, int dir))                int (*hook) (const char *filename, int dir))
681  {  {
682    struct pupa_fat_data *data;    struct pupa_fat_data *data = 0;
683    pupa_disk_t disk = device->disk;    pupa_disk_t disk = device->disk;
684    char *p = (char *) path;    char *p = (char *) path;
685    
686    #ifndef PUPA_UTIL
687      pupa_dl_ref (my_mod);
688    #endif
689        
690    data = pupa_fat_mount (disk);    data = pupa_fat_mount (disk);
691    if (! data)    if (! data)
692      return pupa_errno;      goto fail;
693    
694    do    do
695      {      {
# Line 689  pupa_fat_dir (pupa_device_t device, cons Line 697  pupa_fat_dir (pupa_device_t device, cons
697      }      }
698    while (p && pupa_errno == PUPA_ERR_NONE);    while (p && pupa_errno == PUPA_ERR_NONE);
699    
700     fail:
701      
702    pupa_free (data);    pupa_free (data);
703      
704    #ifndef PUPA_UTIL
705      pupa_dl_unref (my_mod);
706    #endif
707      
708    return pupa_errno;    return pupa_errno;
709  }  }
710    
711  static pupa_err_t  static pupa_err_t
712  pupa_fat_open (pupa_file_t file, const char *name)  pupa_fat_open (pupa_file_t file, const char *name)
713  {  {
714    struct pupa_fat_data *data;    struct pupa_fat_data *data = 0;
715    char *p = (char *) name;    char *p = (char *) name;
716    
717    #ifndef PUPA_UTIL
718      pupa_dl_ref (my_mod);
719    #endif
720        
721    data = pupa_fat_mount (file->device->disk);    data = pupa_fat_mount (file->device->disk);
722    if (! data)    if (! data)
723      return pupa_errno;      goto fail;
724    
725    do    do
726      {      {
# Line 723  pupa_fat_open (pupa_file_t file, const c Line 742  pupa_fat_open (pupa_file_t file, const c
742    return PUPA_ERR_NONE;    return PUPA_ERR_NONE;
743    
744   fail:   fail:
745      
746    pupa_free (data);    pupa_free (data);
747      
748    #ifndef PUPA_UTIL
749      pupa_dl_unref (my_mod);
750    #endif
751      
752    return pupa_errno;    return pupa_errno;
753  }  }
754    
# Line 738  static pupa_err_t Line 763  static pupa_err_t
763  pupa_fat_close (pupa_file_t file)  pupa_fat_close (pupa_file_t file)
764  {  {
765    pupa_free (file->data);    pupa_free (file->data);
766      
767    #ifndef PUPA_UTIL
768      pupa_dl_unref (my_mod);
769    #endif
770      
771    return pupa_errno;    return pupa_errno;
772  }  }
773    
# Line 752  static struct pupa_fs pupa_fat_fs = Line 782  static struct pupa_fs pupa_fat_fs =
782    };    };
783    
784  #ifdef PUPA_UTIL  #ifdef PUPA_UTIL
785  void pupa_fat_init (void)  void
786  #else  pupa_fat_init (void)
787    {
788      pupa_fs_register (&pupa_fat_fs);
789    }
790    
791    void
792    pupa_fat_fini (void)
793    {
794      pupa_fs_unregister (&pupa_fat_fs);
795    }
796    #else /* ! PUPA_UTIL */
797  PUPA_MOD_INIT  PUPA_MOD_INIT
 #endif  
798  {  {
799    pupa_fs_register (&pupa_fat_fs);    pupa_fs_register (&pupa_fat_fs);
800      my_mod = mod;
801  }  }
802    
 #ifdef PUPA_UTIL  
 void pupa_fat_fini (void)  
 #else  
803  PUPA_MOD_FINI  PUPA_MOD_FINI
 #endif  
804  {  {
805    pupa_fs_unregister (&pupa_fat_fs);    pupa_fs_unregister (&pupa_fat_fs);
806  }  }
807    #endif /* ! PUPA_UTIL */

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26