ReactOS  0.4.15-dev-1367-g07cc0b5
btrfs_drv.h
Go to the documentation of this file.
1 /* Copyright (c) Mark Harmstone 2016-17
2  *
3  * This file is part of WinBtrfs.
4  *
5  * WinBtrfs is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public Licence as published by
7  * the Free Software Foundation, either version 3 of the Licence, or
8  * (at your option) any later version.
9  *
10  * WinBtrfs is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public Licence for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public Licence
16  * along with WinBtrfs. If not, see <http://www.gnu.org/licenses/>. */
17 
18 #pragma once
19 
20 #ifndef __REACTOS__
21 #undef _WIN32_WINNT
22 #undef NTDDI_VERSION
23 
24 #define _WIN32_WINNT 0x0601
25 #define NTDDI_VERSION 0x06020000 // Win 8
26 #define _CRT_SECURE_NO_WARNINGS
27 #define _NO_CRT_STDIO_INLINE
28 #endif /* __REACTOS__ */
29 
30 #ifdef _MSC_VER
31 #pragma warning(push)
32 #pragma warning(disable:4163)
33 #pragma warning(disable:4311)
34 #pragma warning(disable:4312)
35 #else
36 #pragma GCC diagnostic push
37 #pragma GCC diagnostic ignored "-Wsign-compare"
38 #pragma GCC diagnostic ignored "-Wsign-conversion"
39 #endif
40 
41 #include <ntifs.h>
42 #include <ntddk.h>
43 #ifdef __REACTOS__
44 #include <ntdddisk.h>
45 #endif /* __REACTOS__ */
46 #include <mountmgr.h>
47 #ifdef __REACTOS__
48 #include <rtlfuncs.h>
49 #include <iotypes.h>
50 #include <pseh/pseh2.h>
51 #endif /* __REACTOS__ */
52 #include <windef.h>
53 #include <wdm.h>
54 
55 #ifdef _MSC_VER
56 #pragma warning(pop)
57 #else
58 #pragma GCC diagnostic pop
59 #endif
60 
61 #include <stdio.h>
62 #include <stdarg.h>
63 #include <stddef.h>
64 #include <stdint.h>
65 #include <stdbool.h>
66 #include "btrfs.h"
67 #include "btrfsioctl.h"
68 
69 #if !defined(__REACTOS__) && (defined(_X86_) || defined(_AMD64_))
70 #include <emmintrin.h>
71 #endif
72 
73 #ifdef __REACTOS__
74 C_ASSERT(sizeof(bool) == 1);
75 #endif
76 
77 #ifdef _DEBUG
78 // #define DEBUG_FCB_REFCOUNTS
79 // #define DEBUG_LONG_MESSAGES
80 // #define DEBUG_FLUSH_TIMES
81 // #define DEBUG_CHUNK_LOCKS
82 // #define DEBUG_TRIM_EMULATION
83 #define DEBUG_PARANOID
84 #endif
85 
86 #define UNUSED(x) (void)(x)
87 
88 #define BTRFS_NODE_TYPE_CCB 0x2295
89 #define BTRFS_NODE_TYPE_FCB 0x2296
90 
91 #define ALLOC_TAG 0x7442484D //'MHBt'
92 #define ALLOC_TAG_ZLIB 0x7A42484D //'MHBz'
93 
94 #define UID_NOBODY 65534
95 #define GID_NOBODY 65534
96 
97 #define EA_NTACL "security.NTACL"
98 #define EA_NTACL_HASH 0x45922146
99 
100 #define EA_DOSATTRIB "user.DOSATTRIB"
101 #define EA_DOSATTRIB_HASH 0x914f9939
102 
103 #define EA_REPARSE "user.reparse"
104 #define EA_REPARSE_HASH 0xfabad1fe
105 
106 #define EA_EA "user.EA"
107 #define EA_EA_HASH 0x8270dd43
108 
109 #define EA_CASE_SENSITIVE "user.casesensitive"
110 #define EA_CASE_SENSITIVE_HASH 0x1a9d97d4
111 
112 #define EA_PROP_COMPRESSION "btrfs.compression"
113 #define EA_PROP_COMPRESSION_HASH 0x20ccdf69
114 
115 #define MAX_EXTENT_SIZE 0x8000000 // 128 MB
116 #define COMPRESSED_EXTENT_SIZE 0x20000 // 128 KB
117 
118 #define READ_AHEAD_GRANULARITY COMPRESSED_EXTENT_SIZE // really ought to be a multiple of COMPRESSED_EXTENT_SIZE
119 
120 #ifndef IO_REPARSE_TAG_LX_SYMLINK
121 
122 #define IO_REPARSE_TAG_LX_SYMLINK 0xa000001d
123 
124 #define IO_REPARSE_TAG_AF_UNIX 0x80000023
125 #define IO_REPARSE_TAG_LX_FIFO 0x80000024
126 #define IO_REPARSE_TAG_LX_CHR 0x80000025
127 #define IO_REPARSE_TAG_LX_BLK 0x80000026
128 
129 #endif
130 
131 #define BTRFS_VOLUME_PREFIX L"\\Device\\Btrfs{"
132 
133 #ifdef _MSC_VER
134 #define try __try
135 #define except __except
136 #define finally __finally
137 #else
138 #define try if (1)
139 #define except(x) if (0 && (x))
140 #define finally if (1)
141 #endif
142 
143 #ifndef __REACTOS__
144 #ifdef __GNUC__
145 #define InterlockedIncrement64(a) __sync_add_and_fetch(a, 1)
146 #endif
147 #endif // __REACTOS__
148 
149 #ifndef FILE_SUPPORTS_BLOCK_REFCOUNTING
150 #define FILE_SUPPORTS_BLOCK_REFCOUNTING 0x08000000
151 #endif
152 
153 #ifndef FILE_SUPPORTS_POSIX_UNLINK_RENAME
154 #define FILE_SUPPORTS_POSIX_UNLINK_RENAME 0x00000400
155 #endif
156 
157 #ifndef FILE_DEVICE_ALLOW_APPCONTAINER_TRAVERSAL
158 #define FILE_DEVICE_ALLOW_APPCONTAINER_TRAVERSAL 0x00020000
159 #endif
160 
161 #ifndef __REACTOS__
162 #ifndef _MSC_VER
163 typedef struct _FILE_ID_128 {
166 
167 #define FILE_CS_FLAG_CASE_SENSITIVE_DIR 1
168 #endif
169 #else
170 typedef struct _FILE_ID_128 {
171  UCHAR Identifier[16];
173 
174 #define FILE_CS_FLAG_CASE_SENSITIVE_DIR 1
175 #endif // __REACTOS__
176 
177 typedef struct _DUPLICATE_EXTENTS_DATA {
183 
184 #define FSCTL_DUPLICATE_EXTENTS_TO_FILE CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 209, METHOD_BUFFERED, FILE_WRITE_ACCESS)
185 
188  WORD Reserved;
189  DWORD Flags;
193 
196  WORD Reserved;
197  DWORD Flags;
199 
200 #define FSCTL_GET_INTEGRITY_INFORMATION CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 159, METHOD_BUFFERED, FILE_ANY_ACCESS)
201 #define FSCTL_SET_INTEGRITY_INFORMATION CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 160, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
202 
203 #ifndef __REACTOS__
204 #ifndef _MSC_VER
205 #define __drv_aliasesMem
206 #define _Requires_lock_held_(a)
207 #define _Requires_exclusive_lock_held_(a)
208 #define _Releases_lock_(a)
209 #define _Releases_exclusive_lock_(a)
210 #define _Dispatch_type_(a)
211 #define _Create_lock_level_(a)
212 #define _Lock_level_order_(a,b)
213 #define _Has_lock_level_(a)
214 #define _Requires_lock_not_held_(a)
215 #define _Acquires_exclusive_lock_(a)
216 #define _Acquires_shared_lock_(a)
217 #endif
218 #endif // __REACTOS__
219 
220 _Create_lock_level_(tree_lock)
221 _Create_lock_level_(fcb_lock)
222 _Lock_level_order_(tree_lock, fcb_lock)
223 
224 #define MAX_HASH_SIZE 32
225 
226 struct _device_extension;
227 
228 typedef struct _fcb_nonpaged {
234 } fcb_nonpaged;
235 
236 struct _root;
237 
238 typedef struct {
241  bool unique;
242  bool ignore;
243  bool inserted;
244  void* csum;
245 
247 
249 } extent;
250 
251 typedef struct {
257 } hardlink;
258 
259 struct _file_ref;
260 
261 typedef struct {
272  bool root_dir;
276 } dir_child;
277 
283 };
284 
285 typedef struct {
289  bool dirty;
290  char data[1];
291 } xattr;
292 
293 typedef struct _fcb {
299  struct _root* subvol;
306  bool deleted;
324 
330 
331  bool dirty;
339  bool created;
340 
341  bool ads;
346 
350 } fcb;
351 
352 typedef struct {
355 
356 typedef struct _file_ref {
362  bool deleted;
363  bool created;
368  struct _file_ref* parent;
370 
371  bool dirty;
372 
375 } file_ref;
376 
377 typedef struct {
379  struct _ccb* ccb;
380  void* context;
384 } send_info;
385 
386 typedef struct _ccb {
397  bool reserving;
407  bool lxss;
410 } ccb;
411 
412 struct _device_extension;
413 
414 typedef struct {
417  struct _tree* tree;
418 } tree_holder;
419 
420 typedef struct _tree_data {
423  bool ignore;
424  bool inserted;
425 
426  union {
428 
429  struct {
432  };
433  };
434 } tree_data;
435 
436 typedef struct {
438 } tree_nonpaged;
439 
440 typedef struct _tree {
447  struct _tree* parent;
449  struct _root* root;
456  bool write;
457  bool is_unique;
460 } tree;
461 
462 typedef struct {
464 } root_nonpaged;
465 
466 typedef struct _root {
468  LONGLONG lastinode; // signed so we can use InterlockedIncrement64
472  bool dirty;
473  bool received;
479  bool dropped;
484 } root;
485 
500 };
501 
502 typedef struct {
504  void* data;
506  enum batch_operation operation;
508 } batch_item;
509 
510 typedef struct {
511  root* r;
514 } batch_root;
515 
516 typedef struct {
519 } traverse_ptr;
520 
521 typedef struct _root_cache {
523  struct _root_cache* next;
524 } root_cache;
525 
526 typedef struct {
531 } space;
532 
533 typedef struct {
537  bool removable;
538  bool seeding;
539  bool readonly;
540  bool reloc;
541  bool trim;
542  bool can_flush;
544  ULONG disk_num;
545  ULONG part_num;
546  uint64_t stats[5];
552 } device;
553 
554 typedef struct {
559 } range_lock;
560 
561 typedef struct {
569 
570 typedef struct {
588  bool created;
589  bool readonly;
590  bool reloc;
593  bool changed;
600 
603 } chunk;
604 
605 typedef struct {
611  bool no_csum;
617 
618 typedef struct {
620 
621  union {
624  };
625 
628 
629 typedef struct {
631  void* data;
634 } sys_chunk;
635 
647 };
648 
649 typedef struct {
651  void* in;
652  void* out;
653  unsigned int inlen, outlen, off, space_left;
658 } calc_job;
659 
660 typedef struct {
664  unsigned int number;
665  bool quit;
667 
668 typedef struct {
675 
676 typedef struct {
677  bool ignore;
678  bool compress;
681  bool readonly;
689  bool no_trim;
693 } mount_options;
694 
695 #define VCB_TYPE_FS 1
696 #define VCB_TYPE_CONTROL 2
697 #define VCB_TYPE_VOLUME 3
698 #define VCB_TYPE_PDO 4
699 #define VCB_TYPE_BUS 5
700 
701 #define BALANCE_OPTS_DATA 0
702 #define BALANCE_OPTS_METADATA 1
703 #define BALANCE_OPTS_SYSTEM 2
704 
705 typedef struct {
710  bool paused;
711  bool stopping;
712  bool removing;
713  bool shrinking;
719 } balance_info;
720 
721 typedef struct {
724  bool recovered;
726  bool parity;
728 
729  union {
730  struct {
735  } data;
736 
737  struct {
741  } metadata;
742  };
743 } scrub_error;
744 
745 typedef struct {
750  bool stopping;
751  bool paused;
762 } scrub_info;
763 
765 
766 typedef struct _device_extension {
773 #ifdef DEBUG_CHUNK_LOCKS
774  LONG chunk_locks_held;
775 #endif
778  unsigned int csum_size;
779  bool readonly;
780  bool removing;
781  bool locked;
785  bool trim;
791  _Has_lock_level_(fcb_lock) ERESOURCE fcb_lock;
794  _Has_lock_level_(tree_lock) ERESOURCE tree_lock;
849 
850 typedef struct {
853 
854 typedef struct {
860 
861 typedef struct {
869  bool seeding;
876 } volume_child;
877 
878 struct pdo_device_extension;
879 
880 typedef struct _volume_device_extension {
889  bool removing;
890  bool dead;
893 
894 typedef struct pdo_device_extension {
899  bool removable;
901 
906 
909 
910 typedef struct {
914 } uid_map;
915 
916 typedef struct {
920 } gid_map;
921 
929 };
930 
931 struct _write_data_context;
932 
933 typedef struct {
943 
944 typedef struct _write_data_context {
948  bool need_wait;
952 
953 typedef struct {
958  bool allocated;
960 } tree_write;
961 
962 typedef struct {
965 } name_bit;
966 
968 _Acquires_shared_lock_(Vcb->fcb_lock)
969 static __inline void acquire_fcb_lock_shared(device_extension* Vcb) {
970  ExAcquireResourceSharedLite(&Vcb->fcb_lock, true);
971 }
972 
973 _Requires_lock_not_held_(Vcb->fcb_lock)
975 static __inline void acquire_fcb_lock_exclusive(device_extension* Vcb) {
976  ExAcquireResourceExclusiveLite(&Vcb->fcb_lock, true);
977 }
978 
980 _Releases_lock_(Vcb->fcb_lock)
981 static __inline void release_fcb_lock(device_extension* Vcb) {
982  ExReleaseResourceLite(&Vcb->fcb_lock);
983 }
984 
985 static __inline void* map_user_buffer(PIRP Irp, ULONG priority) {
986  if (!Irp->MdlAddress) {
987  return Irp->UserBuffer;
988  } else {
989  return MmGetSystemAddressForMdlSafe(Irp->MdlAddress, priority);
990  }
991 }
992 
994  return (t->seconds * 10000000) + (t->nanoseconds / 100) + 116444736000000000;
995 }
996 
997 static __inline void win_time_to_unix(LARGE_INTEGER t, BTRFS_TIME* out) {
998  ULONGLONG l = (ULONGLONG)t.QuadPart - 116444736000000000;
999 
1000  out->seconds = l / 10000000;
1001  out->nanoseconds = (uint32_t)((l % 10000000) * 100);
1002 }
1003 
1004 _Post_satisfies_(*stripe>=0&&*stripe<num_stripes)
1005 static __inline void get_raid0_offset(_In_ uint64_t off, _In_ uint64_t stripe_length, _In_ uint16_t num_stripes, _Out_ uint64_t* stripeoff, _Out_ uint16_t* stripe) {
1006  uint64_t initoff, startoff;
1007 
1008  startoff = off % (num_stripes * stripe_length);
1009  initoff = (off / (num_stripes * stripe_length)) * stripe_length;
1010 
1011  *stripe = (uint16_t)(startoff / stripe_length);
1012  *stripeoff = initoff + startoff - (*stripe * stripe_length);
1013 }
1014 
1015 /* We only have 64 bits for a file ID, which isn't technically enough to be
1016  * unique on Btrfs. We fudge it by having three bytes for the subvol and
1017  * five for the inode, which should be good enough.
1018  * Inodes are also 64 bits on Linux, but the Linux driver seems to get round
1019  * this by tricking it into thinking subvols are separate volumes. */
1021  return (r->id << 40) | (inode & 0xffffffffff);
1022 }
1023 
1024 #define keycmp(key1, key2)\
1025  ((key1.obj_id < key2.obj_id) ? -1 :\
1026  ((key1.obj_id > key2.obj_id) ? 1 :\
1027  ((key1.obj_type < key2.obj_type) ? -1 :\
1028  ((key1.obj_type > key2.obj_type) ? 1 :\
1029  ((key1.offset < key2.offset) ? -1 :\
1030  ((key1.offset > key2.offset) ? 1 :\
1031  0))))))
1032 
1033 _Post_satisfies_(return>=n)
1035  if (n & (a - 1))
1036  n = (n + a) & ~(a - 1);
1037 
1038  return n;
1039 }
1040 
1041 __inline static bool is_subvol_readonly(root* r, PIRP Irp) {
1042  if (!(r->root_item.flags & BTRFS_SUBVOL_READONLY))
1043  return false;
1044 
1045  if (!r->reserved)
1046  return true;
1047 
1048  return (!Irp || Irp->RequestorMode == UserMode) && PsGetCurrentProcess() != r->reserved ? true : false;
1049 }
1050 
1052  switch (type) {
1053  case TYPE_TREE_BLOCK_REF:
1054  return sizeof(TREE_BLOCK_REF);
1055 
1056  case TYPE_EXTENT_DATA_REF:
1057  return sizeof(EXTENT_DATA_REF);
1058 
1059  case TYPE_EXTENT_REF_V0:
1060  return sizeof(EXTENT_REF_V0);
1061 
1062  case TYPE_SHARED_BLOCK_REF:
1063  return sizeof(SHARED_BLOCK_REF);
1064 
1065  case TYPE_SHARED_DATA_REF:
1066  return sizeof(SHARED_DATA_REF);
1067 
1068  default:
1069  return 0;
1070  }
1071 }
1072 
1074  switch (type) {
1075  case TYPE_TREE_BLOCK_REF:
1076  return 1;
1077 
1078  case TYPE_EXTENT_DATA_REF:
1079  {
1081  return edr->count;
1082  }
1083 
1084  case TYPE_EXTENT_REF_V0:
1085  {
1086  EXTENT_REF_V0* erv0 = (EXTENT_REF_V0*)data;
1087  return erv0->count;
1088  }
1089 
1090  case TYPE_SHARED_BLOCK_REF:
1091  return 1;
1092 
1093  case TYPE_SHARED_DATA_REF:
1094  {
1096  return sdr->count;
1097  }
1098 
1099  default:
1100  return 0;
1101  }
1102 }
1103 
1104 // in btrfs.c
1107 
1108 _Success_(return)
1109 bool get_file_attributes_from_xattr(_In_reads_bytes_(len) char* val, _In_ uint16_t len, _Out_ ULONG* atts);
1110 
1112  _In_ uint8_t type, _In_ bool dotfile, _In_ bool ignore_xa, _In_opt_ PIRP Irp);
1113 
1115 bool get_xattr(_In_ _Requires_lock_held_(_Curr_->tree_lock) device_extension* Vcb, _In_ root* subvol, _In_ uint64_t inode, _In_z_ char* name, _In_ uint32_t crc32,
1117 
1118 #ifndef DEBUG_FCB_REFCOUNTS
1119 void free_fcb(_Inout_ fcb* fcb);
1120 #endif
1121 void free_fileref(_Inout_ file_ref* fr);
1123 bool is_top_level(_In_ PIRP Irp);
1125  _Out_ root** rootptr, _In_ bool no_tree, _In_ uint64_t offset, _In_opt_ PIRP Irp);
1128  _Out_writes_bytes_opt_(OutputBufferSize) PVOID OutputBuffer, _In_ ULONG OutputBufferSize, _In_ bool Override, _Out_opt_ IO_STATUS_BLOCK* iosb);
1129 bool is_file_name_valid(_In_ PUNICODE_STRING us, _In_ bool posix, _In_ bool stream);
1132 
1133 #ifdef DEBUG_CHUNK_LOCKS
1134 #define acquire_chunk_lock(c, Vcb) { ExAcquireResourceExclusiveLite(&c->lock, true); InterlockedIncrement(&Vcb->chunk_locks_held); }
1135 #define release_chunk_lock(c, Vcb) { InterlockedDecrement(&Vcb->chunk_locks_held); ExReleaseResourceLite(&c->lock); }
1136 #else
1137 #define acquire_chunk_lock(c, Vcb) ExAcquireResourceExclusiveLite(&(c)->lock, true)
1138 #define release_chunk_lock(c, Vcb) ExReleaseResourceLite(&(c)->lock)
1139 #endif
1140 
1141 void mark_fcb_dirty(_In_ fcb* fcb);
1142 void mark_fileref_dirty(_In_ file_ref* fileref);
1146 void init_device(_In_ device_extension* Vcb, _Inout_ device* dev, _In_ bool get_nums);
1149  _Out_writes_bytes_(Length) PUCHAR Buffer, _In_ bool override);
1153 
1154 _Function_class_(DRIVER_ADD_DEVICE)
1156 
1157 void reap_fcb(fcb* fcb);
1162 NTSTATUS utf8_to_utf16(WCHAR* dest, ULONG dest_max, ULONG* dest_len, char* src, ULONG src_len);
1163 NTSTATUS utf16_to_utf8(char* dest, ULONG dest_max, ULONG* dest_len, WCHAR* src, ULONG src_len);
1165 
1168 
1169 void do_shutdown(PIRP Irp);
1171 
1172 #ifdef _MSC_VER
1173 #define funcname __FUNCTION__
1174 #else
1175 #define funcname __func__
1176 #endif
1177 
1178 extern bool have_sse2;
1179 
1180 extern uint32_t mount_compress;
1183 extern uint32_t mount_zlib_level;
1184 extern uint32_t mount_zstd_level;
1186 extern uint32_t mount_max_inline;
1188 extern uint32_t mount_no_barrier;
1189 extern uint32_t mount_no_trim;
1192 extern uint32_t mount_readonly;
1194 extern uint32_t no_pnp;
1195 
1196 #ifndef __GNUC__
1197 #define __attribute__(x)
1198 #endif
1199 
1200 #ifdef _DEBUG
1201 
1202 extern bool log_started;
1203 extern uint32_t debug_log_level;
1204 
1205 #ifdef DEBUG_LONG_MESSAGES
1206 
1207 #define MSG(fn, file, line, s, level, ...) (!log_started || level <= debug_log_level) ? _debug_message(fn, file, line, s, ##__VA_ARGS__) : (void)0
1208 
1209 #define TRACE(s, ...) MSG(funcname, __FILE__, __LINE__, s, 3, ##__VA_ARGS__)
1210 #define WARN(s, ...) MSG(funcname, __FILE__, __LINE__, s, 2, ##__VA_ARGS__)
1211 #define FIXME(s, ...) MSG(funcname, __FILE__, __LINE__, s, 1, ##__VA_ARGS__)
1212 #define ERR(s, ...) MSG(funcname, __FILE__, __LINE__, s, 1, ##__VA_ARGS__)
1213 
1214 void _debug_message(_In_ const char* func, _In_ const char* file, _In_ unsigned int line, _In_ char* s, ...) __attribute__((format(printf, 4, 5)));
1215 
1216 #else
1217 
1218 #define MSG(fn, s, level, ...) (!log_started || level <= debug_log_level) ? _debug_message(fn, s, ##__VA_ARGS__) : (void)0
1219 
1220 #define TRACE(s, ...) MSG(funcname, s, 3, ##__VA_ARGS__)
1221 #define WARN(s, ...) MSG(funcname, s, 2, ##__VA_ARGS__)
1222 #define FIXME(s, ...) MSG(funcname, s, 1, ##__VA_ARGS__)
1223 #define ERR(s, ...) MSG(funcname, s, 1, ##__VA_ARGS__)
1224 
1225 void _debug_message(_In_ const char* func, _In_ char* s, ...) __attribute__((format(printf, 2, 3)));
1226 
1227 #endif
1228 
1229 #else
1230 
1231 #define TRACE(s, ...)
1232 #define WARN(s, ...)
1233 #define FIXME(s, ...) DbgPrint("Btrfs FIXME : %s : " s, funcname, ##__VA_ARGS__)
1234 #define ERR(s, ...) DbgPrint("Btrfs ERR : %s : " s, funcname, ##__VA_ARGS__)
1235 
1236 #endif
1237 
1238 #ifdef DEBUG_FCB_REFCOUNTS
1239 void _free_fcb(_Inout_ fcb* fcb, _In_ const char* func);
1240 #define free_fcb(fcb) _free_fcb(fcb, funcname)
1241 #endif
1242 
1243 // in fastio.c
1245 
1246 // in sha256.c
1247 void calc_sha256(uint8_t* hash, const void* input, size_t len);
1248 #define SHA256_HASH_SIZE 32
1249 
1250 // in blake2b-ref.c
1251 void blake2b(void *out, size_t outlen, const void* in, size_t inlen);
1252 #define BLAKE2_HASH_SIZE 32
1253 
1254 typedef struct {
1260 } rollback_space;
1261 
1262 typedef struct {
1265 } rollback_extent;
1266 
1272 };
1273 
1274 typedef struct {
1276  void* ptr;
1278 } rollback_item;
1279 
1280 typedef struct {
1285 } ea_item;
1286 
1287 static const char lxuid[] = "$LXUID";
1288 static const char lxgid[] = "$LXGID";
1289 static const char lxmod[] = "$LXMOD";
1290 static const char lxdev[] = "$LXDEV";
1291 
1292 // in treefuncs.c
1294  _In_ const KEY* searchkey, _In_ bool ignore, _In_opt_ PIRP Irp);
1296 bool find_next_item(_Requires_lock_held_(_Curr_->tree_lock) device_extension* Vcb, const traverse_ptr* tp, traverse_ptr* next_tp, bool ignore, PIRP Irp);
1297 bool find_prev_item(_Requires_lock_held_(_Curr_->tree_lock) device_extension* Vcb, const traverse_ptr* tp, traverse_ptr* prev_tp, PIRP Irp);
1303 void free_tree(tree* t);
1311 void clear_batch_list(device_extension* Vcb, LIST_ENTRY* batchlist);
1312 NTSTATUS skip_to_difference(device_extension* Vcb, traverse_ptr* tp, traverse_ptr* tp2, bool* ended1, bool* ended2);
1313 
1314 // in search.c
1316 
1317 _Function_class_(KSTART_ROUTINE)
1318 void __stdcall mountmgr_thread(_In_ void* context);
1319 
1320 _Function_class_(DRIVER_NOTIFICATION_CALLBACK_ROUTINE)
1322 
1326 
1327 _Function_class_(DRIVER_NOTIFICATION_CALLBACK_ROUTINE)
1329 
1331  _In_ volume_child* vc, _In_ bool skip_dev);
1332 
1333 // in cache.c
1334 void init_cache();
1336 
1337 // in write.c
1339 NTSTATUS write_file2(device_extension* Vcb, PIRP Irp, LARGE_INTEGER offset, void* buf, ULONG* length, bool paging_io, bool no_cache,
1340  bool wait, bool deferred_write, bool write_irp, LIST_ENTRY* rollback);
1345 NTSTATUS alloc_chunk(device_extension* Vcb, uint64_t flags, chunk** pc, bool full_size);
1350 
1354 
1359 
1366 void add_extent(_In_ fcb* fcb, _In_ LIST_ENTRY* prevextle, _In_ __drv_aliasesMem extent* newext);
1367 
1368 // in dirctrl.c
1369 
1372 NTSTATUS __stdcall drv_directory_control(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp);
1373 
1376 
1377 // in security.c
1378 
1381 NTSTATUS __stdcall drv_query_security(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp);
1382 
1386 
1387 void fcb_get_sd(fcb* fcb, struct _fcb* parent, bool look_for_xattr, PIRP Irp);
1388 void add_user_mapping(WCHAR* sidstring, ULONG sidstringlength, uint32_t uid);
1389 void add_group_mapping(WCHAR* sidstring, ULONG sidstringlength, uint32_t gid);
1392 NTSTATUS fcb_get_new_sd(fcb* fcb, file_ref* parfileref, ACCESS_STATE* as);
1393 void find_gid(struct _fcb* fcb, struct _fcb* parfcb, PSECURITY_SUBJECT_CONTEXT subjcont);
1394 
1395 // in fileinfo.c
1396 
1399 NTSTATUS __stdcall drv_set_information(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp);
1400 
1403 NTSTATUS __stdcall drv_query_information(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp);
1404 
1408 
1412 
1413 bool has_open_children(file_ref* fileref);
1415 NTSTATUS fileref_get_filename(file_ref* fileref, PUNICODE_STRING fn, USHORT* name_offset, ULONG* preqlen);
1418 
1419 // in reparse.c
1424 
1425 // in create.c
1426 
1430 
1432  _In_ PUNICODE_STRING fnus, _In_opt_ file_ref* related, _In_ bool parent, _Out_opt_ USHORT* parsed, _Out_opt_ ULONG* fn_offset, _In_ POOL_TYPE pooltype,
1433  _In_ bool case_sensitive, _In_opt_ PIRP Irp);
1435  root* subvol, uint64_t inode, uint8_t type, PANSI_STRING utf8, bool always_add_hl, fcb* parent, fcb** pfcb, POOL_TYPE pooltype, PIRP Irp);
1437 NTSTATUS load_dir_children(_Requires_lock_held_(_Curr_->tree_lock) device_extension* Vcb, fcb* fcb, bool ignore_size, PIRP Irp);
1440  _In_ file_ref* sf, _In_ PUNICODE_STRING name, _In_ bool case_sensitive, _In_ bool lastpart, _In_ bool streampart,
1441  _In_ POOL_TYPE pooltype, _Out_ file_ref** psf2, _In_opt_ PIRP Irp);
1443 NTSTATUS find_file_in_dir(PUNICODE_STRING filename, fcb* fcb, root** subvol, uint64_t* inode, dir_child** pdc, bool case_sensitive);
1444 uint32_t inherit_mode(fcb* parfcb, bool is_dir);
1447 
1448 // in fsctl.c
1452 void flush_subvol_fcbs(root* subvol);
1453 bool fcb_is_inline(fcb* fcb);
1455 
1456 // in flushthread.c
1457 
1458 _Function_class_(KSTART_ROUTINE)
1459 void __stdcall flush_thread(void* context);
1460 
1463 NTSTATUS flush_fcb(fcb* fcb, bool cache, LIST_ENTRY* batchlist, PIRP Irp);
1467 NTSTATUS do_tree_writes(device_extension* Vcb, LIST_ENTRY* tree_writes, bool no_free);
1476 
1477 // in read.c
1478 
1482 
1485  _In_ ULONG priority);
1488 NTSTATUS do_read(PIRP Irp, bool wait, ULONG* bytes_read);
1490 void raid6_recover2(uint8_t* sectors, uint16_t num_stripes, ULONG sector_size, uint16_t missing1, uint16_t missing2, uint8_t* out);
1493 void get_sector_csum(device_extension* Vcb, void* buf, void* csum);
1494 bool check_sector_csum(device_extension* Vcb, void* buf, void* csum);
1495 
1496 // in pnp.c
1497 
1501 
1504 
1505 // in free-space.c
1517 
1518 // in extent-tree.c
1521  uint32_t refcount, bool superseded, PIRP Irp);
1529  int32_t count, bool no_csum, bool superseded, PIRP Irp);
1536 
1537 // in worker-thread.c
1541 
1542 // in registry.c
1543 void read_registry(PUNICODE_STRING regpath, bool refresh);
1547 void watch_registry(HANDLE regh);
1548 
1549 // in compress.c
1550 NTSTATUS zlib_decompress(uint8_t* inbuf, uint32_t inlen, uint8_t* outbuf, uint32_t outlen);
1551 NTSTATUS lzo_decompress(uint8_t* inbuf, uint32_t inlen, uint8_t* outbuf, uint32_t outlen, uint32_t inpageoff);
1552 NTSTATUS zstd_decompress(uint8_t* inbuf, uint32_t inlen, uint8_t* outbuf, uint32_t outlen);
1554 NTSTATUS zlib_compress(uint8_t* inbuf, uint32_t inlen, uint8_t* outbuf, uint32_t outlen, unsigned int level, unsigned int* space_left);
1555 NTSTATUS lzo_compress(uint8_t* inbuf, uint32_t inlen, uint8_t* outbuf, uint32_t outlen, unsigned int* space_left);
1556 NTSTATUS zstd_compress(uint8_t* inbuf, uint32_t inlen, uint8_t* outbuf, uint32_t outlen, uint32_t level, unsigned int* space_left);
1557 
1558 // in galois.c
1560 void galois_divpower(uint8_t* data, uint8_t div, uint32_t readlen);
1564 
1565 // in devctrl.c
1566 
1569 NTSTATUS __stdcall drv_device_control(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp);
1570 
1571 // in calcthread.c
1572 
1573 _Function_class_(KSTART_ROUTINE)
1574 void __stdcall calc_thread(void* context);
1575 
1578  void* out, unsigned int outlen, unsigned int off, calc_job** pcj);
1579 NTSTATUS add_calc_job_comp(device_extension* Vcb, uint8_t compression, void* in, unsigned int inlen,
1580  void* out, unsigned int outlen, calc_job** pcj);
1582 
1583 // in balance.c
1591 
1592 _Function_class_(KSTART_ROUTINE)
1593 void __stdcall balance_thread(void* context);
1594 
1595 // in volume.c
1615 void add_volume_device(superblock* sb, PUNICODE_STRING devpath, uint64_t length, ULONG disk_num, ULONG part_num);
1617 
1618 _Function_class_(DRIVER_NOTIFICATION_CALLBACK_ROUTINE)
1620 
1622 
1623 // in scrub.c
1629 
1630 // in send.c
1633 
1634 // in fsrtl.c
1636 
1637 // in boot.c
1639 void boot_add_device(DEVICE_OBJECT* pdo);
1640 extern BTRFS_UUID boot_uuid;
1641 
1642 // based on function in sys/sysmacros.h
1643 #define makedev(major, minor) (((minor) & 0xFF) | (((major) & 0xFFF) << 8) | (((uint64_t)((minor) & ~0xFF)) << 12) | (((uint64_t)((major) & ~0xFFF)) << 32))
1644 
1645 #ifndef __REACTOS__
1646 // not in mingw yet
1647 #ifndef _MSC_VER
1648 typedef struct {
1654  union {
1657  };
1660 
1661 #define FSRTL_FCB_HEADER_V2 2
1662 
1663 #else
1664 #define FSRTL_ADVANCED_FCB_HEADER_NEW FSRTL_ADVANCED_FCB_HEADER
1665 #endif
1666 #else
1667 typedef struct {
1669  PFAST_MUTEX FastMutex;
1670  LIST_ENTRY FilterContexts;
1671  EX_PUSH_LOCK PushLock;
1673  union {
1674  OPLOCK Oplock;
1675  PVOID ReservedForRemote;
1676  };
1677  PVOID ReservedContext;
1679 
1680 #define FSRTL_FCB_HEADER_V2 2
1681 #endif // __REACTOS__
1682 
1683 static __inline POPLOCK fcb_oplock(fcb* fcb) {
1684  if (fcb->Header.Version >= FSRTL_FCB_HEADER_V2)
1685  return &((FSRTL_ADVANCED_FCB_HEADER_NEW*)&fcb->Header)->Oplock;
1686  else
1687  return &fcb->oplock;
1688 }
1689 
1692  return FastIoIsNotPossible;
1693 
1694  if (!FsRtlAreThereCurrentFileLocks(&fcb->lock) && !fcb->Vcb->readonly)
1695  return FastIoIsPossible;
1696 
1697  return FastIoIsQuestionable;
1698 }
1699 
1700 static __inline void print_open_trees(device_extension* Vcb) {
1701  LIST_ENTRY* le = Vcb->trees.Flink;
1702  while (le != &Vcb->trees) {
1704  tree_data* td = CONTAINING_RECORD(t->itemlist.Flink, tree_data, list_entry);
1705  ERR("tree %p: root %I64x, level %u, first key (%I64x,%x,%I64x)\n",
1706  t, t->root->id, t->header.level, td->key.obj_id, td->key.obj_type, td->key.offset);
1707 
1708  le = le->Flink;
1709  }
1710 }
1711 
1712 static __inline bool write_fcb_compressed(fcb* fcb) {
1713  // make sure we don't accidentally write the cache inodes or pagefile compressed
1715  return false;
1716 
1717  if (fcb->Vcb->options.compress_force)
1718  return true;
1719 
1721  return false;
1722 
1723  if (fcb->inode_item.flags & BTRFS_INODE_COMPRESS || fcb->Vcb->options.compress)
1724  return true;
1725 
1726  return false;
1727 }
1728 
1729 static __inline void do_xor(uint8_t* buf1, uint8_t* buf2, uint32_t len) {
1730  uint32_t j;
1731 #ifndef __REACTOS__
1732 #if defined(_X86_) || defined(_AMD64_)
1733  __m128i x1, x2;
1734 
1735  if (have_sse2 && ((uintptr_t)buf1 & 0xf) == 0 && ((uintptr_t)buf2 & 0xf) == 0) {
1736  while (len >= 16) {
1737  x1 = _mm_load_si128((__m128i*)buf1);
1738  x2 = _mm_load_si128((__m128i*)buf2);
1739  x1 = _mm_xor_si128(x1, x2);
1740  _mm_store_si128((__m128i*)buf1, x1);
1741 
1742  buf1 += 16;
1743  buf2 += 16;
1744  len -= 16;
1745  }
1746  }
1747 #elif defined(_ARM_) || defined(_ARM64_)
1748  uint64x2_t x1, x2;
1749 
1750  if (((uintptr_t)buf1 & 0xf) == 0 && ((uintptr_t)buf2 & 0xf) == 0) {
1751  while (len >= 16) {
1752  x1 = vld1q_u64((const uint64_t*)buf1);
1753  x2 = vld1q_u64((const uint64_t*)buf2);
1754  x1 = veorq_u64(x1, x2);
1755  vst1q_u64((uint64_t*)buf1, x1);
1756 
1757  buf1 += 16;
1758  buf2 += 16;
1759  len -= 16;
1760  }
1761  }
1762 #endif
1763 #endif // __REACTOS__
1764 
1765  for (j = 0; j < len; j++) {
1766  *buf1 ^= *buf2;
1767  buf1++;
1768  buf2++;
1769  }
1770 }
1771 
1772 #ifdef DEBUG_FCB_REFCOUNTS
1773 #ifdef DEBUG_LONG_MESSAGES
1774 #define increase_fileref_refcount(fileref) {\
1775  LONG rc = InterlockedIncrement(&fileref->refcount);\
1776  MSG(funcname, __FILE__, __LINE__, "fileref %p: refcount now %i\n", 1, fileref, rc);\
1777 }
1778 #else
1779 #define increase_fileref_refcount(fileref) {\
1780  LONG rc = InterlockedIncrement(&fileref->refcount);\
1781  MSG(funcname, "fileref %p: refcount now %i\n", 1, fileref, rc);\
1782 }
1783 #endif
1784 #else
1785 #define increase_fileref_refcount(fileref) InterlockedIncrement(&fileref->refcount)
1786 #endif
1787 
1788 #ifdef _MSC_VER
1789 #define int3 __debugbreak()
1790 #else
1791 #define int3 asm("int3;")
1792 #endif
1793 
1794 #define hex_digit(c) ((c) <= 9) ? ((c) + '0') : ((c) - 10 + 'a')
1795 
1796 // FIXME - find a way to catch unfreed trees again
1797 
1798 // from sys/stat.h
1799 #define __S_IFMT 0170000 /* These bits determine file type. */
1800 #define __S_IFDIR 0040000 /* Directory. */
1801 #define __S_IFCHR 0020000 /* Character device. */
1802 #define __S_IFBLK 0060000 /* Block device. */
1803 #define __S_IFREG 0100000 /* Regular file. */
1804 #define __S_IFIFO 0010000 /* FIFO. */
1805 #define __S_IFLNK 0120000 /* Symbolic link. */
1806 #define __S_IFSOCK 0140000 /* Socket. */
1807 #define __S_ISTYPE(mode, mask) (((mode) & __S_IFMT) == (mask))
1808 
1809 #ifndef S_ISDIR
1810 #define S_ISDIR(mode) __S_ISTYPE((mode), __S_IFDIR)
1811 #endif
1812 
1813 #ifndef S_IRUSR
1814 #define S_IRUSR 0000400
1815 #endif
1816 
1817 #ifndef S_IWUSR
1818 #define S_IWUSR 0000200
1819 #endif
1820 
1821 #ifndef S_IXUSR
1822 #define S_IXUSR 0000100
1823 #endif
1824 
1825 #ifdef __REACTOS__
1826 #define S_IFDIR __S_IFDIR
1827 #define S_IFREG __S_IFREG
1828 #endif /* __REACTOS__ */
1829 
1830 #ifndef S_IRGRP
1831 #define S_IRGRP (S_IRUSR >> 3)
1832 #endif
1833 
1834 #ifndef S_IWGRP
1835 #define S_IWGRP (S_IWUSR >> 3)
1836 #endif
1837 
1838 #ifndef S_IXGRP
1839 #define S_IXGRP (S_IXUSR >> 3)
1840 #endif
1841 
1842 #ifndef S_IROTH
1843 #define S_IROTH (S_IRGRP >> 3)
1844 #endif
1845 
1846 #ifndef S_IWOTH
1847 #define S_IWOTH (S_IWGRP >> 3)
1848 #endif
1849 
1850 #ifndef S_IXOTH
1851 #define S_IXOTH (S_IXGRP >> 3)
1852 #endif
1853 
1854 #ifndef S_ISUID
1855 #define S_ISUID 0004000
1856 #endif
1857 
1858 #ifndef S_ISGID
1859 #define S_ISGID 0002000
1860 #endif
1861 
1862 #ifndef S_ISVTX
1863 #define S_ISVTX 0001000
1864 #endif
1865 
1866 // based on functions in sys/sysmacros.h
1867 #define major(rdev) ((((rdev) >> 8) & 0xFFF) | ((uint32_t)((rdev) >> 32) & ~0xFFF))
1868 #define minor(rdev) (((rdev) & 0xFF) | ((uint32_t)((rdev) >> 12) & ~0xFF))
1869 
1870 static __inline uint64_t fcb_alloc_size(fcb* fcb) {
1871  if (S_ISDIR(fcb->inode_item.st_mode))
1872  return 0;
1873  else if (fcb->atts & FILE_ATTRIBUTE_SPARSE_FILE)
1874  return fcb->inode_item.st_blocks;
1875  else
1876  return sector_align(fcb->inode_item.st_size, fcb->Vcb->superblock.sector_size);
1877 }
1878 
1880 
1882  ULONG ReadOperationCount, ULONG WriteOperationCount, ULONG FlushOperationCount);
1883 
1885  PVOID Buffer, PETHREAD IoIssuerThread);
1886 
1888  PVOID Buffer, PIO_STATUS_BLOCK IoStatus, PETHREAD IoIssuerThread);
1889 
1890 #ifndef CC_ENABLE_DISK_IO_ACCOUNTING
1891 #define CC_ENABLE_DISK_IO_ACCOUNTING 0x00000010
1892 #endif
1893 
1894 #if defined(__REACTOS__) && (NTDDI_VERSION < NTDDI_VISTA)
1895 typedef struct _ECP_LIST ECP_LIST;
1896 typedef struct _ECP_LIST *PECP_LIST;
1897 #endif
1898 
1900 
1902 
1904 
1906 
1909 
1911 
1913 
1915 
1916 #ifndef __REACTOS__
1917 #ifndef _MSC_VER
1919 #endif
1920 
1921 // not in DDK headers - taken from winternl.h
1922 typedef struct _LDR_DATA_TABLE_ENTRY {
1931  union {
1934  };
1937 
1938 typedef struct _PEB_LDR_DATA {
1943 
1950 
1952 
1953 typedef struct _PEB {
1966 } PEB,*PPEB;
1967 #endif /* __REACTOS__ */
1968 
1969 #ifdef _MSC_VER
1973  IN PROCESSINFOCLASS ProcessInformationClass,
1974  OUT PVOID ProcessInformation,
1975  IN ULONG ProcessInformationLength,
1977 );
1978 #endif
uint64_t get_extent_data_ref_hash2(uint64_t root, uint64_t objid, uint64_t offset)
Definition: extent-tree.c:35
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
VOID(__stdcall * tFsRtlUpdateDiskCounters)(ULONG64 BytesRead, ULONG64 BytesWritten)
Definition: btrfs_drv.h:1901
void add_volume_device(superblock *sb, PUNICODE_STRING devpath, uint64_t length, ULONG disk_num, ULONG part_num)
Definition: volume.c:1162
CACHE_MANAGER_CALLBACKS cache_callbacks
Definition: cache.c:20
NTSTATUS do_load_tree(device_extension *Vcb, tree_holder *th, root *r, tree *t, tree_data *td, PIRP Irp)
Definition: treefuncs.c:219
LIST_ENTRY * list_size
Definition: btrfs_drv.h:1256
SHARED_DATA_REF sdr
Definition: btrfs_drv.h:623
struct _file_ref * parent
Definition: btrfs_drv.h:368
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesWritten
Definition: wdfiotarget.h:949
Definition: cache.c:48
_Must_inspect_result_ _In_ FSRTL_ALLOCATE_ECPLIST_FLAGS _Outptr_ PECP_LIST * EcpList
Definition: fltkernel.h:2511
LIST_ENTRY list_entry
Definition: btrfs_drv.h:507
GLenum func
Definition: glext.h:6028
mount_options options
Definition: btrfs_drv.h:768
void free_fileref(_Inout_ file_ref *fr)
Definition: btrfs.c:1786
_In_ PVOID NotificationStructure
Definition: iofuncs.h:1203
ULONG * bmparr
Definition: btrfs_drv.h:563
uint64_t obj_id
Definition: btrfs.h:137
void galois_double(uint8_t *data, uint32_t len)
Definition: galois.c:109
struct _FILE_ID_128 * PFILE_ID_128
void do_rollback(device_extension *Vcb, LIST_ENTRY *rollback)
Definition: treefuncs.c:1050
struct _DUPLICATE_EXTENTS_DATA DUPLICATE_EXTENTS_DATA
bool boot_volume
Definition: btrfs_drv.h:874
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:39
static PIO_STATUS_BLOCK iosb
Definition: file.c:98
struct _LDR_DATA_TABLE_ENTRY LDR_DATA_TABLE_ENTRY
BYTE Reserved4[104]
Definition: btrfs_drv.h:1960
bool check_superblock_checksum(superblock *sb)
Definition: btrfs.c:2761
void clear_rollback(LIST_ENTRY *rollback)
Definition: treefuncs.c:1029
uint16_t last_stripe
Definition: btrfs_drv.h:596
GLint level
Definition: gl.h:1546
struct _root * root
Definition: btrfs_drv.h:449
#define IN
Definition: typedefs.h:39
PDEVICE_OBJECT buspdo
Definition: btrfs_drv.h:856
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3767
NTSTATUS zstd_decompress(uint8_t *inbuf, uint32_t inlen, uint8_t *outbuf, uint32_t outlen)
Definition: compress.c:676
return
Definition: dirsup.c:529
bool has_address
Definition: btrfs_drv.h:444
struct _FSCTL_GET_INTEGRITY_INFORMATION_BUFFER * PFSCTL_GET_INTEGRITY_INFORMATION_BUFFER
uint32_t mount_compress_type
Definition: btrfs.c:80
static const char lxuid[]
Definition: btrfs_drv.h:1287
_Post_satisfies_(return >=n) __inline static uint64_t sector_align(_In_ uint64_t n
NTSTATUS read_send_buffer(device_extension *Vcb, PFILE_OBJECT FileObject, void *data, ULONG datalen, ULONG_PTR *retlen, KPROCESSOR_MODE processor_mode)
Definition: send.c:3839
_In_ fcb _In_ chunk _In_ uint64_t _In_ uint64_t _In_ bool _In_opt_ void _In_opt_ PIRP _In_ LIST_ENTRY _In_ uint8_t _In_ uint64_t _In_ bool file_write
Definition: btrfs_drv.h:1357
NTSTATUS zlib_compress(uint8_t *inbuf, uint32_t inlen, uint8_t *outbuf, uint32_t outlen, unsigned int level, unsigned int *space_left)
Definition: compress.c:336
UNICODE_STRING pnp_name
Definition: btrfs_drv.h:867
void reap_fcb(fcb *fcb)
Definition: btrfs.c:1673
LIST_ENTRY trees
Definition: btrfs_drv.h:816
LIST_ENTRY trees_hash
Definition: btrfs_drv.h:817
void trim_whole_device(device *dev)
Definition: fsctl.c:2710
struct _file_ref * fileref
Definition: btrfs_drv.h:271
uint16_t size
Definition: btrfs_drv.h:572
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
_In_ ULONG cj
Definition: winddi.h:3540
root * data_reloc_root
Definition: btrfs_drv.h:810
LIST_ENTRY space
Definition: btrfs_drv.h:548
uint8_t obj_type
Definition: btrfs.h:138
NTSTATUS remove_device(device_extension *Vcb, void *data, ULONG length, KPROCESSOR_MODE processor_mode)
Definition: balance.c:3803
_In_ uint16_t len
Definition: btrfs_drv.h:1109
LIST_ENTRY dirty_filerefs
Definition: btrfs_drv.h:823
PFILE_OBJECT fileobj
Definition: btrfs_drv.h:535
bool skip_balance
Definition: btrfs_drv.h:687
scrub_info scrub
Definition: btrfs_drv.h:833
NTSTATUS do_read_job(PIRP Irp)
Definition: worker-thread.c:26
struct LOOKASIDE_ALIGN _NPAGED_LOOKASIDE_LIST NPAGED_LOOKASIDE_LIST
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
PAGED_LOOKASIDE_LIST batch_item_lookaside
Definition: btrfs_drv.h:840
void init_fast_io_dispatch(FAST_IO_DISPATCH **fiod)
Definition: fastio.c:486
LIST_ENTRY list_entry
Definition: btrfs_drv.h:601
NTSTATUS update_changed_extent_ref(device_extension *Vcb, chunk *c, uint64_t address, uint64_t size, uint64_t root, uint64_t objid, uint64_t offset, int32_t count, bool no_csum, bool superseded, PIRP Irp)
Definition: extent-tree.c:1951
NTSTATUS vol_query_volume_information(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: volume.c:336
LIST_ENTRY list_entry
Definition: btrfs_drv.h:1284
chunk * c
Definition: btrfs_drv.h:957
#define FILE_ATTRIBUTE_SPARSE_FILE
Definition: ntifs_ex.h:380
uint64_t start
Definition: btrfs_drv.h:555
LIST_ENTRY list_entry
Definition: btrfs_drv.h:549
uint64_t system_flags
Definition: btrfs_drv.h:801
rwlock_t lock
Definition: tcpcore.h:1163
void free_write_data_stripes(write_data_context *wtc)
Definition: write.c:2307
#define _Create_lock_level_(a)
Definition: btrfs_drv.h:211
BTRFS_UUID boot_uuid
Definition: boot.c:33
LIST_ENTRY list_entry
Definition: btrfs_drv.h:615
#define _Dispatch_type_(a)
Definition: btrfs_drv.h:210
ULONG options
Definition: btrfs_drv.h:390
NTSTATUS fsctl_request(PDEVICE_OBJECT DeviceObject, PIRP *Pirp, uint32_t type)
Definition: fsctl.c:4968
NTSTATUS open_fileref_by_inode(_Requires_exclusive_lock_held_(_Curr_->fcb_lock) device_extension *Vcb, root *subvol, uint64_t inode, file_ref **pfr, PIRP Irp)
Definition: create.c:4068
PAGED_LOOKASIDE_LIST fcb_lookaside
Definition: btrfs_drv.h:842
#define IRP_MJ_QUERY_SECURITY
_In_ PFCB _In_ LONGLONG StartingOffset
Definition: cdprocs.h:290
void * in
Definition: btrfs_drv.h:651
#define _In_reads_bytes_(s)
Definition: no_sal2.h:170
#define error(str)
Definition: mkdosfs.c:1605
uint32_t adshash
Definition: btrfs_drv.h:342
bool paused
Definition: btrfs_drv.h:751
NTSTATUS(__stdcall * tFsRtlGetNextExtraCreateParameter)(PECP_LIST EcpList, PVOID CurrentEcpContext, LPGUID NextEcpType, PVOID *NextEcpContext, ULONG *NextEcpContextSize)
Definition: btrfs_drv.h:1907
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
struct _root_cache root_cache
NPAGED_LOOKASIDE_LIST fcb_np_lookaside
Definition: btrfs_drv.h:846
void blake2b(void *out, size_t outlen, const void *in, size_t inlen)
Definition: blake2b-ref.c:237
PAGED_LOOKASIDE_LIST traverse_ptr_lookaside
Definition: btrfs_drv.h:839
static const char lxdev[]
Definition: btrfs_drv.h:1290
static __inline void do_xor(uint8_t *buf1, uint8_t *buf2, uint32_t len)
Definition: btrfs_drv.h:1729
NTSTATUS fileref_get_filename(file_ref *fileref, PUNICODE_STRING fn, USHORT *name_offset, ULONG *preqlen)
Definition: fileinfo.c:4168
uint64_t offset
Definition: btrfs_drv.h:732
void space_list_subtract(chunk *c, bool deleting, uint64_t address, uint64_t length, LIST_ENTRY *rollback)
Definition: free-space.c:2047
unsigned int csum_size
Definition: btrfs_drv.h:778
struct _FSCTL_SET_INTEGRITY_INFORMATION_BUFFER * PFSCTL_SET_INTEGRITY_INFORMATION_BUFFER
NTSTATUS vol_set_security(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: volume.c:911
Definition: http.c:7094
NTSTATUS start_scrub(device_extension *Vcb, KPROCESSOR_MODE processor_mode)
Definition: scrub.c:3261
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
LIST_ENTRY list_entry
Definition: btrfs_drv.h:482
uint32_t count
Definition: btrfs.h:421
UNICODE_STRING name_uc
Definition: btrfs_drv.h:269
NTSTATUS write_data_complete(device_extension *Vcb, uint64_t address, void *data, uint32_t length, PIRP Irp, chunk *c, bool file_write, uint64_t irp_offset, ULONG priority)
Definition: write.c:2182
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
bool dirty
Definition: btrfs_drv.h:331
NTSTATUS vol_query_security(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: volume.c:905
enum _FAST_IO_POSSIBLE FAST_IO_POSSIBLE
NTSTATUS add_calc_job_decomp(device_extension *Vcb, uint8_t compression, void *in, unsigned int inlen, void *out, unsigned int outlen, unsigned int off, calc_job **pcj)
Definition: calcthread.c:183
superblock * sb
Definition: btrfs.c:4220
root * checksum_root
Definition: btrfs_drv.h:807
#define pt(x, y)
Definition: drawing.c:79
void add_user_mapping(WCHAR *sidstring, ULONG sidstringlength, uint32_t uid)
Definition: security.c:56
static const BYTE us[]
Definition: encode.c:689
bool inserted
Definition: btrfs_drv.h:424
void raid6_recover2(uint8_t *sectors, uint16_t num_stripes, ULONG sector_size, uint16_t missing1, uint16_t missing2, uint8_t *out)
Definition: read.c:933
tree_nonpaged * nonpaged
Definition: btrfs_drv.h:441
UNICODE_STRING us
Definition: btrfs_drv.h:963
NTSTATUS find_chunk_usage(_In_ _Requires_lock_held_(_Curr_->tree_lock) device_extension *Vcb, _In_opt_ PIRP Irp)
Definition: btrfs.c:3835
NTSTATUS uid_to_sid(uint32_t uid, PSID *sid)
Definition: security.c:229
ULONG size
Definition: btrfs_drv.h:270
NTSTATUS load_tree(device_extension *Vcb, uint64_t addr, uint8_t *buf, root *r, tree **pt)
Definition: treefuncs.c:21
_In_ ULONG * pcj
Definition: winddi.h:3642
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
NTSTATUS decrease_extent_refcount(device_extension *Vcb, uint64_t address, uint64_t size, uint8_t type, void *data, KEY *firstitem, uint8_t level, uint64_t parent, bool superseded, PIRP Irp)
Definition: extent-tree.c:903
DRIVER_ADD_DEVICE AddDevice
Definition: parport.h:72
LIST_ENTRY list_entry
Definition: btrfs_drv.h:626
struct _FILE_ID_128 FILE_ID_128
root * root
Definition: btrfs_drv.h:522
_In_ WDFDPC _In_ BOOLEAN Wait
Definition: wdfdpc.h:167
uint64_t offset
Definition: btrfs_drv.h:573
IN PIRP Irp
Definition: btrfs_drv.h:1353
void fcb_get_sd(fcb *fcb, struct _fcb *parent, bool look_for_xattr, PIRP Irp)
Definition: security.c:511
struct _tree tree
int ignore(int trapCode, ppc_trap_frame_t *trap)
Definition: mmuobject.c:296
bool reparse_xattr_changed
Definition: btrfs_drv.h:335
GLuint GLuint GLsizei count
Definition: gl.h:1545
NTSTATUS do_write(device_extension *Vcb, PIRP Irp)
Definition: flushthread.c:7789
#define IRP_MJ_SET_SECURITY
struct _device_extension device_extension
unsigned char * PUCHAR
Definition: retypes.h:3
fcb * create_fcb(device_extension *Vcb, POOL_TYPE pool_type)
Definition: create.c:79
PDEVICE_OBJECT devobj
Definition: btrfs_drv.h:534
uint32_t mount_allow_degraded
Definition: btrfs.c:89
struct _root root
superblock superblock
Definition: btrfs_drv.h:777
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3706
NTSTATUS registry_mark_volume_mounted(BTRFS_UUID *uuid)
Definition: registry.c:235
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
PDEVICE_OBJECT device
Definition: btrfs_drv.h:883
NTSTATUS open_fcb(_Requires_lock_held_(_Curr_->tree_lock) _Requires_exclusive_lock_held_(_Curr_->fcb_lock) device_extension *Vcb, root *subvol, uint64_t inode, uint8_t type, PANSI_STRING utf8, bool always_add_hl, fcb *parent, fcb **pfcb, POOL_TYPE pooltype, PIRP Irp)
Definition: create.c:699
#define FSRTL_FLAG2_IS_PAGING_FILE
Definition: fsrtltypes.h:57
bool can_flush
Definition: btrfs_drv.h:542
void reap_filerefs(device_extension *Vcb, file_ref *fr)
Definition: btrfs.c:1841
LONG NTSTATUS
Definition: precomp.h:26
PAGED_LOOKASIDE_LIST tree_data_lookaside
Definition: btrfs_drv.h:838
batch_operation
Definition: btrfs_drv.h:486
bool sd_deleted
Definition: btrfs_drv.h:332
bool no_barrier
Definition: btrfs_drv.h:688
#define ERR(s,...)
Definition: btrfs_drv.h:1234
tree_holder treeholder
Definition: btrfs_drv.h:427
ERESOURCE fileref_lock
Definition: btrfs_drv.h:792
LIST_ENTRY InMemoryOrderModuleList
Definition: btrfs_drv.h:1941
enum prop_compression_type prop_compression
Definition: btrfs_drv.h:318
uint16_t size
Definition: btrfs_drv.h:430
bool lock_paused_balance
Definition: btrfs_drv.h:782
ANSI_STRING ea_xattr
Definition: btrfs_drv.h:313
static int inbuf
Definition: adnsresfilter.c:73
KEVENT event
Definition: btrfs_drv.h:748
bool dirty
Definition: btrfs_drv.h:472
uint64_t data_flags
Definition: btrfs_drv.h:799
ERESOURCE range_locks_lock
Definition: btrfs_drv.h:584
LIST_ENTRY list_entry_hash
Definition: btrfs_drv.h:452
NTSTATUS update_chunk_caches(device_extension *Vcb, PIRP Irp, LIST_ENTRY *rollback)
Definition: free-space.c:1847
NTSTATUS flush_partial_stripe(device_extension *Vcb, chunk *c, partial_stripe *ps)
Definition: flushthread.c:5863
#define TYPE_TREE_BLOCK_REF
Definition: btrfs.h:33
void init_file_cache(_In_ PFILE_OBJECT FileObject, _In_ CC_FILE_SIZES *ccfs)
Definition: btrfs.c:4028
void free_fcb(_Inout_ fcb *fcb)
Definition: btrfs.c:1664
GLdouble n
Definition: glext.h:7729
BYTE Reserved2[1]
Definition: btrfs_drv.h:1956
NTSTATUS load_csum(_Requires_lock_held_(_Curr_->tree_lock) device_extension *Vcb, void *csum, uint64_t start, uint64_t length, PIRP Irp)
Definition: create.c:446
ERESOURCE chunk_lock
Definition: btrfs_drv.h:827
bool removing
Definition: btrfs_drv.h:712
PKTHREAD lazy_writer_thread
Definition: btrfs_drv.h:307
ERESOURCE dirty_filerefs_lock
Definition: btrfs_drv.h:824
GLdouble GLdouble t
Definition: gl.h:2047
ERESOURCE load_tree_lock
Definition: btrfs_drv.h:463
void * csum
Definition: btrfs_drv.h:244
bool dev_readonly
Definition: btrfs_drv.h:714
NTSTATUS vol_set_ea(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: volume.c:324
bool xattrs_changed
Definition: btrfs_drv.h:338
#define _Acquires_exclusive_lock_(a)
Definition: btrfs_drv.h:215
LIST_ENTRY list_entry_dirty
Definition: btrfs_drv.h:483
void free_vol(volume_device_extension *vde)
Definition: volume.c:50
NTSTATUS vol_flush_buffers(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: volume.c:330
Definition: write.c:111
file_ref_nonpaged * nonpaged
Definition: btrfs_drv.h:364
ANSI_STRING utf8
Definition: btrfs_drv.h:265
FT_UInt sid
Definition: cffcmap.c:139
ROOT_ITEM root_item
Definition: btrfs_drv.h:471
LIST_ENTRY list_entry
Definition: btrfs_drv.h:246
ANSI_STRING reparse_xattr
Definition: btrfs_drv.h:312
PDEVICE_OBJECT pdo
Definition: btrfs_drv.h:885
uint64_t used
Definition: btrfs_drv.h:574
NTSTATUS increase_extent_refcount(device_extension *Vcb, uint64_t address, uint64_t size, uint8_t type, void *data, KEY *firstitem, uint8_t level, PIRP Irp)
Definition: extent-tree.c:454
HANDLE thread
Definition: btrfs_drv.h:706
uint8_t compress_type
Definition: btrfs_drv.h:680
LIST_ENTRY errors
Definition: btrfs_drv.h:761
void get_raid56_lock_range(chunk *c, uint64_t address, uint64_t length, uint64_t *lockaddr, uint64_t *locklen)
Definition: write.c:2166
uint64_t address
Definition: btrfs_drv.h:562
uint32_t hash
Definition: btrfs_drv.h:266
GLuint buffer
Definition: glext.h:5915
BYTE BeingDebugged
Definition: btrfs_drv.h:1955
struct _PEB_LDR_DATA * PPEB_LDR_DATA
PNOTIFY_SYNC NotifySync
Definition: btrfs_drv.h:795
uint16_t datalen
Definition: btrfs_drv.h:240
uint32_t mount_readonly
Definition: btrfs.c:90
uint32_t mount_no_trim
Definition: btrfs.c:87
struct _volume_device_extension * vde
Definition: btrfs_drv.h:771
void add_changed_extent_ref(chunk *c, uint64_t address, uint64_t size, uint64_t root, uint64_t objid, uint64_t offset, uint32_t count, bool no_csum)
Definition: extent-tree.c:2076
KEVENT event
Definition: btrfs_drv.h:655
ERESOURCE load_lock
Definition: btrfs_drv.h:793
bool have_sse2
Definition: btrfs.c:71
bool readonly
Definition: btrfs_drv.h:539
NTSTATUS stop_scrub(device_extension *Vcb, KPROCESSOR_MODE processor_mode)
Definition: scrub.c:3441
ERESOURCE send_load_lock
Definition: btrfs_drv.h:834
NTSTATUS get_device_pnp_name(_In_ PDEVICE_OBJECT DeviceObject, _Out_ PUNICODE_STRING pnp_name, _Out_ const GUID **guid)
Definition: btrfs.c:4192
bool clear_cache
Definition: btrfs_drv.h:690
uint64_t length
Definition: btrfs_drv.h:556
uint64_t old_size
Definition: btrfs_drv.h:608
uint64_t chunk_estimate_phys_size(device_extension *Vcb, chunk *c, uint64_t u)
Definition: btrfs.c:3809
bool readonly
Definition: btrfs_drv.h:589
void watch_registry(HANDLE regh)
Definition: registry.c:1028
NTSTATUS find_file_in_dir(PUNICODE_STRING filename, fcb *fcb, root **subvol, uint64_t *inode, dir_child **pdc, bool case_sensitive)
Definition: create.c:179
LONG open_count
Definition: btrfs_drv.h:367
NTSTATUS zstd_compress(uint8_t *inbuf, uint32_t inlen, uint8_t *outbuf, uint32_t outlen, uint32_t level, unsigned int *space_left)
Definition: compress.c:807
RTL_BITMAP bmp
Definition: btrfs_drv.h:565
PRTL_USER_PROCESS_PARAMETERS ProcessParameters
Definition: btrfs_drv.h:1959
LONGLONG lastinode
Definition: btrfs_drv.h:468
ACCESS_MASK access
Definition: btrfs_drv.h:398
LIST_ENTRY fcbs
Definition: btrfs_drv.h:480
unsigned short int uint16_t
Definition: acefiex.h:54
bool is_extent_unique(device_extension *Vcb, uint64_t address, uint64_t size, PIRP Irp)
Definition: extent-tree.c:1697
NTSTATUS read_file(fcb *fcb, uint8_t *data, uint64_t start, uint64_t length, ULONG *pbr, PIRP Irp)
Definition: read.c:2828
#define uint16_t
Definition: nsiface.idl:60
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1155
NTSTATUS truncate_file(fcb *fcb, uint64_t end, PIRP Irp, LIST_ENTRY *rollback)
Definition: write.c:3216
void calc_sha256(uint8_t *hash, const void *input, size_t len)
Definition: sha256.c:126
ULONG part_num
Definition: btrfs_drv.h:873
void * out
Definition: btrfs_drv.h:652
LIST_ENTRY list_entry
Definition: btrfs_drv.h:451
FAST_MUTEX HeaderMutex
Definition: btrfs_drv.h:229
NTSTATUS vol_write(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: volume.c:225
ERESOURCE paging_resource
Definition: btrfs_drv.h:232
NTSTATUS do_write_job(device_extension *Vcb, PIRP Irp)
Definition: worker-thread.c:68
int const JOCTET unsigned int datalen
Definition: jpeglib.h:1030
bool atts_changed
Definition: btrfs_drv.h:333
const char * filename
Definition: ioapi.h:135
#define MmGetSystemAddressForMdlSafe(_Mdl, _Priority)
NTSTATUS write_file(device_extension *Vcb, PIRP Irp, bool wait, bool deferred_write)
Definition: write.c:4545
NTSTATUS utf8_to_utf16(WCHAR *dest, ULONG dest_max, ULONG *dest_len, char *src, ULONG src_len)
Definition: btrfs.c:727
bool check_sector_csum(device_extension *Vcb, void *buf, void *csum)
Definition: read.c:202
LIST_ENTRY old_refs
Definition: btrfs_drv.h:614
PSID sid
Definition: btrfs_drv.h:918
bool updated_extents
Definition: btrfs_drv.h:455
uint32_t debug_log_level
Definition: btrfs.c:77
NTSTATUS query_balance(device_extension *Vcb, void *data, ULONG length)
Definition: balance.c:3715
uint64_t parent
Definition: btrfs_drv.h:475
device * device
Definition: btrfs_drv.h:937
OPLOCK oplock
Definition: btrfs_drv.h:323
bool manage_volume_privilege
Definition: btrfs_drv.h:395
localAdvHdr FileContextSupportPointer
Definition: fsrtlfuncs.h:1704
uint64_t offset
Definition: btrfs.h:139
LIST_ENTRY list_entry
Definition: btrfs_drv.h:964
_Post_satisfies_ static stripe __inline void get_raid0_offset(_In_ uint64_t off, _In_ uint64_t stripe_length, _In_ uint16_t num_stripes, _Out_ uint64_t *stripeoff, _Out_ uint16_t *stripe)
Definition: btrfs_drv.h:1005
bool dropped
Definition: btrfs_drv.h:479
uint8_t * data
Definition: btrfs_drv.h:431
LARGE_INTEGER resume_time
Definition: btrfs_drv.h:754
device ** devices
Definition: btrfs_drv.h:576
bool ignore
Definition: btrfs_drv.h:242
NTSTATUS utf16_to_utf8(char *dest, ULONG dest_max, ULONG *dest_len, WCHAR *src, ULONG src_len)
Definition: btrfs.c:816
LIST_ENTRY devices
Definition: btrfs_drv.h:772
bool has_wildcard
Definition: btrfs_drv.h:393
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define _Requires_exclusive_lock_held_(a)
Definition: btrfs_drv.h:207
uint64_t fcbs_version
Definition: btrfs_drv.h:477
UNICODE_STRING bus_name
Definition: btrfs_drv.h:858
PAGED_LOOKASIDE_LIST name_bit_lookaside
Definition: btrfs_drv.h:843
#define _In_opt_
Definition: no_sal2.h:212
struct _DUPLICATE_EXTENTS_DATA * PDUPLICATE_EXTENTS_DATA
balance_info balance
Definition: btrfs_drv.h:832
NTSTATUS stop_balance(device_extension *Vcb, KPROCESSOR_MODE processor_mode)
Definition: balance.c:3788
NTSTATUS error
Definition: btrfs_drv.h:759
SECTION_OBJECT_POINTERS segment_object
Definition: btrfs_drv.h:230
UNICODE_STRING filename
Definition: btrfs_drv.h:400
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesRead
Definition: wdfiotarget.h:859
NTSTATUS mountmgr_add_drive_letter(PDEVICE_OBJECT mountmgr, PUNICODE_STRING devpath)
Definition: volume.c:917
uint64_t chunks_left
Definition: btrfs_drv.h:708
void galois_divpower(uint8_t *data, uint8_t div, uint32_t readlen)
Definition: galois.c:55
VOID(NTAPI * PPS_POST_PROCESS_INIT_ROUTINE)(VOID)
Definition: btrfs_drv.h:1951
bool posix_delete
Definition: btrfs_drv.h:361
struct _write_data_context * context
Definition: btrfs_drv.h:934
KTIMER flush_thread_timer
Definition: btrfs_drv.h:829
BTRFS_UUID uuid
Definition: btrfs_drv.h:862
static WCHAR superseded[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1817
LIST_ENTRY list_entry_all
Definition: btrfs_drv.h:348
bool user_set_write_time
Definition: btrfs_drv.h:405
UNICODE_STRING query_string
Definition: btrfs_drv.h:392
uint64_t oldindex
Definition: btrfs_drv.h:359
uint32_t ULONG_PTR
Definition: typedefs.h:65
KEVENT finished
Definition: btrfs_drv.h:718
NTSTATUS open_fileref_child(_Requires_lock_held_(_Curr_->tree_lock) _Requires_exclusive_lock_held_(_Curr_->fcb_lock) _In_ device_extension *Vcb, _In_ file_ref *sf, _In_ PUNICODE_STRING name, _In_ bool case_sensitive, _In_ bool lastpart, _In_ bool streampart, _In_ POOL_TYPE pooltype, _Out_ file_ref **psf2, _In_opt_ PIRP Irp)
Definition: create.c:1452
bool is_top_level(_In_ PIRP Irp)
Definition: btrfs.c:279
FxDevice * device
_In_ fcb _In_ chunk _In_ uint64_t start_data
Definition: btrfs_drv.h:1357
#define FSRTL_FCB_HEADER_V2
Definition: btrfs_drv.h:1661
void * data
Definition: btrfs_drv.h:504
uint64_t length
Definition: btrfs_drv.h:1258
Definition: fs.h:78
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
struct _RTL_USER_PROCESS_PARAMETERS * PRTL_USER_PROCESS_PARAMETERS
uint64_t address
Definition: btrfs_drv.h:527
UNICODE_STRING name
Definition: btrfs_drv.h:882
PEPROCESS __stdcall PsGetThreadProcess(_In_ PETHREAD Thread)
PVOID DllBase
Definition: btrfs_drv.h:1926
ULONG get_file_attributes(_In_ _Requires_lock_held_(_Curr_->tree_lock) device_extension *Vcb, _In_ root *r, _In_ uint64_t inode, _In_ uint8_t type, _In_ bool dotfile, _In_ bool ignore_xa, _In_opt_ PIRP Irp)
Definition: btrfs.c:2600
uint64_t num_children
Definition: btrfs_drv.h:902
PDEVICE_OBJECT pdo
Definition: btrfs_drv.h:898
uint32_t sid_to_uid(PSID sid)
Definition: security.c:310
UNICODE_STRING bus_name
Definition: btrfs_drv.h:887
uint32_t mount_clear_cache
Definition: btrfs.c:88
bool inserted
Definition: btrfs_drv.h:243
#define _Out_writes_bytes_(s)
Definition: no_sal2.h:178
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
root * extent_root
Definition: btrfs_drv.h:806
LIST_ENTRY list_entry
Definition: btrfs_drv.h:422
void do_shutdown(PIRP Irp)
Definition: btrfs.c:5319
uint32_t hash_uc
Definition: btrfs_drv.h:268
ERESOURCE dirty_subvols_lock
Definition: btrfs_drv.h:826
bool ea_changed
Definition: btrfs_drv.h:336
KEY firstitem
Definition: btrfs_drv.h:740
struct _PEB * PPEB
static __inline uint64_t make_file_id(root *r, uint64_t inode)
Definition: btrfs_drv.h:1020
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
fcb * old_cache
Definition: btrfs_drv.h:578
void do_calc_job(device_extension *Vcb, uint8_t *data, uint32_t sectors, void *csum)
Definition: calcthread.c:141
NTSTATUS add_dir_child(fcb *fcb, uint64_t inode, bool subvol, PANSI_STRING utf8, PUNICODE_STRING name, uint8_t type, dir_child **pdc)
Definition: create.c:1861
NTSTATUS pnp_surprise_removal(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: pnp.c:254
void chunk_lock_range(_In_ device_extension *Vcb, _In_ chunk *c, _In_ uint64_t start, _In_ uint64_t length)
Definition: btrfs.c:5747
#define true
Definition: osdep.h:36
struct _device_extension * Vcb
Definition: btrfs_drv.h:446
NTSTATUS update_chunk_caches_tree(device_extension *Vcb, PIRP Irp)
Definition: free-space.c:1917
SECURITY_DESCRIPTOR * sd
Definition: btrfs_drv.h:304
const GUID * guid
enum _PROCESSINFOCLASS PROCESSINFOCLASS
Definition: loader.c:63
PSID sid
Definition: btrfs_drv.h:912
root_nonpaged * nonpaged
Definition: btrfs_drv.h:470
_Ret_maybenull_ root * find_default_subvol(_In_ _Requires_lock_held_(_Curr_->tree_lock) device_extension *Vcb, _In_opt_ PIRP Irp)
Definition: btrfs.c:3940
_In_ ULONG _In_opt_ PVOID _In_ PDRIVER_OBJECT _In_ PDRIVER_NOTIFICATION_CALLBACK_ROUTINE _Inout_opt_ __drv_aliasesMem PVOID _Outptr_result_nullonfailure_ _At_ * NotificationEntry(return==0, __drv_allocatesMem(Mem))) PVOID *NotificationEntry
file_ref * create_fileref(device_extension *Vcb)
Definition: create.c:148
EXTENT_DATA_REF edr
Definition: btrfs_drv.h:622
uint64_t oldused
Definition: btrfs_drv.h:575
void disk_arrival(PDRIVER_OBJECT DriverObject, PUNICODE_STRING devpath)
Definition: search.c:258
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
uint64_t get_extent_flags(device_extension *Vcb, uint64_t address, PIRP Irp)
Definition: extent-tree.c:1835
tree * tree
Definition: btrfs_drv.h:517
uint8_t * scratch
Definition: btrfs_drv.h:949
PVOID Reserved3[2]
Definition: btrfs_drv.h:1957
LIST_ENTRY drop_roots
Definition: btrfs_drv.h:803
chunk * chunk
Definition: btrfs_drv.h:1259
LIST_ENTRY send_ops
Definition: btrfs_drv.h:836
uint8_t gpow2(uint8_t e)
Definition: galois.c:69
ULONG change_count
Definition: btrfs_drv.h:543
_In_ PIRP Irp
Definition: csq.h:116
void space_list_add(chunk *c, uint64_t address, uint64_t length, LIST_ENTRY *rollback)
Definition: free-space.c:1959
uint32_t mount_zlib_level
Definition: btrfs.c:81
uint64_t generation
Definition: btrfs_drv.h:864
LIST_ENTRY items
Definition: btrfs_drv.h:512
NTSTATUS add_space_entry(LIST_ENTRY *list, LIST_ENTRY *list_size, uint64_t offset, uint64_t size)
Definition: free-space.c:190
uint64_t id
Definition: btrfs_drv.h:467
NTSTATUS load_dir_children(_Requires_lock_held_(_Curr_->tree_lock) device_extension *Vcb, fcb *fcb, bool ignore_size, PIRP Irp)
Definition: create.c:503
static __inline bool is_subvol_readonly(root *r, PIRP Irp)
Definition: btrfs_drv.h:1041
ERESOURCE changed_extents_lock
Definition: btrfs_drv.h:587
struct _tree * tree
Definition: btrfs_drv.h:417
LIST_ENTRY list_entry
Definition: btrfs_drv.h:847
#define BTRFS_INODE_COMPRESS
Definition: propsheet.h:87
long LONG
Definition: pedump.c:60
uint64_t address
Definition: btrfs_drv.h:1257
Definition: devices.h:37
ANSI_STRING value
Definition: btrfs_drv.h:1282
LIST_ENTRY list_entry
Definition: btrfs_drv.h:347
void chunk_unlock_range(_In_ device_extension *Vcb, _In_ chunk *c, _In_ uint64_t start, _In_ uint64_t length)
Definition: btrfs.c:5794
uint64_t offset
Definition: btrfs_drv.h:239
ULONG num_errors
Definition: btrfs_drv.h:760
#define e
Definition: ke_i.h:82
NTSTATUS dismount_volume(device_extension *Vcb, bool shutdown, PIRP Irp)
Definition: fsctl.c:2578
#define _Releases_lock_(a)
Definition: btrfs_drv.h:208
BOOLEAN(__stdcall * tCcCopyReadEx)(PFILE_OBJECT FileObject, PLARGE_INTEGER FileOffset, ULONG Length, BOOLEAN Wait, PVOID Buffer, PIO_STATUS_BLOCK IoStatus, PETHREAD IoIssuerThread)
Definition: btrfs_drv.h:1887
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
bool extents_changed
Definition: btrfs_drv.h:334
bool created
Definition: btrfs_drv.h:363
unsigned int uintptr_t
Definition: crtdefs.h:300
#define IRP_MJ_SET_EA
static PVOID ptr
Definition: dispmode.c:27
#define __drv_aliasesMem
Definition: btrfs_drv.h:205
bool seeding
Definition: btrfs_drv.h:869
uint32_t mount_flush_interval
Definition: btrfs.c:83
bool changed
Definition: btrfs_drv.h:593
uint64_t address
Definition: btrfs_drv.h:722
tree_data * paritem
Definition: btrfs_drv.h:448
NTSTATUS(__stdcall * tFsRtlGetEcpListFromIrp)(PIRP Irp, PECP_LIST *EcpList)
Definition: btrfs_drv.h:1905
#define PsGetCurrentProcess
Definition: psfuncs.h:17
bool allocated
Definition: btrfs_drv.h:958
void flush_subvol_fcbs(root *subvol)
Definition: fsctl.c:246
uint32_t count
Definition: btrfs.h:408
bool root_dir
Definition: btrfs_drv.h:272
LIST_ENTRY list_entry_balance
Definition: btrfs_drv.h:602
PFILE_OBJECT root_file
Definition: btrfs_drv.h:837
LIST_ENTRY list_entry
Definition: btrfs_drv.h:566
struct _RTL_USER_PROCESS_PARAMETERS RTL_USER_PROCESS_PARAMETERS
struct pdo_device_extension pdo_device_extension
void init_device(_In_ device_extension *Vcb, _Inout_ device *dev, _In_ bool get_nums)
Definition: btrfs.c:3349
uint64_t count
Definition: btrfs_drv.h:609
unsigned char BOOLEAN
bool specific_file
Definition: btrfs_drv.h:394
bool trim
Definition: btrfs_drv.h:541
LIST_ENTRY ** hash_ptrs_uc
Definition: btrfs_drv.h:329
struct _FSCTL_SET_INTEGRITY_INFORMATION_BUFFER FSCTL_SET_INTEGRITY_INFORMATION_BUFFER
bool allow_degraded
Definition: btrfs_drv.h:691
void mark_fcb_dirty(_In_ fcb *fcb)
Definition: btrfs.c:1625
void mark_fileref_dirty(_In_ file_ref *fileref)
Definition: btrfs.c:1647
root * r
Definition: btrfs_drv.h:511
WDF_INTERRUPT_PRIORITY priority
char ext[3]
Definition: mkdosfs.c:358
PDEVICE_OBJECT devobj
Definition: btrfs_drv.h:865
#define _Out_
Definition: no_sal2.h:160
Definition: parser.c:48
uint32_t mount_no_root_dir
Definition: btrfs.c:91
NTSTATUS vol_file_system_control(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: volume.c:362
HANDLE thread
Definition: btrfs_drv.h:378
struct _tree * parent
Definition: btrfs_drv.h:447
LIST_ENTRY job_list
Definition: btrfs_drv.h:670
bool reloc
Definition: btrfs_drv.h:590
void calc_tree_checksum(device_extension *Vcb, tree_header *th)
Definition: flushthread.c:1799
_IRQL_requires_same_ typedef _In_ ULONG ControlCode
Definition: wmitypes.h:55
NTSTATUS find_item_to_level(device_extension *Vcb, root *r, traverse_ptr *tp, const KEY *searchkey, bool ignore, uint8_t level, PIRP Irp)
Definition: treefuncs.c:569
Definition: bufpool.h:45
#define C_ASSERT(e)
Definition: intsafe.h:71
LARGE_INTEGER finish_time
Definition: btrfs_drv.h:753
NTSTATUS do_write_file(fcb *fcb, uint64_t start_data, uint64_t end_data, void *data, PIRP Irp, bool file_write, uint32_t irp_offset, LIST_ENTRY *rollback)
Definition: write.c:3891
uint8_t type
Definition: btrfs_drv.h:302
struct pdo_device_extension * pdode
Definition: btrfs_drv.h:886
void free_trees(device_extension *Vcb)
Definition: treefuncs.c:794
uint32_t hash
Definition: btrfs_drv.h:443
#define IRP_MJ_DIRECTORY_CONTROL
Definition: rdpdr.c:51
bool parity
Definition: btrfs_drv.h:726
ULONG ea_index
Definition: btrfs_drv.h:401
#define FsRtlAreThereCurrentFileLocks(FL)
Definition: fsrtlfuncs.h:1584
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
NTSTATUS commit_batch_list(_Requires_exclusive_lock_held_(_Curr_->tree_lock) device_extension *Vcb, LIST_ENTRY *batchlist, PIRP Irp)
Definition: treefuncs.c:2281
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
bool prop_compression_changed
Definition: btrfs_drv.h:337
LIST_ENTRY list_entry
Definition: btrfs_drv.h:558
LONG refcount
Definition: btrfs_drv.h:366
#define TYPE_EXTENT_DATA_REF
Definition: btrfs.h:34
bool unique
Definition: btrfs_drv.h:241
void reap_fileref(device_extension *Vcb, file_ref *fr)
Definition: btrfs.c:1806
FILE_LOCK lock
Definition: btrfs_drv.h:305
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
GLuint GLfloat * val
Definition: glext.h:7180
bool marked_as_orphan
Definition: btrfs_drv.h:320
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR OutputBuffer
Definition: wdfiotarget.h:859
_Success_(return) bool get_file_attributes_from_xattr(_In_reads_bytes_(len) char *val
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
typedef bool(CARDLIBPROC *pCanDragProc)(CardRegion &stackobj
void find_gid(struct _fcb *fcb, struct _fcb *parfcb, PSECURITY_SUBJECT_CONTEXT subjcont)
Definition: security.c:924
_In_ uint64_t _In_ uint64_t _In_ uint64_t _In_opt_ traverse_ptr * tp
Definition: btrfs.c:2930
void calc_thread_main(device_extension *Vcb, calc_job *cj)
Definition: calcthread.c:22
uint8_t gmul(uint8_t a, uint8_t b)
Definition: galois.c:73
r l[0]
Definition: byte_order.h:167
#define BTRFS_ROOT_ROOT
Definition: btrfs.h:50
static __inline bool write_fcb_compressed(fcb *fcb)
Definition: btrfs_drv.h:1712
ULONG ealen
Definition: btrfs_drv.h:314
void free_trees_root(device_extension *Vcb, root *r)
Definition: treefuncs.c:757
FSRTL_ADVANCED_FCB_HEADER Header
Definition: btrfs_drv.h:294
#define IRP_MJ_QUERY_EA
uint8_t * data
Definition: btrfs_drv.h:956
FAST_MUTEX
Definition: extypes.h:17
bool deleted
Definition: btrfs_drv.h:362
ERESOURCE dirty_fcbs_lock
Definition: btrfs_drv.h:822
NTSTATUS send_status
Definition: btrfs_drv.h:409
LARGE_INTEGER start_time
Definition: btrfs_drv.h:752
void update_extent_flags(device_extension *Vcb, uint64_t address, uint64_t flags, PIRP Irp)
Definition: extent-tree.c:1876
int64_t LONGLONG
Definition: typedefs.h:68
uint64_t last_alloc
Definition: btrfs_drv.h:595
#define _Requires_lock_not_held_(a)
Definition: btrfs_drv.h:214
#define _Out_opt_
Definition: no_sal2.h:214
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
bool add_thread_job(device_extension *Vcb, PIRP Irp)
LARGE_INTEGER SourceFileOffset
Definition: shellext.h:200
BOOLEAN(__stdcall * tCcCopyWriteEx)(PFILE_OBJECT FileObject, PLARGE_INTEGER FileOffset, ULONG Length, BOOLEAN Wait, PVOID Buffer, PETHREAD IoIssuerThread)
Definition: btrfs_drv.h:1884
LONG send_ops
Definition: btrfs_drv.h:476
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR InputBuffer
Definition: wdfiotarget.h:949
#define TYPE_SHARED_DATA_REF
Definition: btrfs.h:37
int Count
Definition: noreturn.cpp:7
void reap_fcbs(device_extension *Vcb)
Definition: btrfs.c:1771
bool is_unique
Definition: btrfs_drv.h:457
uint64_t metadata_flags
Definition: btrfs_drv.h:800
uint64_t children_loaded
Definition: btrfs_drv.h:903
uint64_t st_size
Definition: btrfs.h:282
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
LIST_ENTRY DirNotifyList
Definition: btrfs_drv.h:796
LIST_ENTRY list_entry
Definition: btrfs_drv.h:1277
bool checked_for_orphans
Definition: btrfs_drv.h:478
LIST_ENTRY dir_children_hash_uc
Definition: btrfs_drv.h:327
LIST_ENTRY list_entry
Definition: btrfs_drv.h:727
calc_thread_type
Definition: btrfs_drv.h:636
GLsizeiptr size
Definition: glext.h:5919
LIST_ENTRY dir_children_index
Definition: btrfs_drv.h:325
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
struct _fcb fcb
Definition: btrfs_drv.h:1357
void clear_batch_list(device_extension *Vcb, LIST_ENTRY *batchlist)
Definition: treefuncs.c:1204
void free_tree(tree *t)
Definition: treefuncs.c:261
#define _Acquires_shared_lock_(a)
Definition: btrfs_drv.h:216
UCHAR flags
Definition: btrfs_drv.h:1283
bool sd_dirty
Definition: btrfs_drv.h:332
NTSTATUS write_data_phys(_In_ PDEVICE_OBJECT device, _In_ PFILE_OBJECT fileobj, _In_ uint64_t address, _In_reads_bytes_(length) void *data, _In_ uint32_t length)
Definition: flushthread.c:65
NTSTATUS vol_query_information(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: volume.c:306
bool fcb_is_inline(fcb *fcb)
Definition: fsctl.c:3240
#define __kernel_entry
Definition: specstrings.h:351
bool find_next_item(_Requires_lock_held_(_Curr_->tree_lock) device_extension *Vcb, const traverse_ptr *tp, traverse_ptr *next_tp, bool ignore, PIRP Irp)
Definition: treefuncs.c:593
r parent
Definition: btrfs.c:2944
NTSYSAPI NTSTATUS NTAPI ZwQueryInformationProcess(_In_ HANDLE ProcessHandle, _In_ PROCESSINFOCLASS ProcessInformationClass, _Out_ PVOID ProcessInformation, _In_ ULONG ProcessInformationLength, _Out_opt_ PULONG ReturnLength)
NTSTATUS status
Definition: btrfs_drv.h:716
uint64_t size
Definition: btrfs_drv.h:607
LIST_ENTRY xattrs
Definition: btrfs_drv.h:319
NTSTATUS vol_shutdown(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: volume.c:899
__wchar_t WCHAR
Definition: xmlstorage.h:180
uint32_t length
Definition: btrfs_drv.h:955
_STLP_VENDOR_CSTD::ldiv_t div(long __x, long __y)
Definition: _cstdlib.h:137
_Function_class_(DRIVER_ADD_DEVICE) NTSTATUS __stdcall AddDevice(PDRIVER_OBJECT DriverObject
static __inline void print_open_trees(device_extension *Vcb)
Definition: btrfs_drv.h:1700
INT WSAAPI shutdown(IN SOCKET s, IN INT how)
Definition: sockctrl.c:506
bool has_new_address
Definition: btrfs_drv.h:454
INT POOL_TYPE
Definition: typedefs.h:78
uint64_t inode
Definition: btrfs_drv.h:300
GLintptr offset
Definition: glext.h:5920
KEVENT finished
Definition: btrfs_drv.h:749
NTSTATUS do_tree_writes(device_extension *Vcb, LIST_ENTRY *tree_writes, bool no_free)
Definition: flushthread.c:1613
LIST_ENTRY itemlist
Definition: btrfs_drv.h:450
uint64_t ULONGLONG
Definition: typedefs.h:67
KEVENT cleared_event
Definition: btrfs_drv.h:381
static __inline uint16_t get_extent_data_len(uint8_t type)
Definition: btrfs_drv.h:1051
KEVENT range_locks_event
Definition: btrfs_drv.h:585
LIST_ENTRY range_locks
Definition: btrfs_drv.h:583
bool user_set_change_time
Definition: btrfs_drv.h:406
#define _Ret_maybenull_
Definition: no_sal2.h:328
PPS_POST_PROCESS_INIT_ROUTINE PostProcessInitRoutine
Definition: btrfs_drv.h:1962
bool had_drive_letter
Definition: btrfs_drv.h:870
BYTE Reserved1[8]
Definition: btrfs_drv.h:1939
struct _file_ref file_ref
#define Vcb
Definition: cdprocs.h:1415
rollback_type
Definition: btrfs_drv.h:1267
static __inline void * map_user_buffer(PIRP Irp, ULONG priority)
Definition: btrfs_drv.h:985
#define S_ISDIR(mode)
Definition: btrfs_drv.h:1810
ULONG CheckSum
Definition: btrfs_drv.h:1932
const GLubyte * c
Definition: glext.h:8905
unsigned int number
Definition: btrfs_drv.h:664
uint64_t root
Definition: btrfs_drv.h:738
UCHAR Identifier[16]
Definition: btrfs_drv.h:164
uint8_t * parity1
Definition: btrfs_drv.h:949
LIST_ENTRY sys_chunks
Definition: btrfs_drv.h:814
_Ret_maybenull_ device * find_device_from_uuid(_In_ device_extension *Vcb, _In_ BTRFS_UUID *uuid)
Definition: btrfs.c:3232
LIST_ENTRY list_entry
Definition: btrfs_drv.h:907
PFILE_OBJECT locked_fileobj
Definition: btrfs_drv.h:786
unsigned short WORD
Definition: ntddk_ex.h:93
static FILE * out
Definition: regtests2xml.c:44
PVOID Reserved6
Definition: btrfs_drv.h:1933
KEVENT event
Definition: btrfs_drv.h:717
NTSTATUS vol_create(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: volume.c:36
void log_device_error(_In_ device_extension *Vcb, _Inout_ device *dev, _In_ int error)
Definition: btrfs.c:5817
__m128i
Definition: emmintrin.h:24
bool removable
Definition: btrfs_drv.h:537
unsigned long DWORD
Definition: ntddk_ex.h:95
NPAGED_LOOKASIDE_LIST fileref_np_lookaside
Definition: btrfs_drv.h:845
#define TYPE_EXTENT_REF_V0
Definition: btrfs.h:35
GLuint address
Definition: glext.h:9393
GLint left
Definition: glext.h:7726
LIST_ENTRY list_entry
Definition: btrfs_drv.h:633
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
LIST_ENTRY hardlinks
Definition: btrfs_drv.h:315
struct _file_ref * fileref
Definition: btrfs_drv.h:316
uint64_t subvol
Definition: btrfs_drv.h:731
uint32_t mount_skip_balance
Definition: btrfs.c:85
LIST_ENTRY list_entry_index
Definition: btrfs_drv.h:273
LIST_ENTRY extents
Definition: btrfs_drv.h:311
bool find_metadata_address_in_chunk(device_extension *Vcb, chunk *c, uint64_t *address)
Definition: flushthread.c:737
bool case_sensitive
Definition: btrfs_drv.h:321
#define __stdcall
Definition: typedefs.h:25
bool chunk_usage_found
Definition: btrfs_drv.h:813
#define _Inout_
Definition: no_sal2.h:162
uint64_t find_extent_shared_tree_refcount(device_extension *Vcb, uint64_t address, uint64_t parent, PIRP Irp)
Definition: extent-tree.c:2119
BOOLEAN(__stdcall * tPsIsDiskCountersEnabled)()
Definition: btrfs_drv.h:1879
NTSTATUS write_compressed(fcb *fcb, uint64_t start_data, uint64_t end_data, void *data, PIRP Irp, LIST_ENTRY *rollback)
Definition: compress.c:877
uint32_t mount_no_barrier
Definition: btrfs.c:86
ERESOURCE fileref_lock
Definition: btrfs_drv.h:353
bool allow_extended_dasd_io
Definition: btrfs_drv.h:396
struct _LDR_DATA_TABLE_ENTRY * PLDR_DATA_TABLE_ENTRY
struct _FSCTL_GET_INTEGRITY_INFORMATION_BUFFER FSCTL_GET_INTEGRITY_INFORMATION_BUFFER
ERESOURCE child_lock
Definition: btrfs_drv.h:904
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
struct _tree_data tree_data
void * notification_entry
Definition: btrfs_drv.h:871
PDEVICE_OBJECT mounted_device
Definition: btrfs_drv.h:884
LARGE_INTEGER duration
Definition: btrfs_drv.h:755
* PFILE_OBJECT
Definition: iotypes.h:1978
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
BYTE Reserved4[8]
Definition: btrfs_drv.h:1929
ULONG disk_num
Definition: btrfs_drv.h:872
struct _ccb * ccb
Definition: btrfs_drv.h:379
USHORT NodeType
Definition: btrfs_drv.h:387
GLbitfield flags
Definition: glext.h:7161
uint64_t total_chunks
Definition: btrfs_drv.h:707
NTSTATUS insert_tree_item(_In_ _Requires_exclusive_lock_held_(_Curr_->tree_lock) device_extension *Vcb, _In_ root *r, _In_ uint64_t obj_id, _In_ uint8_t obj_type, _In_ uint64_t offset, _In_reads_bytes_opt_(size) _When_(return >=0, __drv_aliasesMem) void *data, _In_ uint16_t size, _Out_opt_ traverse_ptr *ptp, _In_opt_ PIRP Irp)
Definition: treefuncs.c:858
BOOLEAN(__stdcall * tFsRtlAreThereCurrentOrInProgressFileLocks)(PFILE_LOCK FileLock)
Definition: btrfs_drv.h:1914
void volume_arrival(PDRIVER_OBJECT DriverObject, PUNICODE_STRING devpath)
Definition: search.c:492
LIST_ENTRY list_entry
Definition: btrfs_drv.h:959
bool stopping
Definition: btrfs_drv.h:750
NTSTATUS create_root(_In_ _Requires_exclusive_lock_held_(_Curr_->tree_lock) device_extension *Vcb, _In_ uint64_t id, _Out_ root **rootptr, _In_ bool no_tree, _In_ uint64_t offset, _In_opt_ PIRP Irp)
Definition: btrfs.c:1199
#define TYPE_SHARED_BLOCK_REF
Definition: btrfs.h:36
uint32_t mount_max_inline
Definition: btrfs.c:84
GLuint GLuint end
Definition: gl.h:1545
uint32_t hash
Definition: btrfs_drv.h:301
LIST_ENTRY list_entry
Definition: btrfs_drv.h:513
LIST_ENTRY trim_list
Definition: btrfs_drv.h:551
uint32_t mount_compress_force
Definition: btrfs.c:79
void __stdcall check_system_root(PDRIVER_OBJECT DriverObject, PVOID Context, ULONG Count)
Definition: boot.c:470
ANSI_STRING name
Definition: btrfs_drv.h:1281
NTSTATUS update_dev_item(device_extension *Vcb, device *device, PIRP Irp)
Definition: flushthread.c:4099
PEPROCESS reserved
Definition: btrfs_drv.h:474
unsigned __int64 ULONG64
Definition: imports.h:198
void add_group_mapping(WCHAR *sidstring, ULONG sidstringlength, uint32_t gid)
Definition: security.c:145
dir_child * dc
Definition: btrfs_drv.h:369
_In_ fcb _In_ chunk _In_ uint64_t _In_ uint64_t _In_ bool _In_opt_ void _In_opt_ PIRP _In_ LIST_ENTRY _In_ uint8_t _In_ uint64_t decoded_size
Definition: btrfs_drv.h:1357
tree_data * item
Definition: btrfs_drv.h:518
PVOID Reserved2[2]
Definition: btrfs_drv.h:1925
unsigned char UCHAR
Definition: xmlstorage.h:181
LONG not_started
Definition: btrfs_drv.h:654
LIST_ENTRY listentry
Definition: btrfs_drv.h:917
LIST_ENTRY children
Definition: btrfs_drv.h:365
NTSTATUS excise_extents(device_extension *Vcb, fcb *fcb, uint64_t start_data, uint64_t end_data, PIRP Irp, LIST_ENTRY *rollback)
Definition: write.c:2384
PFILE_OBJECT fileobj
Definition: btrfs_drv.h:866
struct _fcb_nonpaged fcb_nonpaged
uint32_t count
Definition: btrfs.h:430
UNICODE_STRING ImagePathName
Definition: btrfs_drv.h:1947
NTSTATUS decrease_extent_refcount_tree(device_extension *Vcb, uint64_t address, uint64_t size, uint64_t root, uint8_t level, PIRP Irp)
Definition: extent-tree.c:1560
bool space_changed
Definition: btrfs_drv.h:594
LIST_ENTRY dirty_subvols
Definition: btrfs_drv.h:825
GLenum const GLvoid * addr
Definition: glext.h:9621
tree_header header
Definition: btrfs_drv.h:442
ULONG SessionId
Definition: btrfs_drv.h:1965
PETHREAD thread
Definition: btrfs_drv.h:557
prop_compression_type
Definition: btrfs_drv.h:278
_In_ PECP_LIST _In_opt_ PVOID CurrentEcpContext
Definition: fltkernel.h:2621
LONG refcount
Definition: btrfs_drv.h:296
Definition: parse.h:22
BYTE Reserved1[2]
Definition: btrfs_drv.h:1954
bool recovered
Definition: btrfs_drv.h:724
bool uniqueness_determined
Definition: btrfs_drv.h:458
ULONG num_trim_entries
Definition: btrfs_drv.h:550
bool case_sensitive
Definition: btrfs_drv.h:402
#define NTSTATUS
Definition: precomp.h:20
bool check_tree_checksum(device_extension *Vcb, tree_header *th)
Definition: read.c:128
bool has_open_children(file_ref *fileref)
Definition: fileinfo.c:442
NTSTATUS(__stdcall * tFsRtlValidateReparsePointBuffer)(ULONG BufferLength, PREPARSE_DATA_BUFFER ReparseBuffer)
Definition: btrfs_drv.h:1910
static const WCHAR space[]
Definition: ConsoleCP.c:24
_In_ fcb _In_ chunk _In_ uint64_t _In_ uint64_t _In_ bool _In_opt_ void _In_opt_ PIRP _In_ LIST_ENTRY _In_ uint8_t compression
Definition: btrfs_drv.h:1357
PAGED_LOOKASIDE_LIST fileref_lookaside
Definition: btrfs_drv.h:841
NTSTATUS flush_fcb(fcb *fcb, bool cache, LIST_ENTRY *batchlist, PIRP Irp)
Definition: flushthread.c:4818
_In_ fcb _In_ chunk _In_ uint64_t _In_ uint64_t _In_ bool _In_opt_ void _In_opt_ PIRP _In_ LIST_ENTRY _In_ uint8_t _In_ uint64_t _In_ bool _In_ uint64_t irp_offset
Definition: btrfs_drv.h:1357
#define VOID
Definition: acefi.h:82
LIST_ENTRY changed_extents
Definition: btrfs_drv.h:582
tree_holder treeholder
Definition: btrfs_drv.h:469
uint64_t chunks_left
Definition: btrfs_drv.h:757
LIST_ENTRY all_fcbs
Definition: btrfs_drv.h:820
LIST_ENTRY list_entry_hash_uc
Definition: btrfs_drv.h:275
uint64_t index
Definition: btrfs_drv.h:263
uint8_t * buf
Definition: btrfs_drv.h:935
NTSTATUS lzo_decompress(uint8_t *inbuf, uint32_t inlen, uint8_t *outbuf, uint32_t outlen, uint32_t inpageoff)
Definition: compress.c:278
void add_checksum_entry(device_extension *Vcb, uint64_t address, ULONG length, void *csum, PIRP Irp)
Definition: flushthread.c:2595
LIST_ENTRY list_entry_dirty
Definition: btrfs_drv.h:374
Definition: btrfs_drv.h:1922
GLenum GLsizei len
Definition: glext.h:6722
uint8_t * buf
Definition: btrfs_drv.h:459
NTSTATUS get_tree_new_address(device_extension *Vcb, tree *t, PIRP Irp, LIST_ENTRY *rollback)
Definition: flushthread.c:871
GLdouble s
Definition: gl.h:2039
uint32_t zstd_level
Definition: btrfs_drv.h:683
Definition: _list.h:228
NTSTATUS vol_cleanup(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: volume.c:348
bool created
Definition: btrfs_drv.h:339
uint64_t data_scrubbed
Definition: btrfs_drv.h:758
_In_ PECP_LIST _In_opt_ PVOID _Out_opt_ LPGUID _Outptr_opt_ PVOID _Out_opt_ ULONG * NextEcpContextSize
Definition: fltkernel.h:2621
uint32_t flush_interval
Definition: btrfs_drv.h:684
fcb * fcb
Definition: btrfs_drv.h:357
Definition: typedefs.h:119
UNICODE_STRING CommandLine
Definition: btrfs_drv.h:1948
NTSTATUS increase_extent_refcount_data(device_extension *Vcb, uint64_t address, uint64_t size, uint64_t root, uint64_t inode, uint64_t offset, uint32_t refcount, PIRP Irp)
Definition: extent-tree.c:892
GLenum src
Definition: glext.h:6340
LIST_ENTRY dirty_fcbs
Definition: btrfs_drv.h:821
PVOID Reserved5[52]
Definition: btrfs_drv.h:1961
bool seeding
Definition: btrfs_drv.h:538
uint32_t zlib_level
Definition: btrfs_drv.h:682
#define _Releases_exclusive_lock_(a)
Definition: btrfs_drv.h:209
uint32_t max_inline
Definition: btrfs_drv.h:685
static __inline FAST_IO_POSSIBLE fast_io_possible(fcb *fcb)
Definition: btrfs_drv.h:1690
uint64_t address
Definition: btrfs_drv.h:954
NTSTATUS set_reparse_point(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: reparse.c:367
INODE_ITEM inode_item
Definition: btrfs_drv.h:303
DRIVER_DISPATCH(nfs41_FsdDispatch)
NTSTATUS registry_load_volume_options(device_extension *Vcb)
Definition: registry.c:36
USHORT valuelen
Definition: btrfs_drv.h:288
NTSTATUS get_reparse_point(PDEVICE_OBJECT DeviceObject, PFILE_OBJECT FileObject, void *buffer, DWORD buflen, ULONG_PTR *retlen)
Definition: reparse.c:22
BYTE uint8_t
Definition: msvideo1.c:66
unsigned char BYTE
Definition: xxhash.c:193
NTSTATUS start_balance(device_extension *Vcb, void *data, ULONG length, KPROCESSOR_MODE processor_mode)
Definition: balance.c:3515
uint64_t st_blocks
Definition: btrfs.h:283
uint64_t flags
Definition: btrfs.h:290
LIST_ENTRY partial_stripes
Definition: btrfs_drv.h:597
uint16_t edsize
Definition: write.c:2806
KEVENT flush_thread_finished
Definition: btrfs_drv.h:830
__u8 sector_size[2]
Definition: mkdosfs.c:361
NTSTATUS open_fileref(_Requires_lock_held_(_Curr_->tree_lock) _Requires_exclusive_lock_held_(_Curr_->fcb_lock) _In_ device_extension *Vcb, _Out_ file_ref **pfr, _In_ PUNICODE_STRING fnus, _In_opt_ file_ref *related, _In_ bool parent, _Out_opt_ USHORT *parsed, _Out_opt_ ULONG *fn_offset, _In_ POOL_TYPE pooltype, _In_ bool case_sensitive, _In_opt_ PIRP Irp)
Definition: create.c:1680
LIST_ENTRY space_size
Definition: btrfs_drv.h:580
PDEVICE_OBJECT attached_device
Definition: btrfs_drv.h:888
NTSTATUS delete_fileref(_In_ file_ref *fileref, _In_opt_ PFILE_OBJECT FileObject, _In_ bool make_orphan, _In_opt_ PIRP Irp, _In_ LIST_ENTRY *rollback)
Definition: btrfs.c:2206
INT32 int32_t
Definition: types.h:71
uint32_t get_num_of_processors()
Definition: btrfs.c:4039
uint32_t mount_compress
Definition: btrfs.c:78
NTSTATUS lzo_compress(uint8_t *inbuf, uint32_t inlen, uint8_t *outbuf, uint32_t outlen, unsigned int *space_left)
Definition: compress.c:722
void add_extent(_In_ fcb *fcb, _In_ LIST_ENTRY *prevextle, _In_ __drv_aliasesMem extent *newext)
Definition: write.c:2367
LIST_ENTRY list_entry
Definition: btrfs_drv.h:941
uint16_t filename_length
Definition: btrfs_drv.h:733
NTSTATUS vol_set_information(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: volume.c:312
ERESOURCE dir_children_lock
Definition: btrfs_drv.h:233
NTSTATUS check_csum(device_extension *Vcb, uint8_t *data, uint32_t sectors, void *csum)
Definition: read.c:87
ULONG TimeDateStamp
Definition: btrfs_drv.h:1935
bool user_set_creation_time
Definition: btrfs_drv.h:403
LIST_ENTRY chunks
Definition: btrfs_drv.h:815
NTSTATUS allocate_cache(device_extension *Vcb, bool *changed, PIRP Irp, LIST_ENTRY *rollback)
Definition: free-space.c:1379
NTSTATUS find_item(_In_ _Requires_lock_held_(_Curr_->tree_lock) device_extension *Vcb, _In_ root *r, _Out_ traverse_ptr *tp, _In_ const KEY *searchkey, _In_ bool ignore, _In_opt_ PIRP Irp)
Definition: treefuncs.c:549
NTSTATUS load_cache_chunk(device_extension *Vcb, chunk *c, PIRP Irp)
Definition: free-space.c:980
struct _write_data_context write_data_context
LIST_ENTRY list_entry
Definition: btrfs_drv.h:383
#define _In_
Definition: no_sal2.h:158
file_ref * root_fileref
Definition: btrfs_drv.h:789
struct _ECP_LIST * PECP_LIST
Definition: fsrtltypes.h:139
ULONG balance_num
Definition: btrfs_drv.h:715
bool reloc
Definition: btrfs_drv.h:540
IN PFCB IN PFILE_OBJECT FileObject IN ULONG AllocationSize
Definition: fatprocs.h:319
HANDLE thread
Definition: btrfs_drv.h:746
NTSTATUS send_subvol(device_extension *Vcb, void *data, ULONG datalen, PFILE_OBJECT FileObject, PIRP Irp)
Definition: send.c:3593
#define _Lock_level_order_(a, b)
Definition: btrfs_drv.h:212