ReactOS  0.4.15-dev-5131-g311fcc6
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 #ifdef __REACTOS__
70 C_ASSERT(sizeof(bool) == 1);
71 #endif
72 
73 #ifdef _DEBUG
74 // #define DEBUG_FCB_REFCOUNTS
75 // #define DEBUG_LONG_MESSAGES
76 // #define DEBUG_FLUSH_TIMES
77 // #define DEBUG_CHUNK_LOCKS
78 // #define DEBUG_TRIM_EMULATION
79 #define DEBUG_PARANOID
80 #endif
81 
82 #define UNUSED(x) (void)(x)
83 
84 #define BTRFS_NODE_TYPE_CCB 0x2295
85 #define BTRFS_NODE_TYPE_FCB 0x2296
86 
87 #define ALLOC_TAG 0x7442484D //'MHBt'
88 #define ALLOC_TAG_ZLIB 0x7A42484D //'MHBz'
89 
90 #define UID_NOBODY 65534
91 #define GID_NOBODY 65534
92 
93 #define EA_NTACL "security.NTACL"
94 #define EA_NTACL_HASH 0x45922146
95 
96 #define EA_DOSATTRIB "user.DOSATTRIB"
97 #define EA_DOSATTRIB_HASH 0x914f9939
98 
99 #define EA_REPARSE "user.reparse"
100 #define EA_REPARSE_HASH 0xfabad1fe
101 
102 #define EA_EA "user.EA"
103 #define EA_EA_HASH 0x8270dd43
104 
105 #define EA_CASE_SENSITIVE "user.casesensitive"
106 #define EA_CASE_SENSITIVE_HASH 0x1a9d97d4
107 
108 #define EA_PROP_COMPRESSION "btrfs.compression"
109 #define EA_PROP_COMPRESSION_HASH 0x20ccdf69
110 
111 #define MAX_EXTENT_SIZE 0x8000000 // 128 MB
112 #define COMPRESSED_EXTENT_SIZE 0x20000 // 128 KB
113 
114 #define READ_AHEAD_GRANULARITY COMPRESSED_EXTENT_SIZE // really ought to be a multiple of COMPRESSED_EXTENT_SIZE
115 
116 #ifndef IO_REPARSE_TAG_LX_SYMLINK
117 
118 #define IO_REPARSE_TAG_LX_SYMLINK 0xa000001d
119 
120 #define IO_REPARSE_TAG_AF_UNIX 0x80000023
121 #define IO_REPARSE_TAG_LX_FIFO 0x80000024
122 #define IO_REPARSE_TAG_LX_CHR 0x80000025
123 #define IO_REPARSE_TAG_LX_BLK 0x80000026
124 
125 #endif
126 
127 #define BTRFS_VOLUME_PREFIX L"\\Device\\Btrfs{"
128 
129 #if defined(_MSC_VER) || defined(__clang__)
130 #define try __try
131 #define except __except
132 #define finally __finally
133 #define leave __leave
134 #else
135 #define try if (1)
136 #define except(x) if (0 && (x))
137 #define finally if (1)
138 #define leave
139 #endif
140 
141 #ifndef __REACTOS__
142 #ifndef InterlockedIncrement64
143 #define InterlockedIncrement64(a) __sync_add_and_fetch(a, 1)
144 #endif
145 #endif // __REACTOS__
146 
147 #ifndef FILE_SUPPORTS_BLOCK_REFCOUNTING
148 #define FILE_SUPPORTS_BLOCK_REFCOUNTING 0x08000000
149 #endif
150 
151 #ifndef FILE_SUPPORTS_POSIX_UNLINK_RENAME
152 #define FILE_SUPPORTS_POSIX_UNLINK_RENAME 0x00000400
153 #endif
154 
155 #ifndef FILE_DEVICE_ALLOW_APPCONTAINER_TRAVERSAL
156 #define FILE_DEVICE_ALLOW_APPCONTAINER_TRAVERSAL 0x00020000
157 #endif
158 
159 #ifndef __REACTOS__
160 #ifndef _MSC_VER
161 typedef struct _FILE_ID_128 {
164 
165 #define FILE_CS_FLAG_CASE_SENSITIVE_DIR 1
166 #endif
167 #else
168 typedef struct _FILE_ID_128 {
169  UCHAR Identifier[16];
171 
172 #define FILE_CS_FLAG_CASE_SENSITIVE_DIR 1
173 #endif // __REACTOS__
174 
175 typedef struct _DUPLICATE_EXTENTS_DATA {
181 
182 #define FSCTL_DUPLICATE_EXTENTS_TO_FILE CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 209, METHOD_BUFFERED, FILE_WRITE_ACCESS)
183 
186  WORD Reserved;
187  DWORD Flags;
191 
194  WORD Reserved;
195  DWORD Flags;
197 
198 #define FSCTL_GET_INTEGRITY_INFORMATION CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 159, METHOD_BUFFERED, FILE_ANY_ACCESS)
199 #define FSCTL_SET_INTEGRITY_INFORMATION CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 160, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
200 
201 #ifndef __REACTOS__
202 #ifndef _MSC_VER
203 #define __drv_aliasesMem
204 #define _Dispatch_type_(a)
205 #define _Lock_level_order_(a,b)
206 #endif
207 #endif // __REACTOS__
208 
209 _Create_lock_level_(tree_lock)
210 _Create_lock_level_(fcb_lock)
211 _Lock_level_order_(tree_lock, fcb_lock)
212 
213 #define MAX_HASH_SIZE 32
214 
215 struct _device_extension;
216 
217 typedef struct _fcb_nonpaged {
223 } fcb_nonpaged;
224 
225 struct _root;
226 
227 typedef struct {
230  bool unique;
231  bool ignore;
232  bool inserted;
233  void* csum;
234 
236 
238 } extent;
239 
240 typedef struct {
246 } hardlink;
247 
248 struct _file_ref;
249 
250 typedef struct {
261  bool root_dir;
265 } dir_child;
266 
272 };
273 
274 typedef struct {
278  bool dirty;
279  char data[1];
280 } xattr;
281 
282 typedef struct _fcb {
288  struct _root* subvol;
295  bool deleted;
313 
319 
320  bool dirty;
328  bool created;
329 
330  bool ads;
335 
339 } fcb;
340 
341 typedef struct _file_ref {
347  bool deleted;
348  bool created;
352  struct _file_ref* parent;
354 
355  bool dirty;
356 
359 } file_ref;
360 
361 typedef struct {
363  struct _ccb* ccb;
364  void* context;
368 } send_info;
369 
370 typedef struct _ccb {
381  bool reserving;
391  bool lxss;
394 } ccb;
395 
396 struct _device_extension;
397 
398 typedef struct {
401  struct _tree* tree;
402 } tree_holder;
403 
404 typedef struct _tree_data {
407  bool ignore;
408  bool inserted;
409 
410  union {
412 
413  struct {
416  };
417  };
418 } tree_data;
419 
420 typedef struct {
422 } tree_nonpaged;
423 
424 typedef struct _tree {
431  struct _tree* parent;
433  struct _root* root;
440  bool write;
441  bool is_unique;
444 } tree;
445 
446 typedef struct {
448 } root_nonpaged;
449 
450 typedef struct _root {
452  LONGLONG lastinode; // signed so we can use InterlockedIncrement64
456  bool dirty;
457  bool received;
463  bool dropped;
468 } root;
469 
484 };
485 
486 typedef struct {
488  void* data;
492 } batch_item;
493 
494 typedef struct {
497  unsigned int num_items;
500 
501 typedef struct {
502  root* r;
505 } batch_root;
506 
507 typedef struct {
510 } traverse_ptr;
511 
512 typedef struct _root_cache {
514  struct _root_cache* next;
515 } root_cache;
516 
517 typedef struct {
522 } space;
523 
524 typedef struct {
528  bool removable;
529  bool seeding;
530  bool readonly;
531  bool reloc;
532  bool trim;
533  bool can_flush;
535  ULONG disk_num;
536  ULONG part_num;
537  uint64_t stats[5];
543 } device;
544 
545 typedef struct {
550 } range_lock;
551 
552 typedef struct {
560 
561 typedef struct {
579  bool created;
580  bool readonly;
581  bool reloc;
584  bool changed;
591 
594 } chunk;
595 
596 typedef struct {
602  bool no_csum;
608 
609 typedef struct {
611 
612  union {
615  };
616 
619 
620 typedef struct {
622  void* data;
625 } sys_chunk;
626 
638 };
639 
640 typedef struct {
642  void* in;
643  void* out;
644  unsigned int inlen, outlen, off, space_left;
649 } calc_job;
650 
651 typedef struct {
655  unsigned int number;
656  bool quit;
658 
659 typedef struct {
666 
667 typedef struct {
668  bool ignore;
669  bool compress;
672  bool readonly;
680  bool no_trim;
684  bool nodatacow;
685 } mount_options;
686 
687 #define VCB_TYPE_FS 1
688 #define VCB_TYPE_CONTROL 2
689 #define VCB_TYPE_VOLUME 3
690 #define VCB_TYPE_PDO 4
691 #define VCB_TYPE_BUS 5
692 
693 #define BALANCE_OPTS_DATA 0
694 #define BALANCE_OPTS_METADATA 1
695 #define BALANCE_OPTS_SYSTEM 2
696 
697 typedef struct {
702  bool paused;
703  bool stopping;
704  bool removing;
705  bool shrinking;
711 } balance_info;
712 
713 typedef struct {
716  bool recovered;
718  bool parity;
720 
721  union {
722  struct {
727  } data;
728 
729  struct {
733  } metadata;
734  };
735 } scrub_error;
736 
737 typedef struct {
742  bool stopping;
743  bool paused;
754 } scrub_info;
755 
757 
758 typedef struct _device_extension {
765 #ifdef DEBUG_CHUNK_LOCKS
766  LONG chunk_locks_held;
767 #endif
770  unsigned int sector_shift;
771  unsigned int csum_size;
772  bool readonly;
773  bool removing;
774  bool locked;
778  bool trim;
784  _Has_lock_level_(fcb_lock) ERESOURCE fcb_lock;
787  _Has_lock_level_(tree_lock) ERESOURCE tree_lock;
841 
842 typedef struct {
845 
846 typedef struct {
852 
853 typedef struct {
861  bool seeding;
868 } volume_child;
869 
870 struct pdo_device_extension;
871 
872 typedef struct _volume_device_extension {
881  bool removing;
882  bool dead;
885 
886 typedef struct pdo_device_extension {
891  bool removable;
893 
898 
901 
902 typedef struct {
906 } uid_map;
907 
908 typedef struct {
912 } gid_map;
913 
921 };
922 
923 struct _write_data_context;
924 
925 typedef struct {
935 
936 typedef struct _write_data_context {
940  bool need_wait;
944 
945 typedef struct {
950  bool allocated;
952 } tree_write;
953 
954 typedef struct {
957 } name_bit;
958 
960 _Acquires_shared_lock_(Vcb->fcb_lock)
961 static __inline void acquire_fcb_lock_shared(device_extension* Vcb) {
962  ExAcquireResourceSharedLite(&Vcb->fcb_lock, true);
963 }
964 
965 _Requires_lock_not_held_(Vcb->fcb_lock)
967 static __inline void acquire_fcb_lock_exclusive(device_extension* Vcb) {
968  ExAcquireResourceExclusiveLite(&Vcb->fcb_lock, true);
969 }
970 
972 _Releases_lock_(Vcb->fcb_lock)
973 static __inline void release_fcb_lock(device_extension* Vcb) {
974  ExReleaseResourceLite(&Vcb->fcb_lock);
975 }
976 
977 static __inline void* map_user_buffer(PIRP Irp, ULONG priority) {
978  if (!Irp->MdlAddress) {
979  return Irp->UserBuffer;
980  } else {
981  return MmGetSystemAddressForMdlSafe(Irp->MdlAddress, priority);
982  }
983 }
984 
986  return (t->seconds * 10000000) + (t->nanoseconds / 100) + 116444736000000000;
987 }
988 
989 static __inline void win_time_to_unix(LARGE_INTEGER t, BTRFS_TIME* out) {
990  ULONGLONG l = (ULONGLONG)t.QuadPart - 116444736000000000;
991 
992  out->seconds = l / 10000000;
993  out->nanoseconds = (uint32_t)((l % 10000000) * 100);
994 }
995 
996 _Post_satisfies_(*stripe>=0&&*stripe<num_stripes)
997 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) {
998  uint64_t initoff, startoff;
999 
1000  startoff = off % (num_stripes * stripe_length);
1001  initoff = (off / (num_stripes * stripe_length)) * stripe_length;
1002 
1003  *stripe = (uint16_t)(startoff / stripe_length);
1004  *stripeoff = initoff + startoff - (*stripe * stripe_length);
1005 }
1006 
1007 /* We only have 64 bits for a file ID, which isn't technically enough to be
1008  * unique on Btrfs. We fudge it by having three bytes for the subvol and
1009  * five for the inode, which should be good enough.
1010  * Inodes are also 64 bits on Linux, but the Linux driver seems to get round
1011  * this by tricking it into thinking subvols are separate volumes. */
1013  return (r->id << 40) | (inode & 0xffffffffff);
1014 }
1015 
1016 #define keycmp(key1, key2)\
1017  ((key1.obj_id < key2.obj_id) ? -1 :\
1018  ((key1.obj_id > key2.obj_id) ? 1 :\
1019  ((key1.obj_type < key2.obj_type) ? -1 :\
1020  ((key1.obj_type > key2.obj_type) ? 1 :\
1021  ((key1.offset < key2.offset) ? -1 :\
1022  ((key1.offset > key2.offset) ? 1 :\
1023  0))))))
1024 
1025 _Post_satisfies_(return>=n)
1027  if (n & (a - 1))
1028  n = (n + a) & ~(a - 1);
1029 
1030  return n;
1031 }
1032 
1033 __inline static bool is_subvol_readonly(root* r, PIRP Irp) {
1034  if (!(r->root_item.flags & BTRFS_SUBVOL_READONLY))
1035  return false;
1036 
1037  if (!r->reserved)
1038  return true;
1039 
1040  return (!Irp || Irp->RequestorMode == UserMode) && PsGetCurrentProcess() != r->reserved ? true : false;
1041 }
1042 
1044  switch (type) {
1045  case TYPE_TREE_BLOCK_REF:
1046  return sizeof(TREE_BLOCK_REF);
1047 
1048  case TYPE_EXTENT_DATA_REF:
1049  return sizeof(EXTENT_DATA_REF);
1050 
1051  case TYPE_EXTENT_REF_V0:
1052  return sizeof(EXTENT_REF_V0);
1053 
1054  case TYPE_SHARED_BLOCK_REF:
1055  return sizeof(SHARED_BLOCK_REF);
1056 
1057  case TYPE_SHARED_DATA_REF:
1058  return sizeof(SHARED_DATA_REF);
1059 
1060  default:
1061  return 0;
1062  }
1063 }
1064 
1066  switch (type) {
1067  case TYPE_TREE_BLOCK_REF:
1068  return 1;
1069 
1070  case TYPE_EXTENT_DATA_REF:
1071  {
1073  return edr->count;
1074  }
1075 
1076  case TYPE_EXTENT_REF_V0:
1077  {
1078  EXTENT_REF_V0* erv0 = (EXTENT_REF_V0*)data;
1079  return erv0->count;
1080  }
1081 
1082  case TYPE_SHARED_BLOCK_REF:
1083  return 1;
1084 
1085  case TYPE_SHARED_DATA_REF:
1086  {
1088  return sdr->count;
1089  }
1090 
1091  default:
1092  return 0;
1093  }
1094 }
1095 
1096 // in xor-gas.S
1097 #if defined(_X86_) || defined(_AMD64_)
1098 void __stdcall do_xor_sse2(uint8_t* buf1, uint8_t* buf2, uint32_t len);
1099 void __stdcall do_xor_avx2(uint8_t* buf1, uint8_t* buf2, uint32_t len);
1100 #endif
1101 
1102 // in btrfs.c
1105 
1106 _Success_(return)
1107 bool get_file_attributes_from_xattr(_In_reads_bytes_(len) char* val, _In_ uint16_t len, _Out_ ULONG* atts);
1108 
1110  _In_ uint8_t type, _In_ bool dotfile, _In_ bool ignore_xa, _In_opt_ PIRP Irp);
1111 
1113 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,
1115 
1116 #ifndef DEBUG_FCB_REFCOUNTS
1117 void free_fcb(_Inout_ fcb* fcb);
1118 #endif
1119 void free_fileref(_Inout_ file_ref* fr);
1121 bool is_top_level(_In_ PIRP Irp);
1123  _Out_ root** rootptr, _In_ bool no_tree, _In_ uint64_t offset, _In_opt_ PIRP Irp);
1126  _Out_writes_bytes_opt_(OutputBufferSize) PVOID OutputBuffer, _In_ ULONG OutputBufferSize, _In_ bool Override, _Out_opt_ IO_STATUS_BLOCK* iosb);
1130 
1131 typedef void (__stdcall *xor_func)(uint8_t* buf1, uint8_t* buf2, uint32_t len);
1132 
1133 extern xor_func do_xor;
1134 
1135 #ifdef DEBUG_CHUNK_LOCKS
1136 #define acquire_chunk_lock(c, Vcb) { ExAcquireResourceExclusiveLite(&c->lock, true); InterlockedIncrement(&Vcb->chunk_locks_held); }
1137 #define release_chunk_lock(c, Vcb) { InterlockedDecrement(&Vcb->chunk_locks_held); ExReleaseResourceLite(&c->lock); }
1138 #else
1139 #define acquire_chunk_lock(c, Vcb) ExAcquireResourceExclusiveLite(&(c)->lock, true)
1140 #define release_chunk_lock(c, Vcb) ExReleaseResourceLite(&(c)->lock)
1141 #endif
1142 
1143 void mark_fcb_dirty(_In_ fcb* fcb);
1144 void mark_fileref_dirty(_In_ file_ref* fileref);
1148 void init_device(_In_ device_extension* Vcb, _Inout_ device* dev, _In_ bool get_nums);
1151  _Out_writes_bytes_(Length) PUCHAR Buffer, _In_ bool override);
1155 
1156 _Function_class_(DRIVER_ADD_DEVICE)
1158 
1159 void reap_fcb(fcb* fcb);
1163 NTSTATUS utf8_to_utf16(WCHAR* dest, ULONG dest_max, ULONG* dest_len, char* src, ULONG src_len);
1164 NTSTATUS utf16_to_utf8(char* dest, ULONG dest_max, ULONG* dest_len, WCHAR* src, ULONG src_len);
1166 
1169 
1170 void do_shutdown(PIRP Irp);
1172 
1173 #ifdef _MSC_VER
1174 #define funcname __FUNCTION__
1175 #else
1176 #define funcname __func__
1177 #endif
1178 
1179 extern uint32_t mount_compress;
1182 extern uint32_t mount_zlib_level;
1183 extern uint32_t mount_zstd_level;
1185 extern uint32_t mount_max_inline;
1187 extern uint32_t mount_no_barrier;
1188 extern uint32_t mount_no_trim;
1191 extern uint32_t mount_readonly;
1193 extern uint32_t mount_nodatacow;
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, ...) do { } while(0)
1232 #define WARN(s, ...) do { } while(0)
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) __attribute__((nonnull(1,2,3,4)));
1295 NTSTATUS find_item_to_level(device_extension* Vcb, root* r, traverse_ptr* tp, const KEY* searchkey, bool ignore,
1296  uint8_t level, PIRP Irp) __attribute__((nonnull(1,2,3,4)));
1297 bool find_next_item(_Requires_lock_held_(_Curr_->tree_lock) device_extension* Vcb, const traverse_ptr* tp,
1298  traverse_ptr* next_tp, bool ignore, PIRP Irp) __attribute__((nonnull(1,2,3)));
1299 bool find_prev_item(_Requires_lock_held_(_Curr_->tree_lock) device_extension* Vcb, const traverse_ptr* tp,
1300  traverse_ptr* prev_tp, PIRP Irp) __attribute__((nonnull(1,2,3)));
1301 void free_trees(device_extension* Vcb) __attribute__((nonnull(1)));
1306  _Inout_ traverse_ptr* tp) __attribute__((nonnull(1,2)));
1307 void free_tree(tree* t) __attribute__((nonnull(1)));
1310 void clear_rollback(LIST_ENTRY* rollback) __attribute__((nonnull(1)));
1312 void free_trees_root(device_extension* Vcb, root* r) __attribute__((nonnull(1,2)));
1315  LIST_ENTRY* batchlist, PIRP Irp) __attribute__((nonnull(1,2)));
1316 void clear_batch_list(device_extension* Vcb, LIST_ENTRY* batchlist) __attribute__((nonnull(1,2)));
1317 NTSTATUS skip_to_difference(device_extension* Vcb, traverse_ptr* tp, traverse_ptr* tp2, bool* ended1, bool* ended2) __attribute__((nonnull(1,2,3,4,5)));
1318 
1319 // in search.c
1321 
1322 _Function_class_(KSTART_ROUTINE)
1323 void __stdcall mountmgr_thread(_In_ void* context);
1324 
1325 _Function_class_(DRIVER_NOTIFICATION_CALLBACK_ROUTINE)
1327 
1328 void disk_arrival(PUNICODE_STRING devpath);
1329 bool volume_arrival(PUNICODE_STRING devpath, bool fve_callback);
1330 void volume_removal(PUNICODE_STRING devpath);
1331 
1332 _Function_class_(DRIVER_NOTIFICATION_CALLBACK_ROUTINE)
1334 
1336  _In_ volume_child* vc, _In_ bool skip_dev);
1337 extern KSPIN_LOCK fve_data_lock;
1338 
1339 // in cache.c
1340 void init_cache();
1342 
1343 // in write.c
1344 NTSTATUS write_file(device_extension* Vcb, PIRP Irp, bool wait, bool deferred_write) __attribute__((nonnull(1,2)));
1345 NTSTATUS write_file2(device_extension* Vcb, PIRP Irp, LARGE_INTEGER offset, void* buf, ULONG* length, bool paging_io, bool no_cache,
1346  bool wait, bool deferred_write, bool write_irp, LIST_ENTRY* rollback) __attribute__((nonnull(1,2,4,5,11)));
1351 NTSTATUS alloc_chunk(device_extension* Vcb, uint64_t flags, chunk** pc, bool full_size) __attribute__((nonnull(1,3)));
1353  _In_opt_ PIRP Irp, _In_opt_ chunk* c, _In_ bool file_write, _In_ uint64_t irp_offset, _In_ ULONG priority) __attribute__((nonnull(1,3,5)));
1355  uint64_t irp_offset, ULONG priority) __attribute__((nonnull(1,3)));
1357 
1361 
1366  _In_ bool file_write, _In_ uint64_t irp_offset) __attribute__((nonnull(1,2,3,9)));
1367 
1368 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) __attribute__((nonnull(1, 4)));
1370 void get_raid56_lock_range(chunk* c, uint64_t address, uint64_t length, uint64_t* lockaddr, uint64_t* locklen) __attribute__((nonnull(1,4,5)));
1372  _In_ bool unique, _In_opt_ _When_(return >= 0, __drv_aliasesMem) void* csum, _In_ LIST_ENTRY* rollback) __attribute__((nonnull(1,3,7)));
1373 void add_extent(_In_ fcb* fcb, _In_ LIST_ENTRY* prevextle, _In_ __drv_aliasesMem extent* newext) __attribute__((nonnull(1,2,3)));
1374 
1375 // in dirctrl.c
1376 
1379 NTSTATUS __stdcall drv_directory_control(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp);
1380 
1383 
1384 // in security.c
1385 
1388 NTSTATUS __stdcall drv_query_security(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp);
1389 
1393 
1394 void fcb_get_sd(fcb* fcb, struct _fcb* parent, bool look_for_xattr, PIRP Irp);
1395 void add_user_mapping(WCHAR* sidstring, ULONG sidstringlength, uint32_t uid);
1396 void add_group_mapping(WCHAR* sidstring, ULONG sidstringlength, uint32_t gid);
1399 NTSTATUS fcb_get_new_sd(fcb* fcb, file_ref* parfileref, ACCESS_STATE* as);
1400 void find_gid(struct _fcb* fcb, struct _fcb* parfcb, PSECURITY_SUBJECT_CONTEXT subjcont);
1401 
1402 // in fileinfo.c
1403 
1406 NTSTATUS __stdcall drv_set_information(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp);
1407 
1410 NTSTATUS __stdcall drv_query_information(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp);
1411 
1415 
1419 
1420 bool has_open_children(file_ref* fileref);
1422 NTSTATUS fileref_get_filename(file_ref* fileref, PUNICODE_STRING fn, USHORT* name_offset, ULONG* preqlen);
1427 
1428 // in reparse.c
1433 
1434 // in create.c
1435 
1439 
1441  _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,
1442  _In_ bool case_sensitive, _In_opt_ PIRP Irp);
1444  root* subvol, uint64_t inode, uint8_t type, PANSI_STRING utf8, bool always_add_hl, fcb* parent, fcb** pfcb, POOL_TYPE pooltype, PIRP Irp);
1446 NTSTATUS load_dir_children(_Requires_lock_held_(_Curr_->tree_lock) device_extension* Vcb, fcb* fcb, bool ignore_size, PIRP Irp);
1449  _In_ file_ref* sf, _In_ PUNICODE_STRING name, _In_ bool case_sensitive, _In_ bool lastpart, _In_ bool streampart,
1450  _In_ POOL_TYPE pooltype, _Out_ file_ref** psf2, _In_opt_ PIRP Irp);
1452 NTSTATUS find_file_in_dir(PUNICODE_STRING filename, fcb* fcb, root** subvol, uint64_t* inode, dir_child** pdc, bool case_sensitive);
1453 uint32_t inherit_mode(fcb* parfcb, bool is_dir);
1456 
1457 // in fsctl.c
1461 void flush_subvol_fcbs(root* subvol);
1462 bool fcb_is_inline(fcb* fcb);
1464 
1465 // in flushthread.c
1466 
1467 _Function_class_(KSTART_ROUTINE)
1468 void __stdcall flush_thread(void* context);
1469 
1472 NTSTATUS flush_fcb(fcb* fcb, bool cache, LIST_ENTRY* batchlist, PIRP Irp);
1476 NTSTATUS do_tree_writes(device_extension* Vcb, LIST_ENTRY* tree_writes, bool no_free);
1483 
1484 // in read.c
1485 
1489 
1492  _In_ ULONG priority);
1495 NTSTATUS do_read(PIRP Irp, bool wait, ULONG* bytes_read);
1497 void raid6_recover2(uint8_t* sectors, uint16_t num_stripes, ULONG sector_size, uint16_t missing1, uint16_t missing2, uint8_t* out);
1500 void get_sector_csum(device_extension* Vcb, void* buf, void* csum);
1501 bool check_sector_csum(device_extension* Vcb, void* buf, void* csum);
1502 
1503 // in pnp.c
1504 
1508 
1511 
1512 // in free-space.c
1523 void space_list_merge(LIST_ENTRY* spacelist, LIST_ENTRY* spacelist_size, LIST_ENTRY* deleting);
1525 
1526 // in extent-tree.c
1529  uint32_t refcount, bool superseded, PIRP Irp);
1537  int32_t count, bool no_csum, bool superseded, PIRP Irp);
1544 
1545 // in worker-thread.c
1549 
1550 // in registry.c
1551 void read_registry(PUNICODE_STRING regpath, bool refresh);
1555 void watch_registry(HANDLE regh);
1556 
1557 // in compress.c
1558 NTSTATUS zlib_decompress(uint8_t* inbuf, uint32_t inlen, uint8_t* outbuf, uint32_t outlen);
1559 NTSTATUS lzo_decompress(uint8_t* inbuf, uint32_t inlen, uint8_t* outbuf, uint32_t outlen, uint32_t inpageoff);
1560 NTSTATUS zstd_decompress(uint8_t* inbuf, uint32_t inlen, uint8_t* outbuf, uint32_t outlen);
1562 NTSTATUS zlib_compress(uint8_t* inbuf, uint32_t inlen, uint8_t* outbuf, uint32_t outlen, unsigned int level, unsigned int* space_left);
1563 NTSTATUS lzo_compress(uint8_t* inbuf, uint32_t inlen, uint8_t* outbuf, uint32_t outlen, unsigned int* space_left);
1564 NTSTATUS zstd_compress(uint8_t* inbuf, uint32_t inlen, uint8_t* outbuf, uint32_t outlen, uint32_t level, unsigned int* space_left);
1565 
1566 // in galois.c
1568 void galois_divpower(uint8_t* data, uint8_t div, uint32_t readlen);
1572 
1573 // in devctrl.c
1574 
1577 NTSTATUS __stdcall drv_device_control(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp);
1578 
1579 // in calcthread.c
1580 
1581 _Function_class_(KSTART_ROUTINE)
1582 void __stdcall calc_thread(void* context);
1583 
1586  void* out, unsigned int outlen, unsigned int off, calc_job** pcj);
1587 NTSTATUS add_calc_job_comp(device_extension* Vcb, uint8_t compression, void* in, unsigned int inlen,
1588  void* out, unsigned int outlen, calc_job** pcj);
1590 
1591 // in balance.c
1599 
1600 _Function_class_(KSTART_ROUTINE)
1601 void __stdcall balance_thread(void* context);
1602 
1603 // in volume.c
1609 void add_volume_device(superblock* sb, PUNICODE_STRING devpath, uint64_t length, ULONG disk_num, ULONG part_num);
1611 
1612 _Function_class_(DRIVER_NOTIFICATION_CALLBACK_ROUTINE)
1614 
1616 
1617 // in scrub.c
1623 
1624 // in send.c
1627 
1628 // in fsrtl.c
1630 
1631 // in boot.c
1632 void check_system_root();
1633 void boot_add_device(DEVICE_OBJECT* pdo);
1634 extern BTRFS_UUID boot_uuid;
1635 
1636 // based on function in sys/sysmacros.h
1637 #define makedev(major, minor) (((minor) & 0xFF) | (((major) & 0xFFF) << 8) | (((uint64_t)((minor) & ~0xFF)) << 12) | (((uint64_t)((major) & ~0xFFF)) << 32))
1638 
1639 #ifndef __REACTOS__
1640 // not in mingw yet
1641 #ifndef _MSC_VER
1642 typedef struct {
1648  union {
1651  };
1654 
1655 #define FSRTL_FCB_HEADER_V2 2
1656 
1657 #else
1658 #define FSRTL_ADVANCED_FCB_HEADER_NEW FSRTL_ADVANCED_FCB_HEADER
1659 #endif
1660 #else
1661 typedef struct {
1663  PFAST_MUTEX FastMutex;
1664  LIST_ENTRY FilterContexts;
1665  EX_PUSH_LOCK PushLock;
1667  union {
1668  OPLOCK Oplock;
1669  PVOID ReservedForRemote;
1670  };
1671  PVOID ReservedContext;
1673 
1674 #define FSRTL_FCB_HEADER_V2 2
1675 #endif // __REACTOS__
1676 
1677 static __inline POPLOCK fcb_oplock(fcb* fcb) {
1678  if (fcb->Header.Version >= FSRTL_FCB_HEADER_V2)
1679  return &((FSRTL_ADVANCED_FCB_HEADER_NEW*)&fcb->Header)->Oplock;
1680  else
1681  return &fcb->oplock;
1682 }
1683 
1686  return FastIoIsNotPossible;
1687 
1688  if (!FsRtlAreThereCurrentFileLocks(&fcb->lock) && !fcb->Vcb->readonly)
1689  return FastIoIsPossible;
1690 
1691  return FastIoIsQuestionable;
1692 }
1693 
1694 static __inline void print_open_trees(device_extension* Vcb) {
1695  LIST_ENTRY* le = Vcb->trees.Flink;
1696  while (le != &Vcb->trees) {
1698  tree_data* td = CONTAINING_RECORD(t->itemlist.Flink, tree_data, list_entry);
1699  ERR("tree %p: root %I64x, level %u, first key (%I64x,%x,%I64x)\n",
1700  t, t->root->id, t->header.level, td->key.obj_id, td->key.obj_type, td->key.offset);
1701 
1702  le = le->Flink;
1703  }
1704 }
1705 
1706 static __inline bool write_fcb_compressed(fcb* fcb) {
1708  return false;
1709 
1710  // make sure we don't accidentally write the cache inodes or pagefile compressed
1712  return false;
1713 
1714  if (fcb->Vcb->options.compress_force)
1715  return true;
1716 
1718  return false;
1719 
1720  if (fcb->inode_item.flags & BTRFS_INODE_COMPRESS || fcb->Vcb->options.compress)
1721  return true;
1722 
1723  return false;
1724 }
1725 
1726 #ifdef DEBUG_FCB_REFCOUNTS
1727 #ifdef DEBUG_LONG_MESSAGES
1728 #define increase_fileref_refcount(fileref) {\
1729  LONG rc = InterlockedIncrement(&fileref->refcount);\
1730  MSG(funcname, __FILE__, __LINE__, "fileref %p: refcount now %i\n", 1, fileref, rc);\
1731 }
1732 #else
1733 #define increase_fileref_refcount(fileref) {\
1734  LONG rc = InterlockedIncrement(&fileref->refcount);\
1735  MSG(funcname, "fileref %p: refcount now %i\n", 1, fileref, rc);\
1736 }
1737 #endif
1738 #else
1739 #define increase_fileref_refcount(fileref) InterlockedIncrement(&fileref->refcount)
1740 #endif
1741 
1742 #ifdef _MSC_VER
1743 #define int3 __debugbreak()
1744 #else
1745 #define int3 asm("int3;")
1746 #endif
1747 
1748 #define hex_digit(c) ((c) <= 9) ? ((c) + '0') : ((c) - 10 + 'a')
1749 
1750 // FIXME - find a way to catch unfreed trees again
1751 
1752 // from sys/stat.h
1753 #define __S_IFMT 0170000 /* These bits determine file type. */
1754 #define __S_IFDIR 0040000 /* Directory. */
1755 #define __S_IFCHR 0020000 /* Character device. */
1756 #define __S_IFBLK 0060000 /* Block device. */
1757 #define __S_IFREG 0100000 /* Regular file. */
1758 #define __S_IFIFO 0010000 /* FIFO. */
1759 #define __S_IFLNK 0120000 /* Symbolic link. */
1760 #define __S_IFSOCK 0140000 /* Socket. */
1761 #define __S_ISTYPE(mode, mask) (((mode) & __S_IFMT) == (mask))
1762 
1763 #ifndef S_ISDIR
1764 #define S_ISDIR(mode) __S_ISTYPE((mode), __S_IFDIR)
1765 #endif
1766 
1767 #ifndef S_IRUSR
1768 #define S_IRUSR 0000400
1769 #endif
1770 
1771 #ifndef S_IWUSR
1772 #define S_IWUSR 0000200
1773 #endif
1774 
1775 #ifndef S_IXUSR
1776 #define S_IXUSR 0000100
1777 #endif
1778 
1779 #ifdef __REACTOS__
1780 #define S_IFDIR __S_IFDIR
1781 #define S_IFREG __S_IFREG
1782 #endif /* __REACTOS__ */
1783 
1784 #ifndef S_IRGRP
1785 #define S_IRGRP (S_IRUSR >> 3)
1786 #endif
1787 
1788 #ifndef S_IWGRP
1789 #define S_IWGRP (S_IWUSR >> 3)
1790 #endif
1791 
1792 #ifndef S_IXGRP
1793 #define S_IXGRP (S_IXUSR >> 3)
1794 #endif
1795 
1796 #ifndef S_IROTH
1797 #define S_IROTH (S_IRGRP >> 3)
1798 #endif
1799 
1800 #ifndef S_IWOTH
1801 #define S_IWOTH (S_IWGRP >> 3)
1802 #endif
1803 
1804 #ifndef S_IXOTH
1805 #define S_IXOTH (S_IXGRP >> 3)
1806 #endif
1807 
1808 #ifndef S_ISUID
1809 #define S_ISUID 0004000
1810 #endif
1811 
1812 #ifndef S_ISGID
1813 #define S_ISGID 0002000
1814 #endif
1815 
1816 #ifndef S_ISVTX
1817 #define S_ISVTX 0001000
1818 #endif
1819 
1820 // based on functions in sys/sysmacros.h
1821 #define major(rdev) ((((rdev) >> 8) & 0xFFF) | ((uint32_t)((rdev) >> 32) & ~0xFFF))
1822 #define minor(rdev) (((rdev) & 0xFF) | ((uint32_t)((rdev) >> 12) & ~0xFF))
1823 
1824 static __inline uint64_t fcb_alloc_size(fcb* fcb) {
1825  if (S_ISDIR(fcb->inode_item.st_mode))
1826  return 0;
1827  else if (fcb->atts & FILE_ATTRIBUTE_SPARSE_FILE)
1828  return fcb->inode_item.st_blocks;
1829  else
1830  return sector_align(fcb->inode_item.st_size, fcb->Vcb->superblock.sector_size);
1831 }
1832 
1834 
1836  ULONG ReadOperationCount, ULONG WriteOperationCount, ULONG FlushOperationCount);
1837 
1839  PVOID Buffer, PETHREAD IoIssuerThread);
1840 
1842  PVOID Buffer, PIO_STATUS_BLOCK IoStatus, PETHREAD IoIssuerThread);
1843 
1844 #ifndef CC_ENABLE_DISK_IO_ACCOUNTING
1845 #define CC_ENABLE_DISK_IO_ACCOUNTING 0x00000010
1846 #endif
1847 
1848 #if defined(__REACTOS__) && (NTDDI_VERSION < NTDDI_VISTA)
1849 typedef struct _ECP_LIST ECP_LIST;
1850 typedef struct _ECP_LIST *PECP_LIST;
1851 #endif
1852 
1854 
1856 
1858 
1860 
1863 
1865 
1867 
1869 
1870 #ifndef __REACTOS__
1871 #ifndef _MSC_VER
1873 #endif
1874 
1875 // not in DDK headers - taken from winternl.h
1876 typedef struct _LDR_DATA_TABLE_ENTRY {
1885  union {
1888  };
1891 
1892 typedef struct _PEB_LDR_DATA {
1897 
1904 
1906 
1907 typedef struct _PEB {
1920 } PEB,*PPEB;
1921 #endif /* __REACTOS__ */
1922 
1923 #ifdef _MSC_VER
1927  IN PROCESSINFOCLASS ProcessInformationClass,
1928  OUT PVOID ProcessInformation,
1929  IN ULONG ProcessInformationLength,
1931 );
1932 #endif
uint64_t get_extent_data_ref_hash2(uint64_t root, uint64_t objid, uint64_t offset)
Definition: extent-tree.c:35
VOID(__stdcall * tFsRtlUpdateDiskCounters)(ULONG64 BytesRead, ULONG64 BytesWritten)
Definition: btrfs_drv.h:1855
void add_volume_device(superblock *sb, PUNICODE_STRING devpath, uint64_t length, ULONG disk_num, ULONG part_num)
Definition: volume.c:1077
CACHE_MANAGER_CALLBACKS cache_callbacks
Definition: cache.c:20
LIST_ENTRY * list_size
Definition: btrfs_drv.h:1256
SHARED_DATA_REF sdr
Definition: btrfs_drv.h:614
struct _file_ref * parent
Definition: btrfs_drv.h:352
_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
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) __attribute__((nonnull(1
Definition: cache.c:48
_Must_inspect_result_ _In_ FSRTL_ALLOCATE_ECPLIST_FLAGS _Outptr_ PECP_LIST * EcpList
Definition: fltkernel.h:2510
LIST_ENTRY list_entry
Definition: btrfs_drv.h:491
GLenum func
Definition: glext.h:6028
mount_options options
Definition: btrfs_drv.h:760
void free_fileref(_Inout_ file_ref *fr)
Definition: btrfs.c:1856
_In_ PVOID NotificationStructure
Definition: iofuncs.h:1206
ULONG * bmparr
Definition: btrfs_drv.h:554
uint64_t obj_id
Definition: btrfs.h:144
void galois_double(uint8_t *data, uint32_t len)
Definition: galois.c:109
struct _FILE_ID_128 * PFILE_ID_128
struct _DUPLICATE_EXTENTS_DATA DUPLICATE_EXTENTS_DATA
bool boot_volume
Definition: btrfs_drv.h:866
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:1914
bool check_superblock_checksum(superblock *sb)
Definition: btrfs.c:2825
uint16_t last_stripe
Definition: btrfs_drv.h:587
GLint level
Definition: gl.h:1546
struct _root * root
Definition: btrfs_drv.h:433
#define IN
Definition: typedefs.h:39
PDEVICE_OBJECT buspdo
Definition: btrfs_drv.h:848
_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:428
struct _FSCTL_GET_INTEGRITY_INFORMATION_BUFFER * PFSCTL_GET_INTEGRITY_INFORMATION_BUFFER
uint32_t mount_compress_type
Definition: btrfs.c:74
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:1364
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:859
void reap_fcb(fcb *fcb)
Definition: btrfs.c:1743
LIST_ENTRY trees
Definition: btrfs_drv.h:809
LIST_ENTRY trees_hash
Definition: btrfs_drv.h:810
void trim_whole_device(device *dev)
Definition: fsctl.c:2716
struct _file_ref * fileref
Definition: btrfs_drv.h:260
uint16_t size
Definition: btrfs_drv.h:563
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
_In_ ULONG cj
Definition: winddi.h:3540
root * data_reloc_root
Definition: btrfs_drv.h:803
LIST_ENTRY space
Definition: btrfs_drv.h:539
uint8_t obj_type
Definition: btrfs.h:145
NTSTATUS remove_device(device_extension *Vcb, void *data, ULONG length, KPROCESSOR_MODE processor_mode)
Definition: balance.c:3799
_In_ uint16_t len
Definition: btrfs_drv.h:1107
LIST_ENTRY dirty_filerefs
Definition: btrfs_drv.h:816
PFILE_OBJECT fileobj
Definition: btrfs_drv.h:526
NTSTATUS check_file_name_valid(_In_ PUNICODE_STRING us, _In_ bool posix, _In_ bool stream)
Definition: btrfs.c:5797
bool skip_balance
Definition: btrfs_drv.h:678
scrub_info scrub
Definition: btrfs_drv.h:826
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:833
void init_fast_io_dispatch(FAST_IO_DISPATCH **fiod)
Definition: fastio.c:535
LIST_ENTRY list_entry
Definition: btrfs_drv.h:592
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
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
LIST_ENTRY list_entry
Definition: btrfs_drv.h:1284
chunk * c
Definition: btrfs_drv.h:949
NTSTATUS get_reparse_point(PFILE_OBJECT FileObject, void *buffer, DWORD buflen, ULONG_PTR *retlen)
Definition: reparse.c:27
#define FILE_ATTRIBUTE_SPARSE_FILE
Definition: ntifs_ex.h:380
uint64_t start
Definition: btrfs_drv.h:546
#define _In_opt_
Definition: ms_sal.h:309
LIST_ENTRY list_entry
Definition: btrfs_drv.h:540
uint64_t system_flags
Definition: btrfs_drv.h:794
rwlock_t lock
Definition: tcpcore.h:1163
BTRFS_UUID boot_uuid
Definition: boot.c:33
LIST_ENTRY list_entry
Definition: btrfs_drv.h:606
#define _Inout_
Definition: ms_sal.h:378
#define _Dispatch_type_(a)
Definition: btrfs_drv.h:204
ULONG options
Definition: btrfs_drv.h:374
NTSTATUS fsctl_request(PDEVICE_OBJECT DeviceObject, PIRP *Pirp, uint32_t type)
Definition: fsctl.c:5345
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:4136
PAGED_LOOKASIDE_LIST fcb_lookaside
Definition: btrfs_drv.h:835
#define IRP_MJ_QUERY_SECURITY
_In_ PFCB _In_ LONGLONG StartingOffset
Definition: cdprocs.h:290
void * in
Definition: btrfs_drv.h:642
#define error(str)
Definition: mkdosfs.c:1605
uint32_t adshash
Definition: btrfs_drv.h:331
bool paused
Definition: btrfs_drv.h:743
NTSTATUS(__stdcall * tFsRtlGetNextExtraCreateParameter)(PECP_LIST EcpList, PVOID CurrentEcpContext, LPGUID NextEcpType, PVOID *NextEcpContext, ULONG *NextEcpContextSize)
Definition: btrfs_drv.h:1861
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
struct _root_cache root_cache
#define BTRFS_INODE_NODATACOW
Definition: propsheet.h:77
NPAGED_LOOKASIDE_LIST fcb_np_lookaside
Definition: btrfs_drv.h:838
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:832
static const char lxdev[]
Definition: btrfs_drv.h:1290
NTSTATUS fileref_get_filename(file_ref *fileref, PUNICODE_STRING fn, USHORT *name_offset, ULONG *preqlen)
Definition: fileinfo.c:4245
#define _Out_
Definition: ms_sal.h:345
uint64_t offset
Definition: btrfs_drv.h:724
unsigned int csum_size
Definition: btrfs_drv.h:771
struct _FSCTL_SET_INTEGRITY_INFORMATION_BUFFER * PFSCTL_SET_INTEGRITY_INFORMATION_BUFFER
Definition: http.c:7251
NTSTATUS start_scrub(device_extension *Vcb, KPROCESSOR_MODE processor_mode)
Definition: scrub.c:3260
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
LIST_ENTRY list_entry
Definition: btrfs_drv.h:466
uint32_t count
Definition: btrfs.h:433
UNICODE_STRING name_uc
Definition: btrfs_drv.h:258
bool nodatacow
Definition: btrfs_drv.h:684
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
bool dirty
Definition: btrfs_drv.h:320
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:4261
root * checksum_root
Definition: btrfs_drv.h:800
#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
void space_list_merge(LIST_ENTRY *spacelist, LIST_ENTRY *spacelist_size, LIST_ENTRY *deleting)
Definition: free-space.c:1657
bool inserted
Definition: btrfs_drv.h:408
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:918
tree_nonpaged * nonpaged
Definition: btrfs_drv.h:425
UNICODE_STRING us
Definition: btrfs_drv.h:955
NTSTATUS find_chunk_usage(_In_ _Requires_lock_held_(_Curr_->tree_lock) device_extension *Vcb, _In_opt_ PIRP Irp)
Definition: btrfs.c:3876
NTSTATUS uid_to_sid(uint32_t uid, PSID *sid)
Definition: security.c:229
ULONG size
Definition: btrfs_drv.h:259
_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:617
struct _FILE_ID_128 FILE_ID_128
root * root
Definition: btrfs_drv.h:513
_In_ WDFDPC _In_ BOOLEAN Wait
Definition: wdfdpc.h:167
uint64_t offset
Definition: btrfs_drv.h:564
_In_ fcb _In_ chunk _In_ uint64_t _In_ uint64_t _In_ bool _In_opt_ void _In_opt_ PIRP Irp
Definition: btrfs_drv.h:1364
void fcb_get_sd(fcb *fcb, struct _fcb *parent, bool look_for_xattr, PIRP Irp)
Definition: security.c:511
LIST_ENTRY items_ind
Definition: btrfs_drv.h:503
struct _tree tree
bool reparse_xattr_changed
Definition: btrfs_drv.h:324
GLuint GLuint GLsizei count
Definition: gl.h:1545
NTSTATUS do_write(device_extension *Vcb, PIRP Irp)
Definition: flushthread.c:7877
#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:91
PDEVICE_OBJECT devobj
Definition: btrfs_drv.h:525
uint32_t mount_allow_degraded
Definition: btrfs.c:83
struct _root root
superblock superblock
Definition: btrfs_drv.h:769
NTSTATUS registry_mark_volume_mounted(BTRFS_UUID *uuid)
Definition: registry.c:242
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
PDEVICE_OBJECT device
Definition: btrfs_drv.h:875
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:706
#define FSRTL_FLAG2_IS_PAGING_FILE
Definition: fsrtltypes.h:57
bool can_flush
Definition: btrfs_drv.h:533
void reap_filerefs(device_extension *Vcb, file_ref *fr)
Definition: btrfs.c:1906
LONG NTSTATUS
Definition: precomp.h:26
PAGED_LOOKASIDE_LIST tree_data_lookaside
Definition: btrfs_drv.h:831
batch_operation
Definition: btrfs_drv.h:470
bool sd_deleted
Definition: btrfs_drv.h:321
bool no_barrier
Definition: btrfs_drv.h:679
#define ERR(s,...)
Definition: btrfs_drv.h:1234
tree_holder treeholder
Definition: btrfs_drv.h:411
ERESOURCE fileref_lock
Definition: btrfs_drv.h:785
LIST_ENTRY InMemoryOrderModuleList
Definition: btrfs_drv.h:1895
enum prop_compression_type prop_compression
Definition: btrfs_drv.h:307
uint16_t size
Definition: btrfs_drv.h:414
bool lock_paused_balance
Definition: btrfs_drv.h:775
ANSI_STRING ea_xattr
Definition: btrfs_drv.h:302
static int inbuf
Definition: adnsresfilter.c:73
KEVENT event
Definition: btrfs_drv.h:740
bool dirty
Definition: btrfs_drv.h:456
uint64_t data_flags
Definition: btrfs_drv.h:792
ERESOURCE range_locks_lock
Definition: btrfs_drv.h:575
LIST_ENTRY list_entry_hash
Definition: btrfs_drv.h:436
NTSTATUS update_chunk_caches(device_extension *Vcb, PIRP Irp, LIST_ENTRY *rollback)
Definition: free-space.c:2043
NTSTATUS flush_partial_stripe(device_extension *Vcb, chunk *c, partial_stripe *ps)
Definition: flushthread.c:5958
#define TYPE_TREE_BLOCK_REF
Definition: btrfs.h:37
void init_file_cache(_In_ PFILE_OBJECT FileObject, _In_ CC_FILE_SIZES *ccfs)
Definition: btrfs.c:4069
void free_fcb(_Inout_ fcb *fcb)
Definition: btrfs.c:1734
NTSTATUS read_file(fcb *fcb, uint8_t *data, uint64_t start, uint64_t length, ULONG *pbr, PIRP Irp) __attribute__((nonnull(1
GLdouble n
Definition: glext.h:7729
BYTE Reserved2[1]
Definition: btrfs_drv.h:1910
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:453
ERESOURCE chunk_lock
Definition: btrfs_drv.h:820
bool removing
Definition: btrfs_drv.h:704
PKTHREAD lazy_writer_thread
Definition: btrfs_drv.h:296
ERESOURCE dirty_filerefs_lock
Definition: btrfs_drv.h:817
GLdouble GLdouble t
Definition: gl.h:2047
ERESOURCE load_tree_lock
Definition: btrfs_drv.h:447
void * csum
Definition: btrfs_drv.h:233
bool dev_readonly
Definition: btrfs_drv.h:706
bool xattrs_changed
Definition: btrfs_drv.h:327
LIST_ENTRY list_entry_dirty
Definition: btrfs_drv.h:467
void free_vol(volume_device_extension *vde)
Definition: volume.c:50
Definition: write.c:113
ANSI_STRING utf8
Definition: btrfs_drv.h:254
FT_UInt sid
Definition: cffcmap.c:139
_Acquires_shared_lock_(Vcb->Resource)) FINISHED FatAcquireSharedVcb(IN PIRP_CONTEXT IrpContext
ROOT_ITEM root_item
Definition: btrfs_drv.h:455
LIST_ENTRY list_entry
Definition: btrfs_drv.h:235
ANSI_STRING reparse_xattr
Definition: btrfs_drv.h:301
PDEVICE_OBJECT pdo
Definition: btrfs_drv.h:877
uint64_t used
Definition: btrfs_drv.h:565
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:698
uint8_t compress_type
Definition: btrfs_drv.h:671
LIST_ENTRY errors
Definition: btrfs_drv.h:753
uint64_t address
Definition: btrfs_drv.h:553
uint32_t hash
Definition: btrfs_drv.h:255
GLuint buffer
Definition: glext.h:5915
BYTE BeingDebugged
Definition: btrfs_drv.h:1909
struct _PEB_LDR_DATA * PPEB_LDR_DATA
PNOTIFY_SYNC NotifySync
Definition: btrfs_drv.h:788
uint16_t datalen
Definition: btrfs_drv.h:229
uint32_t mount_readonly
Definition: btrfs.c:84
uint32_t mount_no_trim
Definition: btrfs.c:81
_Requires_lock_not_held_(Vcb->fcb_lock) _Acquires_shared_lock_(Vcb -> fcb_lock) static __inline void acquire_fcb_lock_shared(device_extension *Vcb)
Definition: btrfs_drv.h:959
struct _volume_device_extension * vde
Definition: btrfs_drv.h:763
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:646
ERESOURCE load_lock
Definition: btrfs_drv.h:786
bool readonly
Definition: btrfs_drv.h:530
NTSTATUS stop_scrub(device_extension *Vcb, KPROCESSOR_MODE processor_mode)
Definition: scrub.c:3440
ERESOURCE send_load_lock
Definition: btrfs_drv.h:827
NTSTATUS get_device_pnp_name(_In_ PDEVICE_OBJECT DeviceObject, _Out_ PUNICODE_STRING pnp_name, _Out_ const GUID **guid)
Definition: btrfs.c:4233
bool clear_cache
Definition: btrfs_drv.h:681
uint64_t length
Definition: btrfs_drv.h:547
uint64_t old_size
Definition: btrfs_drv.h:599
bool readonly
Definition: btrfs_drv.h:580
void watch_registry(HANDLE regh)
Definition: registry.c:1036
NTSTATUS find_file_in_dir(PUNICODE_STRING filename, fcb *fcb, root **subvol, uint64_t *inode, dir_child **pdc, bool case_sensitive)
Definition: create.c:182
#define _When_(expr, annos)
Definition: ms_sal.h:254
LONG open_count
Definition: btrfs_drv.h:351
_Acquires_exclusive_lock_(Vcb->Resource)) FINISHED FatAcquireExclusiveVcb_Real(IN PIRP_CONTEXT IrpContext
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:805
RTL_BITMAP bmp
Definition: btrfs_drv.h:556
PRTL_USER_PROCESS_PARAMETERS ProcessParameters
Definition: btrfs_drv.h:1913
LONGLONG lastinode
Definition: btrfs_drv.h:452
ACCESS_MASK access
Definition: btrfs_drv.h:382
LIST_ENTRY fcbs
Definition: btrfs_drv.h:464
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
#define uint16_t
Definition: nsiface.idl:60
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1157
void calc_sha256(uint8_t *hash, const void *input, size_t len)
Definition: sha256.c:126
ULONG part_num
Definition: btrfs_drv.h:865
void * out
Definition: btrfs_drv.h:643
uint32_t flags
Definition: btrfs.h:297
LIST_ENTRY list_entry
Definition: btrfs_drv.h:435
NTSTATUS NTSTATUS 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) __attribute__((nonnull(1
FAST_MUTEX HeaderMutex
Definition: btrfs_drv.h:218
NTSTATUS vol_write(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: volume.c:225
#define _Requires_exclusive_lock_held_(lock)
uint32_t mount_nodatacow
Definition: btrfs.c:86
ERESOURCE paging_resource
Definition: btrfs_drv.h:221
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:322
const char * filename
Definition: ioapi.h:135
#define MmGetSystemAddressForMdlSafe(_Mdl, _Priority)
NTSTATUS utf8_to_utf16(WCHAR *dest, ULONG dest_max, ULONG *dest_len, char *src, ULONG src_len)
Definition: btrfs.c:811
bool check_sector_csum(device_extension *Vcb, void *buf, void *csum)
Definition: read.c:202
LIST_ENTRY old_refs
Definition: btrfs_drv.h:605
PSID sid
Definition: btrfs_drv.h:910
bool updated_extents
Definition: btrfs_drv.h:439
uint32_t debug_log_level
Definition: btrfs.c:71
KSPIN_LOCK fve_data_lock
Definition: search.c:63
NTSTATUS query_balance(device_extension *Vcb, void *data, ULONG length)
Definition: balance.c:3711
uint64_t parent
Definition: btrfs_drv.h:459
device * device
Definition: btrfs_drv.h:929
OPLOCK oplock
Definition: btrfs_drv.h:312
bool manage_volume_privilege
Definition: btrfs_drv.h:379
localAdvHdr FileContextSupportPointer
Definition: fsrtlfuncs.h:1704
uint64_t offset
Definition: btrfs.h:146
LIST_ENTRY list_entry
Definition: btrfs_drv.h:956
_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:997
bool dropped
Definition: btrfs_drv.h:463
uint8_t * data
Definition: btrfs_drv.h:415
LARGE_INTEGER resume_time
Definition: btrfs_drv.h:746
device ** devices
Definition: btrfs_drv.h:567
bool ignore
Definition: btrfs_drv.h:231
NTSTATUS utf16_to_utf8(char *dest, ULONG dest_max, ULONG *dest_len, WCHAR *src, ULONG src_len)
Definition: btrfs.c:894
LIST_ENTRY devices
Definition: btrfs_drv.h:764
NTSTATUS NTSTATUS void free_tree(tree *t) __attribute__((nonnull(1)))
bool has_wildcard
Definition: btrfs_drv.h:377
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
uint64_t fcbs_version
Definition: btrfs_drv.h:461
UNICODE_STRING bus_name
Definition: btrfs_drv.h:850
PAGED_LOOKASIDE_LIST name_bit_lookaside
Definition: btrfs_drv.h:836
struct _DUPLICATE_EXTENTS_DATA * PDUPLICATE_EXTENTS_DATA
balance_info balance
Definition: btrfs_drv.h:825
NTSTATUS stop_balance(device_extension *Vcb, KPROCESSOR_MODE processor_mode)
Definition: balance.c:3784
NTSTATUS error
Definition: btrfs_drv.h:751
SECTION_OBJECT_POINTERS segment_object
Definition: btrfs_drv.h:219
UNICODE_STRING filename
Definition: btrfs_drv.h:384
_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:832
uint64_t chunks_left
Definition: btrfs_drv.h:700
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:1905
bool posix_delete
Definition: btrfs_drv.h:346
#define _Releases_exclusive_lock_(lock)
struct _write_data_context * context
Definition: btrfs_drv.h:926
KTIMER flush_thread_timer
Definition: btrfs_drv.h:822
BTRFS_UUID uuid
Definition: btrfs_drv.h:854
static WCHAR superseded[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1817
LIST_ENTRY list_entry_all
Definition: btrfs_drv.h:337
bool user_set_write_time
Definition: btrfs_drv.h:389
UNICODE_STRING query_string
Definition: btrfs_drv.h:376
uint64_t oldindex
Definition: btrfs_drv.h:344
uint32_t ULONG_PTR
Definition: typedefs.h:65
KEVENT finished
Definition: btrfs_drv.h:710
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:1459
bool is_top_level(_In_ PIRP Irp)
Definition: btrfs.c:278
FxDevice * device
_In_ fcb _In_ chunk _In_ uint64_t start_data
Definition: btrfs_drv.h:1364
#define FSRTL_FCB_HEADER_V2
Definition: btrfs_drv.h:1655
void * data
Definition: btrfs_drv.h:488
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:518
UNICODE_STRING name
Definition: btrfs_drv.h:874
PEPROCESS __stdcall PsGetThreadProcess(_In_ PETHREAD Thread)
PVOID DllBase
Definition: btrfs_drv.h:1880
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:2664
uint64_t num_children
Definition: btrfs_drv.h:894
PDEVICE_OBJECT pdo
Definition: btrfs_drv.h:890
uint32_t sid_to_uid(PSID sid)
Definition: security.c:310
void add_fcb_to_subvol(_In_ _Requires_exclusive_lock_held_(_Curr_->Vcb->fcb_lock) fcb *fcb)
Definition: fileinfo.c:888
UNICODE_STRING bus_name
Definition: btrfs_drv.h:879
uint32_t mount_clear_cache
Definition: btrfs.c:82
bool inserted
Definition: btrfs_drv.h:232
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
root * extent_root
Definition: btrfs_drv.h:799
_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:1364
LIST_ENTRY list_entry
Definition: btrfs_drv.h:406
void do_shutdown(PIRP Irp)
Definition: btrfs.c:5392
uint32_t hash_uc
Definition: btrfs_drv.h:257
ERESOURCE dirty_subvols_lock
Definition: btrfs_drv.h:819
bool ea_changed
Definition: btrfs_drv.h:325
KEY firstitem
Definition: btrfs_drv.h:732
struct _PEB * PPEB
static __inline uint64_t make_file_id(root *r, uint64_t inode)
Definition: btrfs_drv.h:1012
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
fcb * old_cache
Definition: btrfs_drv.h:569
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:1871
NTSTATUS pnp_surprise_removal(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: pnp.c:77
void chunk_lock_range(_In_ device_extension *Vcb, _In_ chunk *c, _In_ uint64_t start, _In_ uint64_t length)
Definition: btrfs.c:5844
struct _device_extension * Vcb
Definition: btrfs_drv.h:430
NTSTATUS update_chunk_caches_tree(device_extension *Vcb, PIRP Irp)
Definition: free-space.c:2113
SECURITY_DESCRIPTOR * sd
Definition: btrfs_drv.h:293
const GUID * guid
enum _PROCESSINFOCLASS PROCESSINFOCLASS
Definition: loader.c:63
PSID sid
Definition: btrfs_drv.h:904
root_nonpaged * nonpaged
Definition: btrfs_drv.h:454
_Ret_maybenull_ root * find_default_subvol(_In_ _Requires_lock_held_(_Curr_->tree_lock) device_extension *Vcb, _In_opt_ PIRP Irp)
Definition: btrfs.c:3981
_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:160
NTSTATUS write_file(device_extension *Vcb, PIRP Irp, bool wait, bool deferred_write) __attribute__((nonnull(1
EXTENT_DATA_REF edr
Definition: btrfs_drv.h:613
uint64_t oldused
Definition: btrfs_drv.h:566
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:508
uint8_t * scratch
Definition: btrfs_drv.h:941
PVOID Reserved3[2]
Definition: btrfs_drv.h:1911
LIST_ENTRY drop_roots
Definition: btrfs_drv.h:796
chunk * chunk
Definition: btrfs_drv.h:1259
LIST_ENTRY send_ops
Definition: btrfs_drv.h:829
uint8_t gpow2(uint8_t e)
Definition: galois.c:69
ULONG change_count
Definition: btrfs_drv.h:534
_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:2146
uint32_t mount_zlib_level
Definition: btrfs.c:75
uint64_t generation
Definition: btrfs_drv.h:856
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:451
NTSTATUS load_dir_children(_Requires_lock_held_(_Curr_->tree_lock) device_extension *Vcb, fcb *fcb, bool ignore_size, PIRP Irp)
Definition: create.c:510
static __inline bool is_subvol_readonly(root *r, PIRP Irp)
Definition: btrfs_drv.h:1033
ERESOURCE changed_extents_lock
Definition: btrfs_drv.h:578
Definition: Header.h:8
struct _tree * tree
Definition: btrfs_drv.h:401
void volume_removal(PUNICODE_STRING devpath)
Definition: search.c:795
LIST_ENTRY list_entry
Definition: btrfs_drv.h:839
NTSTATUS NTSTATUS NTSTATUS do_read(PIRP Irp, bool wait, ULONG *bytes_read)
Definition: read.c:3328
#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:336
void chunk_unlock_range(_In_ device_extension *Vcb, _In_ chunk *c, _In_ uint64_t start, _In_ uint64_t length)
Definition: btrfs.c:5891
uint64_t offset
Definition: btrfs_drv.h:228
ULONG num_errors
Definition: btrfs_drv.h:752
#define e
Definition: ke_i.h:82
void void void NTSTATUS void NTSTATUS skip_to_difference(device_extension *Vcb, traverse_ptr *tp, traverse_ptr *tp2, bool *ended1, bool *ended2) __attribute__((nonnull(1
NTSTATUS dismount_volume(device_extension *Vcb, bool shutdown, PIRP Irp)
Definition: fsctl.c:2584
NTSTATUS NTSTATUS bool bool find_prev_item(_Requires_lock_held_(_Curr_->tree_lock) device_extension *Vcb, const traverse_ptr *tp, traverse_ptr *prev_tp, PIRP Irp) __attribute__((nonnull(1
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:1841
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
bool extents_changed
Definition: btrfs_drv.h:323
NTSTATUS NTSTATUS NTSTATUS truncate_file(fcb *fcb, uint64_t end, PIRP Irp, LIST_ENTRY *rollback) __attribute__((nonnull(1
bool created
Definition: btrfs_drv.h:348
#define IRP_MJ_SET_EA
static PVOID ptr
Definition: dispmode.c:27
_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:1364
#define __drv_aliasesMem
Definition: btrfs_drv.h:203
bool seeding
Definition: btrfs_drv.h:861
uint32_t mount_flush_interval
Definition: btrfs.c:77
bool changed
Definition: btrfs_drv.h:584
uint64_t address
Definition: btrfs_drv.h:714
tree_data * paritem
Definition: btrfs_drv.h:432
NTSTATUS(__stdcall * tFsRtlGetEcpListFromIrp)(PIRP Irp, PECP_LIST *EcpList)
Definition: btrfs_drv.h:1859
#define PsGetCurrentProcess
Definition: psfuncs.h:17
bool allocated
Definition: btrfs_drv.h:950
void flush_subvol_fcbs(root *subvol)
Definition: fsctl.c:243
unsigned int num_items
Definition: btrfs_drv.h:497
uint32_t count
Definition: btrfs.h:420
bool root_dir
Definition: btrfs_drv.h:261
LIST_ENTRY list_entry_balance
Definition: btrfs_drv.h:593
PFILE_OBJECT root_file
Definition: btrfs_drv.h:830
LIST_ENTRY list_entry
Definition: btrfs_drv.h:557
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:3416
uint64_t count
Definition: btrfs_drv.h:600
unsigned char BOOLEAN
bool specific_file
Definition: btrfs_drv.h:378
bool trim
Definition: btrfs_drv.h:532
LIST_ENTRY ** hash_ptrs_uc
Definition: btrfs_drv.h:318
struct _FSCTL_SET_INTEGRITY_INFORMATION_BUFFER FSCTL_SET_INTEGRITY_INFORMATION_BUFFER
bool allow_degraded
Definition: btrfs_drv.h:682
void mark_fcb_dirty(_In_ fcb *fcb)
Definition: btrfs.c:1695
void mark_fileref_dirty(_In_ file_ref *fileref)
Definition: btrfs.c:1717
root * r
Definition: btrfs_drv.h:502
WDF_INTERRUPT_PRIORITY priority
PDEVICE_OBJECT devobj
Definition: btrfs_drv.h:857
#define _In_
Definition: ms_sal.h:308
_Releases_lock_(c->lock)) bool insert_extent_chunk(_In_ device_extension *Vcb
Definition: parser.c:48
uint32_t mount_no_root_dir
Definition: btrfs.c:85
HANDLE thread
Definition: btrfs_drv.h:362
struct _tree * parent
Definition: btrfs_drv.h:431
LIST_ENTRY job_list
Definition: btrfs_drv.h:661
#define _In_z_
Definition: ms_sal.h:313
bool reloc
Definition: btrfs_drv.h:581
void calc_tree_checksum(device_extension *Vcb, tree_header *th)
Definition: flushthread.c:1806
_IRQL_requires_same_ typedef _In_ ULONG ControlCode
Definition: wmitypes.h:55
Definition: bufpool.h:45
#define C_ASSERT(e)
Definition: intsafe.h:73
LARGE_INTEGER finish_time
Definition: btrfs_drv.h:745
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) __attribute__((nonnull(1
NTSTATUS NTSTATUS NTSTATUS NTSTATUS extend_file(fcb *fcb, file_ref *fileref, uint64_t end, bool prealloc, PIRP Irp, LIST_ENTRY *rollback) __attribute__((nonnull(1
uint8_t type
Definition: btrfs_drv.h:291
struct pdo_device_extension * pdode
Definition: btrfs_drv.h:878
uint32_t hash
Definition: btrfs_drv.h:427
#define IRP_MJ_DIRECTORY_CONTROL
Definition: rdpdr.c:51
NTSTATUS alloc_chunk(device_extension *Vcb, uint64_t flags, chunk **pc, bool full_size) __attribute__((nonnull(1
bool parity
Definition: btrfs_drv.h:718
ULONG ea_index
Definition: btrfs_drv.h:385
#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
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:547
bool prop_compression_changed
Definition: btrfs_drv.h:326
LIST_ENTRY list_entry
Definition: btrfs_drv.h:549
LONG refcount
Definition: btrfs_drv.h:350
#define TYPE_EXTENT_DATA_REF
Definition: btrfs.h:38
#define _Out_writes_bytes_opt_(size)
Definition: ms_sal.h:351
bool unique
Definition: btrfs_drv.h:230
void reap_fileref(device_extension *Vcb, file_ref *fr)
Definition: btrfs.c:1875
FILE_LOCK lock
Definition: btrfs_drv.h:294
_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:309
_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
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:2996
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:54
_Requires_lock_held_(Vcb->fcb_lock) _Releases_lock_(Vcb -> fcb_lock) static __inline void release_fcb_lock(device_extension *Vcb)
Definition: btrfs_drv.h:971
static __inline bool write_fcb_compressed(fcb *fcb)
Definition: btrfs_drv.h:1706
ULONG ealen
Definition: btrfs_drv.h:303
FSRTL_ADVANCED_FCB_HEADER Header
Definition: btrfs_drv.h:283
#define IRP_MJ_QUERY_EA
uint8_t * data
Definition: btrfs_drv.h:948
FAST_MUTEX
Definition: extypes.h:17
void void void NTSTATUS void NTSTATUS NTSTATUS remove_drive_letter(PDEVICE_OBJECT mountmgr, PUNICODE_STRING devpath)
Definition: search.c:407
bool deleted
Definition: btrfs_drv.h:347
ERESOURCE dirty_fcbs_lock
Definition: btrfs_drv.h:815
NTSTATUS send_status
Definition: btrfs_drv.h:393
void void void NTSTATUS commit_batch_list(_Requires_exclusive_lock_held_(_Curr_->tree_lock) device_extension *Vcb, LIST_ENTRY *batchlist, PIRP Irp) __attribute__((nonnull(1
LARGE_INTEGER start_time
Definition: btrfs_drv.h:744
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:586
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:1838
LONG send_ops
Definition: btrfs_drv.h:460
_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:41
void reap_fcbs(device_extension *Vcb)
Definition: btrfs.c:1841
bool is_unique
Definition: btrfs_drv.h:441
uint64_t metadata_flags
Definition: btrfs_drv.h:793
uint64_t children_loaded
Definition: btrfs_drv.h:895
uint64_t st_size
Definition: btrfs.h:289
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
LIST_ENTRY DirNotifyList
Definition: btrfs_drv.h:789
LIST_ENTRY list_entry
Definition: btrfs_drv.h:1277
bool checked_for_orphans
Definition: btrfs_drv.h:462
LIST_ENTRY dir_children_hash_uc
Definition: btrfs_drv.h:316
LIST_ENTRY list_entry
Definition: btrfs_drv.h:719
calc_thread_type
Definition: btrfs_drv.h:627
GLsizeiptr size
Definition: glext.h:5919
LIST_ENTRY dir_children_index
Definition: btrfs_drv.h:314
LIST_ENTRY list_entry
Definition: btrfs_drv.h:498
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
struct _fcb fcb
Definition: btrfs_drv.h:1364
#define printf
Definition: freeldr.h:94
UCHAR flags
Definition: btrfs_drv.h:1283
bool sd_dirty
Definition: btrfs_drv.h:321
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:70
bool fcb_is_inline(fcb *fcb)
Definition: fsctl.c:3246
#define __kernel_entry
Definition: specstrings.h:355
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) __attribute__((nonnull(1
r parent
Definition: btrfs.c:3010
void check_system_root()
Definition: boot.c:336
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:708
uint64_t size
Definition: btrfs_drv.h:598
LIST_ENTRY xattrs
Definition: btrfs_drv.h:308
__wchar_t WCHAR
Definition: xmlstorage.h:180
uint32_t length
Definition: btrfs_drv.h:947
_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:1694
xor_func do_xor
Definition: btrfs.c:127
INT WSAAPI shutdown(IN SOCKET s, IN INT how)
Definition: sockctrl.c:506
bool has_new_address
Definition: btrfs_drv.h:438
INT POOL_TYPE
Definition: typedefs.h:78
uint64_t inode
Definition: btrfs_drv.h:289
GLintptr offset
Definition: glext.h:5920
KEVENT finished
Definition: btrfs_drv.h:741
NTSTATUS do_tree_writes(device_extension *Vcb, LIST_ENTRY *tree_writes, bool no_free)
Definition: flushthread.c:1620
LIST_ENTRY itemlist
Definition: btrfs_drv.h:434
uint64_t ULONGLONG
Definition: typedefs.h:67
KEVENT cleared_event
Definition: btrfs_drv.h:365
static __inline uint16_t get_extent_data_len(uint8_t type)
Definition: btrfs_drv.h:1043
KEVENT range_locks_event
Definition: btrfs_drv.h:576
LIST_ENTRY range_locks
Definition: btrfs_drv.h:574
bool user_set_change_time
Definition: btrfs_drv.h:390
PPS_POST_PROCESS_INIT_ROUTINE PostProcessInitRoutine
Definition: btrfs_drv.h:1916
bool had_drive_letter
Definition: btrfs_drv.h:862
BYTE Reserved1[8]
Definition: btrfs_drv.h:1893
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:977
#define S_ISDIR(mode)
Definition: btrfs_drv.h:1764
ULONG CheckSum
Definition: btrfs_drv.h:1886
const GLubyte * c
Definition: glext.h:8905
unsigned int number
Definition: btrfs_drv.h:655
uint64_t root
Definition: btrfs_drv.h:730
UCHAR Identifier[16]
Definition: btrfs_drv.h:162
uint8_t * parity1
Definition: btrfs_drv.h:941
LIST_ENTRY sys_chunks
Definition: btrfs_drv.h:807
NTSTATUS NTSTATUS void clear_rollback(LIST_ENTRY *rollback) __attribute__((nonnull(1)))
_Ret_maybenull_ device * find_device_from_uuid(_In_ device_extension *Vcb, _In_ BTRFS_UUID *uuid)
Definition: btrfs.c:3299
LIST_ENTRY list_entry
Definition: btrfs_drv.h:899
PFILE_OBJECT locked_fileobj
Definition: btrfs_drv.h:779
unsigned short WORD
Definition: ntddk_ex.h:93
static FILE * out
Definition: regtests2xml.c:44
PVOID Reserved6
Definition: btrfs_drv.h:1887
KEVENT event
Definition: btrfs_drv.h:709
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:5914
bool removable
Definition: btrfs_drv.h:528
unsigned long DWORD
Definition: ntddk_ex.h:95
#define TYPE_EXTENT_REF_V0
Definition: btrfs.h:39
GLuint address
Definition: glext.h:9393
GLint left
Definition: glext.h:7726
LIST_ENTRY list_entry
Definition: btrfs_drv.h:624
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2652
LIST_ENTRY hardlinks
Definition: btrfs_drv.h:304
struct _file_ref * fileref
Definition: btrfs_drv.h:305
uint64_t subvol
Definition: btrfs_drv.h:723
uint32_t mount_skip_balance
Definition: btrfs.c:79
LIST_ENTRY list_entry_index
Definition: btrfs_drv.h:262
LIST_ENTRY extents
Definition: btrfs_drv.h:300
bool find_metadata_address_in_chunk(device_extension *Vcb, chunk *c, uint64_t *address)
Definition: flushthread.c:744
bool case_sensitive
Definition: btrfs_drv.h:310
#define __stdcall
Definition: typedefs.h:25
bool chunk_usage_found
Definition: btrfs_drv.h:806
uint64_t find_extent_shared_tree_refcount(device_extension *Vcb, uint64_t address, uint64_t parent, PIRP Irp)
Definition: extent-tree.c:2119
Definition: stddef.h:6
BOOLEAN(__stdcall * tPsIsDiskCountersEnabled)()
Definition: btrfs_drv.h:1833
NTSTATUS write_compressed(fcb *fcb, uint64_t start_data, uint64_t end_data, void *data, PIRP Irp, LIST_ENTRY *rollback)
Definition: compress.c:875
NTSTATUS set_reparse_point(PIRP Irp)
Definition: reparse.c:409
uint32_t mount_no_barrier
Definition: btrfs.c:80
bool allow_extended_dasd_io
Definition: btrfs_drv.h:380
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:896
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:863
PDEVICE_OBJECT mounted_device
Definition: btrfs_drv.h:876
LARGE_INTEGER duration
Definition: btrfs_drv.h:747
* PFILE_OBJECT
Definition: iotypes.h:1998
void(__stdcall * xor_func)(uint8_t *buf1, uint8_t *buf2, uint32_t len)
Definition: btrfs_drv.h:1131
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
BYTE Reserved4[8]
Definition: btrfs_drv.h:1883
ULONG disk_num
Definition: btrfs_drv.h:864
struct _ccb * ccb
Definition: btrfs_drv.h:363
USHORT NodeType
Definition: btrfs_drv.h:371
NTSTATUS delete_reparse_point(PIRP Irp)
Definition: reparse.c:482
GLbitfield flags
Definition: glext.h:7161
uint64_t total_chunks
Definition: btrfs_drv.h:699
BOOLEAN(__stdcall * tFsRtlAreThereCurrentOrInProgressFileLocks)(PFILE_LOCK FileLock)
Definition: btrfs_drv.h:1868
#define _Ret_maybenull_
Definition: ms_sal.h:529
LIST_ENTRY list_entry
Definition: btrfs_drv.h:951
bool stopping
Definition: btrfs_drv.h:742
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:1271
#define TYPE_SHARED_BLOCK_REF
Definition: btrfs.h:40
uint32_t mount_max_inline
Definition: btrfs.c:78
GLuint GLuint end
Definition: gl.h:1545
uint32_t hash
Definition: btrfs_drv.h:290
LIST_ENTRY list_entry
Definition: btrfs_drv.h:504
LIST_ENTRY trim_list
Definition: btrfs_drv.h:542
uint32_t mount_compress_force
Definition: btrfs.c:73
ANSI_STRING name
Definition: btrfs_drv.h:1281
NTSTATUS update_dev_item(device_extension *Vcb, device *device, PIRP Irp)
Definition: flushthread.c:4093
PEPROCESS reserved
Definition: btrfs_drv.h:458
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:353
tree_data * item
Definition: btrfs_drv.h:509
PVOID Reserved2[2]
Definition: btrfs_drv.h:1879
unsigned char UCHAR
Definition: xmlstorage.h:181
LONG not_started
Definition: btrfs_drv.h:645
LIST_ENTRY listentry
Definition: btrfs_drv.h:909
LIST_ENTRY children
Definition: btrfs_drv.h:349
NTSTATUS bool void NTSTATUS add_extent_to_fcb(_In_ fcb *fcb, _In_ uint64_t offset, _In_reads_bytes_(edsize) EXTENT_DATA *ed, _In_ uint16_t edsize, _In_ bool unique, _In_opt_ _When_(return >=0, __drv_aliasesMem) void *csum, _In_ LIST_ENTRY *rollback) __attribute__((nonnull(1
PFILE_OBJECT fileobj
Definition: btrfs_drv.h:858
NTSTATUS NTSTATUS find_item_to_level(device_extension *Vcb, root *r, traverse_ptr *tp, const KEY *searchkey, bool ignore, uint8_t level, PIRP Irp) __attribute__((nonnull(1
struct _fcb_nonpaged fcb_nonpaged
uint32_t count
Definition: btrfs.h:442
void disk_arrival(PUNICODE_STRING devpath)
Definition: search.c:460
UNICODE_STRING ImagePathName
Definition: btrfs_drv.h:1901
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:585
LIST_ENTRY dirty_subvols
Definition: btrfs_drv.h:818
NTSTATUS NTSTATUS do_load_tree(device_extension *Vcb, tree_holder *th, root *r, tree *t, tree_data *td, PIRP Irp) __attribute__((nonnull(1
GLenum const GLvoid * addr
Definition: glext.h:9621
tree_header header
Definition: btrfs_drv.h:426
ULONG SessionId
Definition: btrfs_drv.h:1919
PETHREAD thread
Definition: btrfs_drv.h:548
prop_compression_type
Definition: btrfs_drv.h:267
_In_ PECP_LIST _In_opt_ PVOID CurrentEcpContext
Definition: fltkernel.h:2620
LONG refcount
Definition: btrfs_drv.h:285
Definition: parse.h:22
BYTE Reserved1[2]
Definition: btrfs_drv.h:1908
bool recovered
Definition: btrfs_drv.h:716
bool uniqueness_determined
Definition: btrfs_drv.h:442
ULONG num_trim_entries
Definition: btrfs_drv.h:541
bool case_sensitive
Definition: btrfs_drv.h:386
#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:1864
static const WCHAR space[]
Definition: ConsoleCP.c:24
PAGED_LOOKASIDE_LIST fileref_lookaside
Definition: btrfs_drv.h:834
NTSTATUS flush_fcb(fcb *fcb, bool cache, LIST_ENTRY *batchlist, PIRP Irp)
Definition: flushthread.c:4924
#define VOID
Definition: acefi.h:82
LIST_ENTRY changed_extents
Definition: btrfs_drv.h:573
tree_holder treeholder
Definition: btrfs_drv.h:453
uint64_t chunks_left
Definition: btrfs_drv.h:749
LIST_ENTRY all_fcbs
Definition: btrfs_drv.h:813
LIST_ENTRY list_entry_hash_uc
Definition: btrfs_drv.h:264
uint64_t index
Definition: btrfs_drv.h:252
uint8_t * buf
Definition: btrfs_drv.h:927
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:2602
LIST_ENTRY list_entry_dirty
Definition: btrfs_drv.h:358
Definition: btrfs_drv.h:1876
GLenum GLsizei len
Definition: glext.h:6722
uint8_t * buf
Definition: btrfs_drv.h:443
NTSTATUS get_tree_new_address(device_extension *Vcb, tree *t, PIRP Irp, LIST_ENTRY *rollback)
Definition: flushthread.c:878
GLdouble s
Definition: gl.h:2039
uint32_t zstd_level
Definition: btrfs_drv.h:674
Definition: _list.h:228
bool created
Definition: btrfs_drv.h:328
uint64_t data_scrubbed
Definition: btrfs_drv.h:750
_In_ PECP_LIST _In_opt_ PVOID _Out_opt_ LPGUID _Outptr_opt_ PVOID _Out_opt_ ULONG * NextEcpContextSize
Definition: fltkernel.h:2620
uint32_t flush_interval
Definition: btrfs_drv.h:675
fcb * fcb
Definition: btrfs_drv.h:342
Definition: typedefs.h:119
UNICODE_STRING CommandLine
Definition: btrfs_drv.h:1902
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:814
PVOID Reserved5[52]
Definition: btrfs_drv.h:1915
bool seeding
Definition: btrfs_drv.h:529
void do_rollback(device_extension *Vcb, LIST_ENTRY *rollback) __attribute__((nonnull(1
uint32_t zlib_level
Definition: btrfs_drv.h:673
uint32_t max_inline
Definition: btrfs_drv.h:676
static __inline FAST_IO_POSSIBLE fast_io_possible(fcb *fcb)
Definition: btrfs_drv.h:1684
uint64_t address
Definition: btrfs_drv.h:946
INODE_ITEM inode_item
Definition: btrfs_drv.h:292
DRIVER_DISPATCH(nfs41_FsdDispatch)
NTSTATUS registry_load_volume_options(device_extension *Vcb)
Definition: registry.c:36
USHORT valuelen
Definition: btrfs_drv.h:277
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:3511
uint64_t st_blocks
Definition: btrfs.h:290
NTSTATUS NTSTATUS 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) __attribute__((nonnull(1
LIST_ENTRY partial_stripes
Definition: btrfs_drv.h:588
KEVENT flush_thread_finished
Definition: btrfs_drv.h:823
__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:1690
LIST_ENTRY space_size
Definition: btrfs_drv.h:571
PDEVICE_OBJECT attached_device
Definition: btrfs_drv.h:880
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:2270
unsigned int sector_shift
Definition: btrfs_drv.h:770
INT32 int32_t
Definition: types.h:71
NTSTATUS NTSTATUS NTSTATUS void free_write_data_stripes(write_data_context *wtc) __attribute__((nonnull(1)))
uint32_t get_num_of_processors()
Definition: btrfs.c:4080
uint32_t mount_compress
Definition: btrfs.c:72
NTSTATUS lzo_compress(uint8_t *inbuf, uint32_t inlen, uint8_t *outbuf, uint32_t outlen, unsigned int *space_left)
Definition: compress.c:727
LIST_ENTRY list_entry
Definition: btrfs_drv.h:933
uint16_t filename_length
Definition: btrfs_drv.h:725
ERESOURCE dir_children_lock
Definition: btrfs_drv.h:222
NTSTATUS check_csum(device_extension *Vcb, uint8_t *data, uint32_t sectors, void *csum)
Definition: read.c:87
ULONG TimeDateStamp
Definition: btrfs_drv.h:1889
NTSTATUS NTSTATUS bool bool void free_trees(device_extension *Vcb) __attribute__((nonnull(1)))
bool user_set_creation_time
Definition: btrfs_drv.h:387
LIST_ENTRY chunks
Definition: btrfs_drv.h:808
NTSTATUS allocate_cache(device_extension *Vcb, bool *changed, PIRP Irp, LIST_ENTRY *rollback)
Definition: free-space.c:1382
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:367
file_ref * root_fileref
Definition: btrfs_drv.h:782
struct _ECP_LIST * PECP_LIST
Definition: fsrtltypes.h:139
ULONG balance_num
Definition: btrfs_drv.h:707
bool reloc
Definition: btrfs_drv.h:531
IN PFCB IN PFILE_OBJECT FileObject IN ULONG AllocationSize
Definition: fatprocs.h:319
HANDLE thread
Definition: btrfs_drv.h:738
NTSTATUS send_subvol(device_extension *Vcb, void *data, ULONG datalen, PFILE_OBJECT FileObject, PIRP Irp)
Definition: send.c:3593
operation
Definition: copy.c:29
#define _Lock_level_order_(a, b)
Definition: btrfs_drv.h:205
void uninit(_In_ device_extension *Vcb)
Definition: btrfs.c:2001
bool ignore
Definition: btrfs_drv.h:407
uint32_t size
Definition: btrfs_drv.h:429
extent * ext
Definition: btrfs_drv.h:1264
Definition: btrfs.h:143
ULONG get_reparse_tag_fcb(fcb *fcb)
Definition: dirctrl.c:83
void void void add_rollback(_In_ LIST_ENTRY *rollback, _In_ enum rollback_type type, _In_ __drv_aliasesMem void *ptr) __attribute__((nonnull(1
void get_tree_checksum(device_extension *Vcb, tree_header *th, void *csum)
Definition: read.c:108
uint64_t size
Definition: btrfs_drv.h:519
NTSTATUS NTSTATUS NTSTATUS NTSTATUS NTSTATUS excise_extents(device_extension *Vcb, fcb *fcb, uint64_t start_data, uint64_t end_data, PIRP Irp, LIST_ENTRY *rollback) __attribute__((nonnull(1
NTSTATUS Status
Definition: btrfs_drv.h:648
PDEVICE_OBJECT attached_device
Definition: btrfs_drv.h:849
bool volume_arrival(PUNICODE_STRING devpath, bool fve_callback)
Definition: search.c:693
bool stats_changed
Definition: btrfs_drv.h:538
uint64_t total_chunks
Definition: btrfs_drv.h:748
NTSTATUS(__stdcall * tIoUnregisterPlugPlayNotificationEx)(PVOID NotificationEntry)
Definition: btrfs_drv.h:1857
void init_cache()
Definition: cache.c:85
* PFAST_MUTEX
Definition: extypes.h:17
bool created
Definition: btrfs_drv.h:579
_Create_lock_level_(tree_lock) _Create_lock_level_(fcb_lock) _Lock_level_order_(tree_lock
NTSTATUS zlib_decompress(uint8_t *inbuf, uint32_t inlen, uint8_t *outbuf, uint32_t outlen)
Definition: compress.c:377
uint32_t gid
Definition: btrfs_drv.h:911
NTSTATUS load_tree(device_extension *Vcb, uint64_t addr, uint8_t *buf, root *r, tree **pt) __attribute__((nonnull(1
static __inline uint64_t unix_time_to_win(BTRFS_TIME *t)
Definition: btrfs_drv.h:985
UINT64 uint64_t
Definition: types.h:77
NTSTATUS vol_device_control(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: volume.c:755
uint8_t level
Definition: btrfs_drv.h:731
const WCHAR * action
Definition: action.c:7479
NTSTATUS load_stored_free_space_cache(device_extension *Vcb, chunk *c, bool load_only, PIRP Irp)
Definition: free-space.c:466
GLenum GLenum GLenum input
Definition: glext.h:9031
LIST_ENTRY list_entry_hash
Definition: btrfs_drv.h:263
ULONG atts
Definition: btrfs_drv.h:297
FSRTL_COMMON_FCB_HEADER Header
Definition: btrfs_drv.h:1643
NTSTATUS query_scrub(device_extension *Vcb, KPROCESSOR_MODE processor_mode, void *data, ULONG length)
Definition: scrub.c:3301
ERESOURCE resource
Definition: btrfs_drv.h:220
void space_list_subtract(chunk *c, uint64_t address, uint64_t length, LIST_ENTRY *rollback)
Definition: free-space.c:2234
GLuint in
Definition: glext.h:9616
NTSTATUS NTSTATUS write_file2(device_extension *Vcb, PIRP Irp, LARGE_INTEGER offset, void *buf, ULONG *length, bool paging_io, bool no_cache, bool wait, bool deferred_write, bool write_irp, LIST_ENTRY *rollback) __attribute__((nonnull(1
struct _fcb_nonpaged * nonpaged
Definition: btrfs_drv.h:284
struct LOOKASIDE_ALIGN _PAGED_LOOKASIDE_LIST PAGED_LOOKASIDE_LIST
void boot_add_device(DEVICE_OBJECT *pdo)
Definition: boot.c:318
void remove_fcb_from_subvol(_In_ _Requires_exclusive_lock_held_(_Curr_->Vcb->fcb_lock) fcb *fcb)
Definition: fileinfo.c:937
LIST_ENTRY roots
Definition: btrfs_drv.h:795
drv_calc_threads calcthreads
Definition: btrfs_drv.h:824
void * context
Definition: btrfs_drv.h:364
BOOLEAN(__stdcall * tFsRtlCheckLockForOplockRequest)(PFILE_LOCK FileLock, PLARGE_INTEGER AllocationSize)
Definition: btrfs_drv.h:1866
unsigned short USHORT
Definition: pedump.c:61
ERESOURCE stats_lock
Definition: btrfs_drv.h:739
bool deleted
Definition: btrfs_drv.h:295
void space_list_subtract2(LIST_ENTRY *list, LIST_ENTRY *list_size, uint64_t address, uint64_t length, chunk *c, LIST_ENTRY *rollback)
Definition: free-space.c:2155
GLuint start
Definition: gl.h:1545
uint32_t inherit_mode(fcb *parfcb, bool is_dir)
Definition: create.c:1948
uint8_t type
Definition: btrfs_drv.h:253
static const char lxgid[]
Definition: btrfs_drv.h:1288
PDEVICE_OBJECT devobj
Definition: btrfs_drv.h:762
LIST_ENTRY InMemoryOrderLinks
Definition: btrfs_drv.h:1878
ULONG disposition
Definition: btrfs_drv.h:373
NTSTATUS NTSTATUS delete_tree_item(_In_ _Requires_exclusive_lock_held_(_Curr_->tree_lock) device_extension *Vcb, _Inout_ traverse_ptr *tp) __attribute__((nonnull(1