attrib.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * attrib.h - Defines for attribute handling in NTFS Linux kernel driver.
  4. * Part of the Linux-NTFS project.
  5. *
  6. * Copyright (c) 2001-2005 Anton Altaparmakov
  7. * Copyright (c) 2002 Richard Russon
  8. */
  9. #ifndef _LINUX_NTFS_ATTRIB_H
  10. #define _LINUX_NTFS_ATTRIB_H
  11. #include "endian.h"
  12. #include "types.h"
  13. #include "layout.h"
  14. #include "inode.h"
  15. #include "runlist.h"
  16. #include "volume.h"
  17. /**
  18. * ntfs_attr_search_ctx - used in attribute search functions
  19. * @mrec: buffer containing mft record to search
  20. * @attr: attribute record in @mrec where to begin/continue search
  21. * @is_first: if true ntfs_attr_lookup() begins search with @attr, else after
  22. *
  23. * Structure must be initialized to zero before the first call to one of the
  24. * attribute search functions. Initialize @mrec to point to the mft record to
  25. * search, and @attr to point to the first attribute within @mrec (not necessary
  26. * if calling the _first() functions), and set @is_first to 'true' (not necessary
  27. * if calling the _first() functions).
  28. *
  29. * If @is_first is 'true', the search begins with @attr. If @is_first is 'false',
  30. * the search begins after @attr. This is so that, after the first call to one
  31. * of the search attribute functions, we can call the function again, without
  32. * any modification of the search context, to automagically get the next
  33. * matching attribute.
  34. */
  35. typedef struct {
  36. MFT_RECORD *mrec;
  37. ATTR_RECORD *attr;
  38. bool is_first;
  39. ntfs_inode *ntfs_ino;
  40. ATTR_LIST_ENTRY *al_entry;
  41. ntfs_inode *base_ntfs_ino;
  42. MFT_RECORD *base_mrec;
  43. ATTR_RECORD *base_attr;
  44. } ntfs_attr_search_ctx;
  45. extern int ntfs_map_runlist_nolock(ntfs_inode *ni, VCN vcn,
  46. ntfs_attr_search_ctx *ctx);
  47. extern int ntfs_map_runlist(ntfs_inode *ni, VCN vcn);
  48. extern LCN ntfs_attr_vcn_to_lcn_nolock(ntfs_inode *ni, const VCN vcn,
  49. const bool write_locked);
  50. extern runlist_element *ntfs_attr_find_vcn_nolock(ntfs_inode *ni,
  51. const VCN vcn, ntfs_attr_search_ctx *ctx);
  52. int ntfs_attr_lookup(const ATTR_TYPE type, const ntfschar *name,
  53. const u32 name_len, const IGNORE_CASE_BOOL ic,
  54. const VCN lowest_vcn, const u8 *val, const u32 val_len,
  55. ntfs_attr_search_ctx *ctx);
  56. extern int load_attribute_list(ntfs_volume *vol, runlist *rl, u8 *al_start,
  57. const s64 size, const s64 initialized_size);
  58. static inline s64 ntfs_attr_size(const ATTR_RECORD *a)
  59. {
  60. if (!a->non_resident)
  61. return (s64)le32_to_cpu(a->data.resident.value_length);
  62. return sle64_to_cpu(a->data.non_resident.data_size);
  63. }
  64. extern void ntfs_attr_reinit_search_ctx(ntfs_attr_search_ctx *ctx);
  65. extern ntfs_attr_search_ctx *ntfs_attr_get_search_ctx(ntfs_inode *ni,
  66. MFT_RECORD *mrec);
  67. extern void ntfs_attr_put_search_ctx(ntfs_attr_search_ctx *ctx);
  68. #ifdef NTFS_RW
  69. extern int ntfs_attr_size_bounds_check(const ntfs_volume *vol,
  70. const ATTR_TYPE type, const s64 size);
  71. extern int ntfs_attr_can_be_non_resident(const ntfs_volume *vol,
  72. const ATTR_TYPE type);
  73. extern int ntfs_attr_can_be_resident(const ntfs_volume *vol,
  74. const ATTR_TYPE type);
  75. extern int ntfs_attr_record_resize(MFT_RECORD *m, ATTR_RECORD *a, u32 new_size);
  76. extern int ntfs_resident_attr_value_resize(MFT_RECORD *m, ATTR_RECORD *a,
  77. const u32 new_size);
  78. extern int ntfs_attr_make_non_resident(ntfs_inode *ni, const u32 data_size);
  79. extern s64 ntfs_attr_extend_allocation(ntfs_inode *ni, s64 new_alloc_size,
  80. const s64 new_data_size, const s64 data_start);
  81. extern int ntfs_attr_set(ntfs_inode *ni, const s64 ofs, const s64 cnt,
  82. const u8 val);
  83. #endif /* NTFS_RW */
  84. #endif /* _LINUX_NTFS_ATTRIB_H */