support.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:2k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  * support.h - Header file for specific support.c
  3.  *
  4.  * Copyright (C) 1997 R間is Duchesne
  5.  * Copyright (c) 2001 Anton Altaparmakov (AIA)
  6.  */
  7. /* Debug levels */
  8. #define DEBUG_OTHER 1
  9. #define DEBUG_MALLOC 2
  10. #define DEBUG_BSD       4
  11. #define DEBUG_LINUX     8
  12. #define DEBUG_DIR1     16
  13. #define DEBUG_DIR2     32
  14. #define DEBUG_DIR3     64
  15. #define DEBUG_FILE1   128
  16. #define DEBUG_FILE2   256
  17. #define DEBUG_FILE3   512
  18. #define DEBUG_NAME1  1024
  19. #define DEBUG_NAME2  2048
  20. #ifdef DEBUG
  21. void ntfs_debug(int mask, const char *fmt, ...);
  22. #else
  23. #define ntfs_debug(mask, fmt...) do {} while (0)
  24. #endif
  25. #include <linux/slab.h>
  26. #include <linux/vmalloc.h>
  27. #define ntfs_malloc(size)  kmalloc(size, GFP_KERNEL)
  28. #define ntfs_free(ptr)     kfree(ptr)
  29. /**
  30.  * ntfs_vmalloc - allocate memory in multiples of pages
  31.  * @size number of bytes to allocate
  32.  *
  33.  * Allocates @size bytes of memory, rounded up to multiples of PAGE_SIZE and
  34.  * returns a pointer to the allocated memory.
  35.  *
  36.  * If there was insufficient memory to complete the request, return NULL.
  37.  */
  38. static inline void *ntfs_vmalloc(unsigned long size)
  39. {
  40. if (size <= PAGE_SIZE) {
  41. if (size) {
  42. /* kmalloc() has per-CPU caches so if faster for now. */
  43. return kmalloc(PAGE_SIZE, GFP_NOFS);
  44. /* return (void *)__get_free_page(GFP_NOFS |
  45. __GFP_HIGHMEM); */
  46. }
  47. BUG();
  48. }
  49. if (size >> PAGE_SHIFT < num_physpages)
  50. return __vmalloc(size, GFP_NOFS | __GFP_HIGHMEM, PAGE_KERNEL);
  51. return NULL;
  52. }
  53. static inline void ntfs_vfree(void *addr)
  54. {
  55. if ((unsigned long)addr < VMALLOC_START) {
  56. return kfree(addr);
  57. /* return free_page((unsigned long)addr); */
  58. }
  59. vfree(addr);
  60. }
  61. void ntfs_bzero(void *s, int n);
  62. void ntfs_memcpy(void *dest, const void *src, ntfs_size_t n);
  63. void ntfs_memmove(void *dest, const void *src, ntfs_size_t n);
  64. void ntfs_error(const char *fmt,...);
  65. int ntfs_read_mft_record(ntfs_volume *vol, int mftno, char *buf);
  66. int ntfs_getput_clusters(ntfs_volume *pvol, int cluster, ntfs_size_t offs,
  67.  ntfs_io *buf);
  68. ntfs_time64_t ntfs_now(void);
  69. int ntfs_dupuni2map(ntfs_volume *vol, ntfs_u16 *in, int in_len, char **out,
  70.     int *out_len);
  71. int ntfs_dupmap2uni(ntfs_volume *vol, char* in, int in_len, ntfs_u16 **out,
  72.     int *out_len);