journal_ext2.c
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:2k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

  1. /*
  2.  * Intermezzo. (C) 1998 Peter J. Braam
  3.  */
  4. #include <linux/types.h>
  5. #include <linux/kernel.h>
  6. #include <linux/sched.h>
  7. #include <linux/fs.h>
  8. #include <linux/slab.h>
  9. #include <linux/vmalloc.h>
  10. #include <linux/stat.h>
  11. #include <linux/errno.h>
  12. #include <linux/locks.h>
  13. #include <asm/segment.h>
  14. #include <asm/uaccess.h>
  15. #include <linux/string.h>
  16. #include <linux/ext2_fs.h> 
  17. #include <linux/intermezzo_fs.h>
  18. #include <linux/intermezzo_upcall.h>
  19. #include <linux/intermezzo_psdev.h>
  20. #include <linux/intermezzo_kml.h>
  21. #if defined(CONFIG_EXT2_FS)
  22. /* EXT2 has no journalling, so these functions do nothing */
  23. static loff_t presto_e2_freespace(struct presto_cache *cache,
  24.                                          struct super_block *sb)
  25. {
  26.         unsigned long freebl = le32_to_cpu(sb->u.ext2_sb.s_es->s_free_blocks_count);
  27.         unsigned long avail =   freebl - le32_to_cpu(sb->u.ext2_sb.s_es->s_r_blocks_count);
  28. return (avail <<  EXT2_BLOCK_SIZE_BITS(sb));
  29. }
  30. /* start the filesystem journal operations */
  31. static void *presto_e2_trans_start(struct presto_file_set *fset, struct inode *inode, int op)
  32. {
  33.         __u32 avail_kmlblocks;
  34.         if ( presto_no_journal(fset) ||
  35.              strcmp(fset->fset_cache->cache_type, "ext2"))
  36.                 return NULL;
  37.         avail_kmlblocks = inode->i_sb->u.ext2_sb.s_es->s_free_blocks_count;
  38.         
  39.         if ( avail_kmlblocks < 3 ) {
  40.                 return ERR_PTR(-ENOSPC);
  41.         }
  42.         
  43.         if (  (op != PRESTO_OP_UNLINK && op != PRESTO_OP_RMDIR)
  44.               && avail_kmlblocks < 6 ) {
  45.                 return ERR_PTR(-ENOSPC);
  46.         }            
  47. return (void *) 1;
  48. }
  49. static void presto_e2_trans_commit(struct presto_file_set *fset, void *handle)
  50. {
  51.   do {} while (0);
  52. }
  53. struct journal_ops presto_ext2_journal_ops = {
  54.         tr_avail: presto_e2_freespace,
  55.         tr_start: presto_e2_trans_start,
  56.         tr_commit: presto_e2_trans_commit,
  57.         tr_journal_data: NULL
  58. };
  59. #endif /* CONFIG_EXT2_FS */