ReactOS  0.4.15-dev-4853-g3a72a52
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 {
495  root* r;
498 } batch_root;
499 
500 typedef struct {
503 } traverse_ptr;
504 
505 typedef struct _root_cache {
507  struct _root_cache* next;
508 } root_cache;
509 
510 typedef struct {
515 } space;
516 
517 typedef struct {
521  bool removable;
522  bool seeding;
523  bool readonly;
524  bool reloc;
525  bool trim;
526  bool can_flush;
528  ULONG disk_num;
529  ULONG part_num;
530  uint64_t stats[5];
536 } device;
537 
538 typedef struct {
543 } range_lock;
544 
545 typedef struct {
553 
554 typedef struct {
572  bool created;
573  bool readonly;
574  bool reloc;
577  bool changed;
584 
587 } chunk;
588 
589 typedef struct {
595  bool no_csum;
601 
602 typedef struct {
604 
605  union {
608  };
609 
612 
613 typedef struct {
615  void* data;
618 } sys_chunk;
619 
631 };
632 
633 typedef struct {
635  void* in;
636  void* out;
637  unsigned int inlen, outlen, off, space_left;
642 } calc_job;
643 
644 typedef struct {
648  unsigned int number;
649  bool quit;
651 
652 typedef struct {
659 
660 typedef struct {
661  bool ignore;
662  bool compress;
665  bool readonly;
673  bool no_trim;
677 } mount_options;
678 
679 #define VCB_TYPE_FS 1
680 #define VCB_TYPE_CONTROL 2
681 #define VCB_TYPE_VOLUME 3
682 #define VCB_TYPE_PDO 4
683 #define VCB_TYPE_BUS 5
684 
685 #define BALANCE_OPTS_DATA 0
686 #define BALANCE_OPTS_METADATA 1
687 #define BALANCE_OPTS_SYSTEM 2
688 
689 typedef struct {
694  bool paused;
695  bool stopping;
696  bool removing;
697  bool shrinking;
703 } balance_info;
704 
705 typedef struct {
708  bool recovered;
710  bool parity;
712 
713  union {
714  struct {
719  } data;
720 
721  struct {
725  } metadata;
726  };
727 } scrub_error;
728 
729 typedef struct {
734  bool stopping;
735  bool paused;
746 } scrub_info;
747 
749 
750 typedef struct _device_extension {
757 #ifdef DEBUG_CHUNK_LOCKS
758  LONG chunk_locks_held;
759 #endif
762  unsigned int sector_shift;
763  unsigned int csum_size;
764  bool readonly;
765  bool removing;
766  bool locked;
770  bool trim;
776  _Has_lock_level_(fcb_lock) ERESOURCE fcb_lock;
779  _Has_lock_level_(tree_lock) ERESOURCE tree_lock;
833 
834 typedef struct {
837 
838 typedef struct {
844 
845 typedef struct {
853  bool seeding;
860 } volume_child;
861 
862 struct pdo_device_extension;
863 
864 typedef struct _volume_device_extension {
873  bool removing;
874  bool dead;
877 
878 typedef struct pdo_device_extension {
883  bool removable;
885 
890 
893 
894 typedef struct {
898 } uid_map;
899 
900 typedef struct {
904 } gid_map;
905 
913 };
914 
915 struct _write_data_context;
916 
917 typedef struct {
927 
928 typedef struct _write_data_context {
932  bool need_wait;
936 
937 typedef struct {
942  bool allocated;
944 } tree_write;
945 
946 typedef struct {
949 } name_bit;
950 
952 _Acquires_shared_lock_(Vcb->fcb_lock)
953 static __inline void acquire_fcb_lock_shared(device_extension* Vcb) {
954  ExAcquireResourceSharedLite(&Vcb->fcb_lock, true);
955 }
956 
957 _Requires_lock_not_held_(Vcb->fcb_lock)
959 static __inline void acquire_fcb_lock_exclusive(device_extension* Vcb) {
960  ExAcquireResourceExclusiveLite(&Vcb->fcb_lock, true);
961 }
962 
964 _Releases_lock_(Vcb->fcb_lock)
965 static __inline void release_fcb_lock(device_extension* Vcb) {
966  ExReleaseResourceLite(&Vcb->fcb_lock);
967 }
968 
969 static __inline void* map_user_buffer(PIRP Irp, ULONG priority) {
970  if (!Irp->MdlAddress) {
971  return Irp->UserBuffer;
972  } else {
973  return MmGetSystemAddressForMdlSafe(Irp->MdlAddress, priority);
974  }
975 }
976 
978  return (t->seconds * 10000000) + (t->nanoseconds / 100) + 116444736000000000;
979 }
980 
981 static __inline void win_time_to_unix(LARGE_INTEGER t, BTRFS_TIME* out) {
982  ULONGLONG l = (ULONGLONG)t.QuadPart - 116444736000000000;
983 
984  out->seconds = l / 10000000;
985  out->nanoseconds = (uint32_t)((l % 10000000) * 100);
986 }
987 
988 _Post_satisfies_(*stripe>=0&&*stripe<num_stripes)
989 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) {
990  uint64_t initoff, startoff;
991 
992  startoff = off % (num_stripes * stripe_length);
993  initoff = (off / (num_stripes * stripe_length)) * stripe_length;
994 
995  *stripe = (uint16_t)(startoff / stripe_length);
996  *stripeoff = initoff + startoff - (*stripe * stripe_length);
997 }
998 
999 /* We only have 64 bits for a file ID, which isn't technically enough to be
1000  * unique on Btrfs. We fudge it by having three bytes for the subvol and
1001  * five for the inode, which should be good enough.
1002  * Inodes are also 64 bits on Linux, but the Linux driver seems to get round
1003  * this by tricking it into thinking subvols are separate volumes. */
1005  return (r->id << 40) | (inode & 0xffffffffff);
1006 }
1007 
1008 #define keycmp(key1, key2)\
1009  ((key1.obj_id < key2.obj_id) ? -1 :\
1010  ((key1.obj_id > key2.obj_id) ? 1 :\
1011  ((key1.obj_type < key2.obj_type) ? -1 :\
1012  ((key1.obj_type > key2.obj_type) ? 1 :\
1013  ((key1.offset < key2.offset) ? -1 :\
1014  ((key1.offset > key2.offset) ? 1 :\
1015  0))))))
1016 
1017 _Post_satisfies_(return>=n)
1019  if (n & (a - 1))
1020  n = (n + a) & ~(a - 1);
1021 
1022  return n;
1023 }
1024 
1025 __inline static bool is_subvol_readonly(root* r, PIRP Irp) {
1026  if (!(r->root_item.flags & BTRFS_SUBVOL_READONLY))
1027  return false;
1028 
1029  if (!r->reserved)
1030  return true;
1031 
1032  return (!Irp || Irp->RequestorMode == UserMode) && PsGetCurrentProcess() != r->reserved ? true : false;
1033 }
1034 
1036  switch (type) {
1037  case TYPE_TREE_BLOCK_REF:
1038  return sizeof(TREE_BLOCK_REF);
1039 
1040  case TYPE_EXTENT_DATA_REF:
1041  return sizeof(EXTENT_DATA_REF);
1042 
1043  case TYPE_EXTENT_REF_V0:
1044  return sizeof(EXTENT_REF_V0);
1045 
1046  case TYPE_SHARED_BLOCK_REF:
1047  return sizeof(SHARED_BLOCK_REF);
1048 
1049  case TYPE_SHARED_DATA_REF:
1050  return sizeof(SHARED_DATA_REF);
1051 
1052  default:
1053  return 0;
1054  }
1055 }
1056 
1058  switch (type) {
1059  case TYPE_TREE_BLOCK_REF:
1060  return 1;
1061 
1062  case TYPE_EXTENT_DATA_REF:
1063  {
1065  return edr->count;
1066  }
1067 
1068  case TYPE_EXTENT_REF_V0:
1069  {
1070  EXTENT_REF_V0* erv0 = (EXTENT_REF_V0*)data;
1071  return erv0->count;
1072  }
1073 
1074  case TYPE_SHARED_BLOCK_REF:
1075  return 1;
1076 
1077  case TYPE_SHARED_DATA_REF:
1078  {
1080  return sdr->count;
1081  }
1082 
1083  default:
1084  return 0;
1085  }
1086 }
1087 
1088 // in xor-gas.S
1089 #if defined(_X86_) || defined(_AMD64_)
1090 void __stdcall do_xor_sse2(uint8_t* buf1, uint8_t* buf2, uint32_t len);
1091 void __stdcall do_xor_avx2(uint8_t* buf1, uint8_t* buf2, uint32_t len);
1092 #endif
1093 
1094 // in btrfs.c
1097 
1098 _Success_(return)
1099 bool get_file_attributes_from_xattr(_In_reads_bytes_(len) char* val, _In_ uint16_t len, _Out_ ULONG* atts);
1100 
1102  _In_ uint8_t type, _In_ bool dotfile, _In_ bool ignore_xa, _In_opt_ PIRP Irp);
1103 
1105 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,
1107 
1108 #ifndef DEBUG_FCB_REFCOUNTS
1109 void free_fcb(_Inout_ fcb* fcb);
1110 #endif
1111 void free_fileref(_Inout_ file_ref* fr);
1113 bool is_top_level(_In_ PIRP Irp);
1115  _Out_ root** rootptr, _In_ bool no_tree, _In_ uint64_t offset, _In_opt_ PIRP Irp);
1118  _Out_writes_bytes_opt_(OutputBufferSize) PVOID OutputBuffer, _In_ ULONG OutputBufferSize, _In_ bool Override, _Out_opt_ IO_STATUS_BLOCK* iosb);
1122 
1123 typedef void (__stdcall *xor_func)(uint8_t* buf1, uint8_t* buf2, uint32_t len);
1124 
1125 extern xor_func do_xor;
1126 
1127 #ifdef DEBUG_CHUNK_LOCKS
1128 #define acquire_chunk_lock(c, Vcb) { ExAcquireResourceExclusiveLite(&c->lock, true); InterlockedIncrement(&Vcb->chunk_locks_held); }
1129 #define release_chunk_lock(c, Vcb) { InterlockedDecrement(&Vcb->chunk_locks_held); ExReleaseResourceLite(&c->lock); }
1130 #else
1131 #define acquire_chunk_lock(c, Vcb) ExAcquireResourceExclusiveLite(&(c)->lock, true)
1132 #define release_chunk_lock(c, Vcb) ExReleaseResourceLite(&(c)->lock)
1133 #endif
1134 
1135 void mark_fcb_dirty(_In_ fcb* fcb);
1136 void mark_fileref_dirty(_In_ file_ref* fileref);
1140 void init_device(_In_ device_extension* Vcb, _Inout_ device* dev, _In_ bool get_nums);
1143  _Out_writes_bytes_(Length) PUCHAR Buffer, _In_ bool override);
1147 
1148 _Function_class_(DRIVER_ADD_DEVICE)
1150 
1151 void reap_fcb(fcb* fcb);
1155 NTSTATUS utf8_to_utf16(WCHAR* dest, ULONG dest_max, ULONG* dest_len, char* src, ULONG src_len);
1156 NTSTATUS utf16_to_utf8(char* dest, ULONG dest_max, ULONG* dest_len, WCHAR* src, ULONG src_len);
1158 
1161 
1162 void do_shutdown(PIRP Irp);
1164 
1165 #ifdef _MSC_VER
1166 #define funcname __FUNCTION__
1167 #else
1168 #define funcname __func__
1169 #endif
1170 
1171 extern uint32_t mount_compress;
1174 extern uint32_t mount_zlib_level;
1175 extern uint32_t mount_zstd_level;
1177 extern uint32_t mount_max_inline;
1179 extern uint32_t mount_no_barrier;
1180 extern uint32_t mount_no_trim;
1183 extern uint32_t mount_readonly;
1185 extern uint32_t no_pnp;
1186 
1187 #ifndef __GNUC__
1188 #define __attribute__(x)
1189 #endif
1190 
1191 #ifdef _DEBUG
1192 
1193 extern bool log_started;
1194 extern uint32_t debug_log_level;
1195 
1196 #ifdef DEBUG_LONG_MESSAGES
1197 
1198 #define MSG(fn, file, line, s, level, ...) (!log_started || level <= debug_log_level) ? _debug_message(fn, file, line, s, ##__VA_ARGS__) : (void)0
1199 
1200 #define TRACE(s, ...) MSG(funcname, __FILE__, __LINE__, s, 3, ##__VA_ARGS__)
1201 #define WARN(s, ...) MSG(funcname, __FILE__, __LINE__, s, 2, ##__VA_ARGS__)
1202 #define FIXME(s, ...) MSG(funcname, __FILE__, __LINE__, s, 1, ##__VA_ARGS__)
1203 #define ERR(s, ...) MSG(funcname, __FILE__, __LINE__, s, 1, ##__VA_ARGS__)
1204 
1205 void _debug_message(_In_ const char* func, _In_ const char* file, _In_ unsigned int line, _In_ char* s, ...) __attribute__((format(printf, 4, 5)));
1206 
1207 #else
1208 
1209 #define MSG(fn, s, level, ...) (!log_started || level <= debug_log_level) ? _debug_message(fn, s, ##__VA_ARGS__) : (void)0
1210 
1211 #define TRACE(s, ...) MSG(funcname, s, 3, ##__VA_ARGS__)
1212 #define WARN(s, ...) MSG(funcname, s, 2, ##__VA_ARGS__)
1213 #define FIXME(s, ...) MSG(funcname, s, 1, ##__VA_ARGS__)
1214 #define ERR(s, ...) MSG(funcname, s, 1, ##__VA_ARGS__)
1215 
1216 void _debug_message(_In_ const char* func, _In_ char* s, ...) __attribute__((format(printf, 2, 3)));
1217 
1218 #endif
1219 
1220 #else
1221 
1222 #define TRACE(s, ...) do { } while(0)
1223 #define WARN(s, ...) do { } while(0)
1224 #define FIXME(s, ...) DbgPrint("Btrfs FIXME : %s : " s, funcname, ##__VA_ARGS__)
1225 #define ERR(s, ...) DbgPrint("Btrfs ERR : %s : " s, funcname, ##__VA_ARGS__)
1226 
1227 #endif
1228 
1229 #ifdef DEBUG_FCB_REFCOUNTS
1230 void _free_fcb(_Inout_ fcb* fcb, _In_ const char* func);
1231 #define free_fcb(fcb) _free_fcb(fcb, funcname)
1232 #endif
1233 
1234 // in fastio.c
1236 
1237 // in sha256.c
1238 void calc_sha256(uint8_t* hash, const void* input, size_t len);
1239 #define SHA256_HASH_SIZE 32
1240 
1241 // in blake2b-ref.c
1242 void blake2b(void *out, size_t outlen, const void* in, size_t inlen);
1243 #define BLAKE2_HASH_SIZE 32
1244 
1245 typedef struct {
1251 } rollback_space;
1252 
1253 typedef struct {
1256 } rollback_extent;
1257 
1263 };
1264 
1265 typedef struct {
1267  void* ptr;
1269 } rollback_item;
1270 
1271 typedef struct {
1276 } ea_item;
1277 
1278 static const char lxuid[] = "$LXUID";
1279 static const char lxgid[] = "$LXGID";
1280 static const char lxmod[] = "$LXMOD";
1281 static const char lxdev[] = "$LXDEV";
1282 
1283 // in treefuncs.c
1285  _In_ const KEY* searchkey, _In_ bool ignore, _In_opt_ PIRP Irp) __attribute__((nonnull(1,2,3,4)));
1286 NTSTATUS find_item_to_level(device_extension* Vcb, root* r, traverse_ptr* tp, const KEY* searchkey, bool ignore,
1287  uint8_t level, PIRP Irp) __attribute__((nonnull(1,2,3,4)));
1288 bool find_next_item(_Requires_lock_held_(_Curr_->tree_lock) device_extension* Vcb, const traverse_ptr* tp,
1289  traverse_ptr* next_tp, bool ignore, PIRP Irp) __attribute__((nonnull(1,2,3)));
1290 bool find_prev_item(_Requires_lock_held_(_Curr_->tree_lock) device_extension* Vcb, const traverse_ptr* tp,
1291  traverse_ptr* prev_tp, PIRP Irp) __attribute__((nonnull(1,2,3)));
1292 void free_trees(device_extension* Vcb) __attribute__((nonnull(1)));
1297  _Inout_ traverse_ptr* tp) __attribute__((nonnull(1,2)));
1298 void free_tree(tree* t) __attribute__((nonnull(1)));
1301 void clear_rollback(LIST_ENTRY* rollback) __attribute__((nonnull(1)));
1303 void free_trees_root(device_extension* Vcb, root* r) __attribute__((nonnull(1,2)));
1306  LIST_ENTRY* batchlist, PIRP Irp) __attribute__((nonnull(1,2)));
1307 void clear_batch_list(device_extension* Vcb, LIST_ENTRY* batchlist) __attribute__((nonnull(1,2)));
1308 NTSTATUS skip_to_difference(device_extension* Vcb, traverse_ptr* tp, traverse_ptr* tp2, bool* ended1, bool* ended2) __attribute__((nonnull(1,2,3,4,5)));
1309 
1310 // in search.c
1312 
1313 _Function_class_(KSTART_ROUTINE)
1314 void __stdcall mountmgr_thread(_In_ void* context);
1315 
1316 _Function_class_(DRIVER_NOTIFICATION_CALLBACK_ROUTINE)
1318 
1319 void disk_arrival(PUNICODE_STRING devpath);
1320 bool volume_arrival(PUNICODE_STRING devpath, bool fve_callback);
1321 void volume_removal(PUNICODE_STRING devpath);
1322 
1323 _Function_class_(DRIVER_NOTIFICATION_CALLBACK_ROUTINE)
1325 
1327  _In_ volume_child* vc, _In_ bool skip_dev);
1328 extern KSPIN_LOCK fve_data_lock;
1329 
1330 // in cache.c
1331 void init_cache();
1333 
1334 // in write.c
1335 NTSTATUS write_file(device_extension* Vcb, PIRP Irp, bool wait, bool deferred_write) __attribute__((nonnull(1,2)));
1336 NTSTATUS write_file2(device_extension* Vcb, PIRP Irp, LARGE_INTEGER offset, void* buf, ULONG* length, bool paging_io, bool no_cache,
1337  bool wait, bool deferred_write, bool write_irp, LIST_ENTRY* rollback) __attribute__((nonnull(1,2,4,5,11)));
1342 NTSTATUS alloc_chunk(device_extension* Vcb, uint64_t flags, chunk** pc, bool full_size) __attribute__((nonnull(1,3)));
1344  _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)));
1346  uint64_t irp_offset, ULONG priority) __attribute__((nonnull(1,3)));
1348 
1352 
1357  _In_ bool file_write, _In_ uint64_t irp_offset) __attribute__((nonnull(1,2,3,9)));
1358 
1359 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)));
1361 void get_raid56_lock_range(chunk* c, uint64_t address, uint64_t length, uint64_t* lockaddr, uint64_t* locklen) __attribute__((nonnull(1,4,5)));
1363  _In_ bool unique, _In_opt_ _When_(return >= 0, __drv_aliasesMem) void* csum, _In_ LIST_ENTRY* rollback) __attribute__((nonnull(1,3,7)));
1364 void add_extent(_In_ fcb* fcb, _In_ LIST_ENTRY* prevextle, _In_ __drv_aliasesMem extent* newext) __attribute__((nonnull(1,2,3)));
1365 
1366 // in dirctrl.c
1367 
1370 NTSTATUS __stdcall drv_directory_control(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp);
1371 
1374 
1375 // in security.c
1376 
1379 NTSTATUS __stdcall drv_query_security(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp);
1380 
1384 
1385 void fcb_get_sd(fcb* fcb, struct _fcb* parent, bool look_for_xattr, PIRP Irp);
1386 void add_user_mapping(WCHAR* sidstring, ULONG sidstringlength, uint32_t uid);
1387 void add_group_mapping(WCHAR* sidstring, ULONG sidstringlength, uint32_t gid);
1390 NTSTATUS fcb_get_new_sd(fcb* fcb, file_ref* parfileref, ACCESS_STATE* as);
1391 void find_gid(struct _fcb* fcb, struct _fcb* parfcb, PSECURITY_SUBJECT_CONTEXT subjcont);
1392 
1393 // in fileinfo.c
1394 
1397 NTSTATUS __stdcall drv_set_information(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp);
1398 
1401 NTSTATUS __stdcall drv_query_information(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp);
1402 
1406 
1410 
1411 bool has_open_children(file_ref* fileref);
1413 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
1516 void space_list_merge(LIST_ENTRY* spacelist, LIST_ENTRY* spacelist_size, LIST_ENTRY* deleting);
1518 
1519 // in extent-tree.c
1522  uint32_t refcount, bool superseded, PIRP Irp);
1530  int32_t count, bool no_csum, bool superseded, PIRP Irp);
1537 
1538 // in worker-thread.c
1542 
1543 // in registry.c
1544 void read_registry(PUNICODE_STRING regpath, bool refresh);
1548 void watch_registry(HANDLE regh);
1549 
1550 // in compress.c
1551 NTSTATUS zlib_decompress(uint8_t* inbuf, uint32_t inlen, uint8_t* outbuf, uint32_t outlen);
1552 NTSTATUS lzo_decompress(uint8_t* inbuf, uint32_t inlen, uint8_t* outbuf, uint32_t outlen, uint32_t inpageoff);
1553 NTSTATUS zstd_decompress(uint8_t* inbuf, uint32_t inlen, uint8_t* outbuf, uint32_t outlen);
1555 NTSTATUS zlib_compress(uint8_t* inbuf, uint32_t inlen, uint8_t* outbuf, uint32_t outlen, unsigned int level, unsigned int* space_left);
1556 NTSTATUS lzo_compress(uint8_t* inbuf, uint32_t inlen, uint8_t* outbuf, uint32_t outlen, unsigned int* space_left);
1557 NTSTATUS zstd_compress(uint8_t* inbuf, uint32_t inlen, uint8_t* outbuf, uint32_t outlen, uint32_t level, unsigned int* space_left);
1558 
1559 // in galois.c
1561 void galois_divpower(uint8_t* data, uint8_t div, uint32_t readlen);
1565 
1566 // in devctrl.c
1567 
1570 NTSTATUS __stdcall drv_device_control(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp);
1571 
1572 // in calcthread.c
1573 
1574 _Function_class_(KSTART_ROUTINE)
1575 void __stdcall calc_thread(void* context);
1576 
1579  void* out, unsigned int outlen, unsigned int off, calc_job** pcj);
1580 NTSTATUS add_calc_job_comp(device_extension* Vcb, uint8_t compression, void* in, unsigned int inlen,
1581  void* out, unsigned int outlen, calc_job** pcj);
1583 
1584 // in balance.c
1592 
1593 _Function_class_(KSTART_ROUTINE)
1594 void __stdcall balance_thread(void* context);
1595 
1596 // in volume.c
1602 void add_volume_device(superblock* sb, PUNICODE_STRING devpath, uint64_t length, ULONG disk_num, ULONG part_num);
1604 
1605 _Function_class_(DRIVER_NOTIFICATION_CALLBACK_ROUTINE)
1607 
1609 
1610 // in scrub.c
1616 
1617 // in send.c
1620 
1621 // in fsrtl.c
1623 
1624 // in boot.c
1625 void check_system_root();
1626 void boot_add_device(DEVICE_OBJECT* pdo);
1627 extern BTRFS_UUID boot_uuid;
1628 
1629 // based on function in sys/sysmacros.h
1630 #define makedev(major, minor) (((minor) & 0xFF) | (((major) & 0xFFF) << 8) | (((uint64_t)((minor) & ~0xFF)) << 12) | (((uint64_t)((major) & ~0xFFF)) << 32))
1631 
1632 #ifndef __REACTOS__
1633 // not in mingw yet
1634 #ifndef _MSC_VER
1635 typedef struct {
1641  union {
1644  };
1647 
1648 #define FSRTL_FCB_HEADER_V2 2
1649 
1650 #else
1651 #define FSRTL_ADVANCED_FCB_HEADER_NEW FSRTL_ADVANCED_FCB_HEADER
1652 #endif
1653 #else
1654 typedef struct {
1656  PFAST_MUTEX FastMutex;
1657  LIST_ENTRY FilterContexts;
1658  EX_PUSH_LOCK PushLock;
1660  union {
1661  OPLOCK Oplock;
1662  PVOID ReservedForRemote;
1663  };
1664  PVOID ReservedContext;
1666 
1667 #define FSRTL_FCB_HEADER_V2 2
1668 #endif // __REACTOS__
1669 
1670 static __inline POPLOCK fcb_oplock(fcb* fcb) {
1671  if (fcb->Header.Version >= FSRTL_FCB_HEADER_V2)
1672  return &((FSRTL_ADVANCED_FCB_HEADER_NEW*)&fcb->Header)->Oplock;
1673  else
1674  return &fcb->oplock;
1675 }
1676 
1679  return FastIoIsNotPossible;
1680 
1681  if (!FsRtlAreThereCurrentFileLocks(&fcb->lock) && !fcb->Vcb->readonly)
1682  return FastIoIsPossible;
1683 
1684  return FastIoIsQuestionable;
1685 }
1686 
1687 static __inline void print_open_trees(device_extension* Vcb) {
1688  LIST_ENTRY* le = Vcb->trees.Flink;
1689  while (le != &Vcb->trees) {
1691  tree_data* td = CONTAINING_RECORD(t->itemlist.Flink, tree_data, list_entry);
1692  ERR("tree %p: root %I64x, level %u, first key (%I64x,%x,%I64x)\n",
1693  t, t->root->id, t->header.level, td->key.obj_id, td->key.obj_type, td->key.offset);
1694 
1695  le = le->Flink;
1696  }
1697 }
1698 
1699 static __inline bool write_fcb_compressed(fcb* fcb) {
1700  // make sure we don't accidentally write the cache inodes or pagefile compressed
1702  return false;
1703 
1704  if (fcb->Vcb->options.compress_force)
1705  return true;
1706 
1708  return false;
1709 
1710  if (fcb->inode_item.flags & BTRFS_INODE_COMPRESS || fcb->Vcb->options.compress)
1711  return true;
1712 
1713  return false;
1714 }
1715 
1716 #ifdef DEBUG_FCB_REFCOUNTS
1717 #ifdef DEBUG_LONG_MESSAGES
1718 #define increase_fileref_refcount(fileref) {\
1719  LONG rc = InterlockedIncrement(&fileref->refcount);\
1720  MSG(funcname, __FILE__, __LINE__, "fileref %p: refcount now %i\n", 1, fileref, rc);\
1721 }
1722 #else
1723 #define increase_fileref_refcount(fileref) {\
1724  LONG rc = InterlockedIncrement(&fileref->refcount);\
1725  MSG(funcname, "fileref %p: refcount now %i\n", 1, fileref, rc);\
1726 }
1727 #endif
1728 #else
1729 #define increase_fileref_refcount(fileref) InterlockedIncrement(&fileref->refcount)
1730 #endif
1731 
1732 #ifdef _MSC_VER
1733 #define int3 __debugbreak()
1734 #else
1735 #define int3 asm("int3;")
1736 #endif
1737 
1738 #define hex_digit(c) ((c) <= 9) ? ((c) + '0') : ((c) - 10 + 'a')
1739 
1740 // FIXME - find a way to catch unfreed trees again
1741 
1742 // from sys/stat.h
1743 #define __S_IFMT 0170000 /* These bits determine file type. */
1744 #define __S_IFDIR 0040000 /* Directory. */
1745 #define __S_IFCHR 0020000 /* Character device. */
1746 #define __S_IFBLK 0060000 /* Block device. */
1747 #define __S_IFREG 0100000 /* Regular file. */
1748 #define __S_IFIFO 0010000 /* FIFO. */
1749 #define __S_IFLNK 0120000 /* Symbolic link. */
1750 #define __S_IFSOCK 0140000 /* Socket. */
1751 #define __S_ISTYPE(mode, mask) (((mode) & __S_IFMT) == (mask))
1752 
1753 #ifndef S_ISDIR
1754 #define S_ISDIR(mode) __S_ISTYPE((mode), __S_IFDIR)
1755 #endif
1756 
1757 #ifndef S_IRUSR
1758 #define S_IRUSR 0000400
1759 #endif
1760 
1761 #ifndef S_IWUSR
1762 #define S_IWUSR 0000200
1763 #endif
1764 
1765 #ifndef S_IXUSR
1766 #define S_IXUSR 0000100
1767 #endif
1768 
1769 #ifdef __REACTOS__
1770 #define S_IFDIR __S_IFDIR
1771 #define S_IFREG __S_IFREG
1772 #endif /* __REACTOS__ */
1773 
1774 #ifndef S_IRGRP
1775 #define S_IRGRP (S_IRUSR >> 3)
1776 #endif
1777 
1778 #ifndef S_IWGRP
1779 #define S_IWGRP (S_IWUSR >> 3)
1780 #endif
1781 
1782 #ifndef S_IXGRP
1783 #define S_IXGRP (S_IXUSR >> 3)
1784 #endif
1785 
1786 #ifndef S_IROTH
1787 #define S_IROTH (S_IRGRP >> 3)
1788 #endif
1789 
1790 #ifndef S_IWOTH
1791 #define S_IWOTH (S_IWGRP >> 3)
1792 #endif
1793 
1794 #ifndef S_IXOTH
1795 #define S_IXOTH (S_IXGRP >> 3)
1796 #endif
1797 
1798 #ifndef S_ISUID
1799 #define S_ISUID 0004000
1800 #endif
1801 
1802 #ifndef S_ISGID
1803 #define S_ISGID 0002000
1804 #endif
1805 
1806 #ifndef S_ISVTX
1807 #define S_ISVTX 0001000
1808 #endif
1809 
1810 // based on functions in sys/sysmacros.h
1811 #define major(rdev) ((((rdev) >> 8) & 0xFFF) | ((uint32_t)((rdev) >> 32) & ~0xFFF))
1812 #define minor(rdev) (((rdev) & 0xFF) | ((uint32_t)((rdev) >> 12) & ~0xFF))
1813 
1814 static __inline uint64_t fcb_alloc_size(fcb* fcb) {
1815  if (S_ISDIR(fcb->inode_item.st_mode))
1816  return 0;
1817  else if (fcb->atts & FILE_ATTRIBUTE_SPARSE_FILE)
1818  return fcb->inode_item.st_blocks;
1819  else
1820  return sector_align(fcb->inode_item.st_size, fcb->Vcb->superblock.sector_size);
1821 }
1822 
1824 
1826  ULONG ReadOperationCount, ULONG WriteOperationCount, ULONG FlushOperationCount);
1827 
1829  PVOID Buffer, PETHREAD IoIssuerThread);
1830 
1832  PVOID Buffer, PIO_STATUS_BLOCK IoStatus, PETHREAD IoIssuerThread);
1833 
1834 #ifndef CC_ENABLE_DISK_IO_ACCOUNTING
1835 #define CC_ENABLE_DISK_IO_ACCOUNTING 0x00000010
1836 #endif
1837 
1838 #if defined(__REACTOS__) && (NTDDI_VERSION < NTDDI_VISTA)
1839 typedef struct _ECP_LIST ECP_LIST;
1840 typedef struct _ECP_LIST *PECP_LIST;
1841 #endif
1842 
1844 
1846 
1848 
1850 
1853 
1855 
1857 
1859 
1860 #ifndef __REACTOS__
1861 #ifndef _MSC_VER
1863 #endif
1864 
1865 // not in DDK headers - taken from winternl.h
1866 typedef struct _LDR_DATA_TABLE_ENTRY {
1875  union {
1878  };
1881 
1882 typedef struct _PEB_LDR_DATA {
1887 
1894 
1896 
1897 typedef struct _PEB {
1910 } PEB,*PPEB;
1911 #endif /* __REACTOS__ */
1912 
1913 #ifdef _MSC_VER
1917  IN PROCESSINFOCLASS ProcessInformationClass,
1918  OUT PVOID ProcessInformation,
1919  IN ULONG ProcessInformationLength,
1921 );
1922 #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:1845
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:1247
SHARED_DATA_REF sdr
Definition: btrfs_drv.h:607
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:752
void free_fileref(_Inout_ file_ref *fr)
Definition: btrfs.c:1825
_In_ PVOID NotificationStructure
Definition: iofuncs.h:1206
ULONG * bmparr
Definition: btrfs_drv.h:547
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:858
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:1904
bool check_superblock_checksum(superblock *sb)
Definition: btrfs.c:2794
uint16_t last_stripe
Definition: btrfs_drv.h:580
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:840
_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:1278
_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:1355
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:851
void reap_fcb(fcb *fcb)
Definition: btrfs.c:1712
LIST_ENTRY trees
Definition: btrfs_drv.h:801
LIST_ENTRY trees_hash
Definition: btrfs_drv.h:802
void trim_whole_device(device *dev)
Definition: fsctl.c:2712
struct _file_ref * fileref
Definition: btrfs_drv.h:260
uint16_t size
Definition: btrfs_drv.h:556
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
_In_ ULONG cj
Definition: winddi.h:3540
root * data_reloc_root
Definition: btrfs_drv.h:795
LIST_ENTRY space
Definition: btrfs_drv.h:532
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:1099
LIST_ENTRY dirty_filerefs
Definition: btrfs_drv.h:808
PFILE_OBJECT fileobj
Definition: btrfs_drv.h:519
NTSTATUS check_file_name_valid(_In_ PUNICODE_STRING us, _In_ bool posix, _In_ bool stream)
Definition: btrfs.c:5766
bool skip_balance
Definition: btrfs_drv.h:671
scrub_info scrub
Definition: btrfs_drv.h:818
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:825
void init_fast_io_dispatch(FAST_IO_DISPATCH **fiod)
Definition: fastio.c:535
LIST_ENTRY list_entry
Definition: btrfs_drv.h:585
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:1275
chunk * c
Definition: btrfs_drv.h:941
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:539
#define _In_opt_
Definition: ms_sal.h:309
LIST_ENTRY list_entry
Definition: btrfs_drv.h:533
uint64_t system_flags
Definition: btrfs_drv.h:786
rwlock_t lock
Definition: tcpcore.h:1163
BTRFS_UUID boot_uuid
Definition: boot.c:33
LIST_ENTRY list_entry
Definition: btrfs_drv.h:599
#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:5341
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:4131
PAGED_LOOKASIDE_LIST fcb_lookaside
Definition: btrfs_drv.h:827
#define IRP_MJ_QUERY_SECURITY
_In_ PFCB _In_ LONGLONG StartingOffset
Definition: cdprocs.h:290
void * in
Definition: btrfs_drv.h:635
#define error(str)
Definition: mkdosfs.c:1605
uint32_t adshash
Definition: btrfs_drv.h:331
bool paused
Definition: btrfs_drv.h:735
NTSTATUS(__stdcall * tFsRtlGetNextExtraCreateParameter)(PECP_LIST EcpList, PVOID CurrentEcpContext, LPGUID NextEcpType, PVOID *NextEcpContext, ULONG *NextEcpContextSize)
Definition: btrfs_drv.h:1851
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
struct _root_cache root_cache
NPAGED_LOOKASIDE_LIST fcb_np_lookaside
Definition: btrfs_drv.h:830
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:824
static const char lxdev[]
Definition: btrfs_drv.h:1281
NTSTATUS fileref_get_filename(file_ref *fileref, PUNICODE_STRING fn, USHORT *name_offset, ULONG *preqlen)
Definition: fileinfo.c:4236
#define _Out_
Definition: ms_sal.h:345
uint64_t offset
Definition: btrfs_drv.h:716
unsigned int csum_size
Definition: btrfs_drv.h:763
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
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:4230
root * checksum_root
Definition: btrfs_drv.h:792
#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:947
NTSTATUS find_chunk_usage(_In_ _Requires_lock_held_(_Curr_->tree_lock) device_extension *Vcb, _In_opt_ PIRP Irp)
Definition: btrfs.c:3845
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:610
struct _FILE_ID_128 FILE_ID_128
root * root
Definition: btrfs_drv.h:506
_In_ WDFDPC _In_ BOOLEAN Wait
Definition: wdfdpc.h:167
uint64_t offset
Definition: btrfs_drv.h:557
_In_ fcb _In_ chunk _In_ uint64_t _In_ uint64_t _In_ bool _In_opt_ void _In_opt_ PIRP Irp
Definition: btrfs_drv.h:1355
void fcb_get_sd(fcb *fcb, struct _fcb *parent, bool look_for_xattr, PIRP Irp)
Definition: security.c:511
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:7759
#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:518
uint32_t mount_allow_degraded
Definition: btrfs.c:83
struct _root root
superblock superblock
Definition: btrfs_drv.h:761
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:867
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:526
void reap_filerefs(device_extension *Vcb, file_ref *fr)
Definition: btrfs.c:1875
LONG NTSTATUS
Definition: precomp.h:26
PAGED_LOOKASIDE_LIST tree_data_lookaside
Definition: btrfs_drv.h:823
batch_operation
Definition: btrfs_drv.h:470
bool sd_deleted
Definition: btrfs_drv.h:321
bool no_barrier
Definition: btrfs_drv.h:672
#define ERR(s,...)
Definition: btrfs_drv.h:1225
tree_holder treeholder
Definition: btrfs_drv.h:411
ERESOURCE fileref_lock
Definition: btrfs_drv.h:777
LIST_ENTRY InMemoryOrderModuleList
Definition: btrfs_drv.h:1885
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:767
ANSI_STRING ea_xattr
Definition: btrfs_drv.h:302
static int inbuf
Definition: adnsresfilter.c:73
KEVENT event
Definition: btrfs_drv.h:732
bool dirty
Definition: btrfs_drv.h:456
uint64_t data_flags
Definition: btrfs_drv.h:784
ERESOURCE range_locks_lock
Definition: btrfs_drv.h:568
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:5840
#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:4038
void free_fcb(_Inout_ fcb *fcb)
Definition: btrfs.c:1703
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:1900
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:812
bool removing
Definition: btrfs_drv.h:696
PKTHREAD lazy_writer_thread
Definition: btrfs_drv.h:296
ERESOURCE dirty_filerefs_lock
Definition: btrfs_drv.h:809
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:698
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:869
uint64_t used
Definition: btrfs_drv.h:558
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:690
uint8_t compress_type
Definition: btrfs_drv.h:664
LIST_ENTRY errors
Definition: btrfs_drv.h:745
uint64_t address
Definition: btrfs_drv.h:546
uint32_t hash
Definition: btrfs_drv.h:255
GLuint buffer
Definition: glext.h:5915
BYTE BeingDebugged
Definition: btrfs_drv.h:1899
struct _PEB_LDR_DATA * PPEB_LDR_DATA
PNOTIFY_SYNC NotifySync
Definition: btrfs_drv.h:780
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:951
struct _volume_device_extension * vde
Definition: btrfs_drv.h:755
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:639
ERESOURCE load_lock
Definition: btrfs_drv.h:778
bool readonly
Definition: btrfs_drv.h:523
NTSTATUS stop_scrub(device_extension *Vcb, KPROCESSOR_MODE processor_mode)
Definition: scrub.c:3440
ERESOURCE send_load_lock
Definition: btrfs_drv.h:819
NTSTATUS get_device_pnp_name(_In_ PDEVICE_OBJECT DeviceObject, _Out_ PUNICODE_STRING pnp_name, _Out_ const GUID **guid)
Definition: btrfs.c:4202
bool clear_cache
Definition: btrfs_drv.h:674
uint64_t length
Definition: btrfs_drv.h:540
uint64_t old_size
Definition: btrfs_drv.h:592
bool readonly
Definition: btrfs_drv.h:573
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: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:549
PRTL_USER_PROCESS_PARAMETERS ProcessParameters
Definition: btrfs_drv.h:1903
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:1149
void calc_sha256(uint8_t *hash, const void *input, size_t len)
Definition: sha256.c:126
ULONG part_num
Definition: btrfs_drv.h:857
void * out
Definition: btrfs_drv.h:636
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)
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:780
bool check_sector_csum(device_extension *Vcb, void *buf, void *csum)
Definition: read.c:202
LIST_ENTRY old_refs
Definition: btrfs_drv.h:598
PSID sid
Definition: btrfs_drv.h:902
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:921
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:948
_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:989
bool dropped
Definition: btrfs_drv.h:463
uint8_t * data
Definition: btrfs_drv.h:415
LARGE_INTEGER resume_time
Definition: btrfs_drv.h:738
device ** devices
Definition: btrfs_drv.h:560
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:863
LIST_ENTRY devices
Definition: btrfs_drv.h:756
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:842
PAGED_LOOKASIDE_LIST name_bit_lookaside
Definition: btrfs_drv.h:828
struct _DUPLICATE_EXTENTS_DATA * PDUPLICATE_EXTENTS_DATA
balance_info balance
Definition: btrfs_drv.h:817
NTSTATUS stop_balance(device_extension *Vcb, KPROCESSOR_MODE processor_mode)
Definition: balance.c:3784
NTSTATUS error
Definition: btrfs_drv.h:743
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:692
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:1895
bool posix_delete
Definition: btrfs_drv.h:346
#define _Releases_exclusive_lock_(lock)
struct _write_data_context * context
Definition: btrfs_drv.h:918
KTIMER flush_thread_timer
Definition: btrfs_drv.h:814
BTRFS_UUID uuid
Definition: btrfs_drv.h:846
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:702
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:277
FxDevice * device
_In_ fcb _In_ chunk _In_ uint64_t start_data
Definition: btrfs_drv.h:1355
#define FSRTL_FCB_HEADER_V2
Definition: btrfs_drv.h:1648
void * data
Definition: btrfs_drv.h:488
uint64_t length
Definition: btrfs_drv.h:1249
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:511
UNICODE_STRING name
Definition: btrfs_drv.h:866
PEPROCESS __stdcall PsGetThreadProcess(_In_ PETHREAD Thread)
PVOID DllBase
Definition: btrfs_drv.h:1870
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:2633
uint64_t num_children
Definition: btrfs_drv.h:886
PDEVICE_OBJECT pdo
Definition: btrfs_drv.h:882
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:871
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:791
_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:1355
LIST_ENTRY list_entry
Definition: btrfs_drv.h:406
void do_shutdown(PIRP Irp)
Definition: btrfs.c:5361
uint32_t hash_uc
Definition: btrfs_drv.h:257
ERESOURCE dirty_subvols_lock
Definition: btrfs_drv.h:811
bool ea_changed
Definition: btrfs_drv.h:325
KEY firstitem
Definition: btrfs_drv.h:724
struct _PEB * PPEB
static __inline uint64_t make_file_id(root *r, uint64_t inode)
Definition: btrfs_drv.h:1004
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
fcb * old_cache
Definition: btrfs_drv.h:562
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:5813
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:896
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:3950
_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:606
uint64_t oldused
Definition: btrfs_drv.h:559
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:501
uint8_t * scratch
Definition: btrfs_drv.h:933
PVOID Reserved3[2]
Definition: btrfs_drv.h:1901
LIST_ENTRY drop_roots
Definition: btrfs_drv.h:788
chunk * chunk
Definition: btrfs_drv.h:1250
LIST_ENTRY send_ops
Definition: btrfs_drv.h:821
uint8_t gpow2(uint8_t e)
Definition: galois.c:69
ULONG change_count
Definition: btrfs_drv.h:527
_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:848
LIST_ENTRY items
Definition: btrfs_drv.h:496
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:1025
ERESOURCE changed_extents_lock
Definition: btrfs_drv.h:571
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:831
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:1248
Definition: devices.h:37
ANSI_STRING value
Definition: btrfs_drv.h:1273
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:5860
uint64_t offset
Definition: btrfs_drv.h:228
ULONG num_errors
Definition: btrfs_drv.h:744
#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:2580
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:1831
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:1355
#define __drv_aliasesMem
Definition: btrfs_drv.h:203
bool seeding
Definition: btrfs_drv.h:853
uint32_t mount_flush_interval
Definition: btrfs.c:77
bool changed
Definition: btrfs_drv.h:577
uint64_t address
Definition: btrfs_drv.h:706
tree_data * paritem
Definition: btrfs_drv.h:432
NTSTATUS(__stdcall * tFsRtlGetEcpListFromIrp)(PIRP Irp, PECP_LIST *EcpList)
Definition: btrfs_drv.h:1849
#define PsGetCurrentProcess
Definition: psfuncs.h:17
bool allocated
Definition: btrfs_drv.h:942
void flush_subvol_fcbs(root *subvol)
Definition: fsctl.c:243
uint32_t count
Definition: btrfs.h:420
bool root_dir
Definition: btrfs_drv.h:261
LIST_ENTRY list_entry_balance
Definition: btrfs_drv.h:586
PFILE_OBJECT root_file
Definition: btrfs_drv.h:822
LIST_ENTRY list_entry
Definition: btrfs_drv.h:550
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:3385
uint64_t count
Definition: btrfs_drv.h:593
unsigned char BOOLEAN
bool specific_file
Definition: btrfs_drv.h:378
bool trim
Definition: btrfs_drv.h:525
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:675
void mark_fcb_dirty(_In_ fcb *fcb)
Definition: btrfs.c:1664
void mark_fileref_dirty(_In_ file_ref *fileref)
Definition: btrfs.c:1686
root * r
Definition: btrfs_drv.h:495
WDF_INTERRUPT_PRIORITY priority
PDEVICE_OBJECT devobj
Definition: btrfs_drv.h:849
#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:654
#define _In_z_
Definition: ms_sal.h:313
bool reloc
Definition: btrfs_drv.h:574
void calc_tree_checksum(device_extension *Vcb, tree_header *th)
Definition: flushthread.c:1800
_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:737
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:870
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:710
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:542
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:1844
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:2965
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:963
static __inline bool write_fcb_compressed(fcb *fcb)
Definition: btrfs_drv.h:1699
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:940
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:807
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:736
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:579
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:1828
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:1810
bool is_unique
Definition: btrfs_drv.h:441
uint64_t metadata_flags
Definition: btrfs_drv.h:785
uint64_t children_loaded
Definition: btrfs_drv.h:887
uint64_t st_size
Definition: btrfs.h:289
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
LIST_ENTRY DirNotifyList
Definition: btrfs_drv.h:781
LIST_ENTRY list_entry
Definition: btrfs_drv.h:1268
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:711
calc_thread_type
Definition: btrfs_drv.h:620
GLsizeiptr size
Definition: glext.h:5919
LIST_ENTRY dir_children_index
Definition: btrfs_drv.h:314
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
struct _fcb fcb
Definition: btrfs_drv.h:1355
#define printf
Definition: freeldr.h:94
UCHAR flags
Definition: btrfs_drv.h:1274
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:64
bool fcb_is_inline(fcb *fcb)
Definition: fsctl.c:3242
#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:2979
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:700
uint64_t size
Definition: btrfs_drv.h:591
LIST_ENTRY xattrs
Definition: btrfs_drv.h:308
__wchar_t WCHAR
Definition: xmlstorage.h:180
uint32_t length
Definition: btrfs_drv.h:939
_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:1687
xor_func do_xor
Definition: btrfs.c:126
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:733
NTSTATUS do_tree_writes(device_extension *Vcb, LIST_ENTRY *tree_writes, bool no_free)
Definition: flushthread.c:1614
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:1035
KEVENT range_locks_event
Definition: btrfs_drv.h:569
LIST_ENTRY range_locks
Definition: btrfs_drv.h:567
bool user_set_change_time
Definition: btrfs_drv.h:390
PPS_POST_PROCESS_INIT_ROUTINE PostProcessInitRoutine
Definition: btrfs_drv.h:1906
bool had_drive_letter
Definition: btrfs_drv.h:854
BYTE Reserved1[8]
Definition: btrfs_drv.h:1883
struct _file_ref file_ref
#define Vcb
Definition: cdprocs.h:1415
rollback_type
Definition: btrfs_drv.h:1258
static __inline void * map_user_buffer(PIRP Irp, ULONG priority)
Definition: btrfs_drv.h:969
#define S_ISDIR(mode)
Definition: btrfs_drv.h:1754
ULONG CheckSum
Definition: btrfs_drv.h:1876
const GLubyte * c
Definition: glext.h:8905
unsigned int number
Definition: btrfs_drv.h:648
uint64_t root
Definition: btrfs_drv.h:722
UCHAR Identifier[16]
Definition: btrfs_drv.h:162
uint8_t * parity1
Definition: btrfs_drv.h:933
LIST_ENTRY sys_chunks
Definition: btrfs_drv.h:799
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:3268
LIST_ENTRY list_entry
Definition: btrfs_drv.h:891
PFILE_OBJECT locked_fileobj
Definition: btrfs_drv.h:771
unsigned short WORD
Definition: ntddk_ex.h:93
static FILE * out
Definition: regtests2xml.c:44
PVOID Reserved6
Definition: btrfs_drv.h:1877
KEVENT event
Definition: btrfs_drv.h:701
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:5883
bool removable
Definition: btrfs_drv.h:521
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:617
_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:715
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:738
bool case_sensitive
Definition: btrfs_drv.h:310
#define __stdcall
Definition: typedefs.h:25
bool chunk_usage_found
Definition: btrfs_drv.h:798
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:1823
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:888
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:855
PDEVICE_OBJECT mounted_device
Definition: btrfs_drv.h:868
LARGE_INTEGER duration
Definition: btrfs_drv.h:739
* PFILE_OBJECT
Definition: iotypes.h:1998
void(__stdcall * xor_func)(uint8_t *buf1, uint8_t *buf2, uint32_t len)
Definition: btrfs_drv.h:1123
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
BYTE Reserved4[8]
Definition: btrfs_drv.h:1873
ULONG disk_num
Definition: btrfs_drv.h:856
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:691
BOOLEAN(__stdcall * tFsRtlAreThereCurrentOrInProgressFileLocks)(PFILE_LOCK FileLock)
Definition: btrfs_drv.h:1858
#define _Ret_maybenull_
Definition: ms_sal.h:529
LIST_ENTRY list_entry
Definition: btrfs_drv.h:943
bool stopping
Definition: btrfs_drv.h:734
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:1240
#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:497
LIST_ENTRY trim_list
Definition: btrfs_drv.h:535
uint32_t mount_compress_force
Definition: btrfs.c:73
ANSI_STRING name
Definition: btrfs_drv.h:1272
NTSTATUS update_dev_item(device_extension *Vcb, device *device, PIRP Irp)
Definition: flushthread.c:4087
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:502
PVOID Reserved2[2]
Definition: btrfs_drv.h:1869
unsigned char UCHAR
Definition: xmlstorage.h:181
LONG not_started
Definition: btrfs_drv.h:638
LIST_ENTRY listentry
Definition: btrfs_drv.h:901
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:850
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:1891
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:578
LIST_ENTRY dirty_subvols
Definition: btrfs_drv.h:810
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:1909
PETHREAD thread
Definition: btrfs_drv.h:541
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:1898
bool recovered
Definition: btrfs_drv.h:708
bool uniqueness_determined
Definition: btrfs_drv.h:442
ULONG num_trim_entries
Definition: btrfs_drv.h:534
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:1854
static const WCHAR space[]
Definition: ConsoleCP.c:24
PAGED_LOOKASIDE_LIST fileref_lookaside
Definition: btrfs_drv.h:826
NTSTATUS flush_fcb(fcb *fcb, bool cache, LIST_ENTRY *batchlist, PIRP Irp)
Definition: flushthread.c:4806
#define VOID
Definition: acefi.h:82
LIST_ENTRY changed_extents
Definition: btrfs_drv.h:566
tree_holder treeholder
Definition: btrfs_drv.h:453
uint64_t chunks_left
Definition: btrfs_drv.h:741
LIST_ENTRY all_fcbs
Definition: btrfs_drv.h:805
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:919
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:2596
LIST_ENTRY list_entry_dirty
Definition: btrfs_drv.h:358
Definition: btrfs_drv.h:1866
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:872
GLdouble s
Definition: gl.h:2039
uint32_t zstd_level
Definition: btrfs_drv.h:667
Definition: _list.h:228
bool created
Definition: btrfs_drv.h:328
uint64_t data_scrubbed
Definition: btrfs_drv.h:742
_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:668
fcb * fcb
Definition: btrfs_drv.h:342
Definition: typedefs.h:119
UNICODE_STRING CommandLine
Definition: btrfs_drv.h:1892
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:806
PVOID Reserved5[52]
Definition: btrfs_drv.h:1905
bool seeding
Definition: btrfs_drv.h:522
void do_rollback(device_extension *Vcb, LIST_ENTRY *rollback) __attribute__((nonnull(1
uint32_t zlib_level
Definition: btrfs_drv.h:666
uint32_t max_inline
Definition: btrfs_drv.h:669
static __inline FAST_IO_POSSIBLE fast_io_possible(fcb *fcb)
Definition: btrfs_drv.h:1677
uint64_t address
Definition: btrfs_drv.h:938
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:581
KEVENT flush_thread_finished
Definition: btrfs_drv.h:815
__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:564
PDEVICE_OBJECT attached_device
Definition: btrfs_drv.h:872
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:2239
unsigned int sector_shift
Definition: btrfs_drv.h:762
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:4049
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:925
uint16_t filename_length
Definition: btrfs_drv.h:717
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:1879
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:800
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:774
struct _ECP_LIST * PECP_LIST
Definition: fsrtltypes.h:139
ULONG balance_num
Definition: btrfs_drv.h:699
bool reloc
Definition: btrfs_drv.h:524
IN PFCB IN PFILE_OBJECT FileObject IN ULONG AllocationSize
Definition: fatprocs.h:319
HANDLE thread
Definition: btrfs_drv.h:730
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:1970
bool ignore
Definition: btrfs_drv.h:407
uint32_t size
Definition: btrfs_drv.h:429
extent * ext
Definition: btrfs_drv.h:1255
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:512
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:641
PDEVICE_OBJECT attached_device
Definition: btrfs_drv.h:841
bool volume_arrival(PUNICODE_STRING devpath, bool fve_callback)
Definition: search.c:693
bool stats_changed
Definition: btrfs_drv.h:531
uint64_t total_chunks
Definition: btrfs_drv.h:740
NTSTATUS(__stdcall * tIoUnregisterPlugPlayNotificationEx)(PVOID NotificationEntry)
Definition: btrfs_drv.h:1847
void init_cache()
Definition: cache.c:85
* PFAST_MUTEX
Definition: extypes.h:17
bool created
Definition: btrfs_drv.h:572
_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:903
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:977
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:723
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:1636
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:787
drv_calc_threads calcthreads
Definition: btrfs_drv.h:816
void * context
Definition: btrfs_drv.h:364
BOOLEAN(__stdcall * tFsRtlCheckLockForOplockRequest)(PFILE_LOCK FileLock, PLARGE_INTEGER AllocationSize)
Definition: btrfs_drv.h:1856
unsigned short USHORT
Definition: pedump.c:61
ERESOURCE stats_lock
Definition: btrfs_drv.h:731
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:1279
PDEVICE_OBJECT devobj
Definition: btrfs_drv.h:754
LIST_ENTRY InMemoryOrderLinks
Definition: btrfs_drv.h:1868
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
uint32_t find_extent_shared_data_refcount(device_extension *Vcb, uint64_t address, uint64_t parent, PIRP Irp)
Definition: extent-tree.c:2220
PPEB_LDR_DATA Ldr
Definition: btrfs_drv.h:1902
bool compress_force
Definition: btrfs_drv.h:663
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:159
_In_ fcb _In_ chunk _In_ uint64_t _In_ uint64_t _In_ bool _In_opt_ void * data
Definition: btrfs_drv.h:1355
_In_ uint64_t _In_ uint64_t _In_ uint64_t generation
Definition: btrfs.c:2964
NTSTATUS dev_ioctl(_In_ PDEVICE_OBJECT DeviceObject, _In_ ULONG ControlCode, _In_reads_bytes_opt_(InputBufferSize) PVOID InputBuffer, _In_ ULONG InputBufferSize, _Out_writes_bytes_opt_(OutputBufferSize) PVOID OutputBuffer, _In_ ULONG OutputBufferSize, _In_ bool Override, _Out_opt_ IO_STATUS_BLOCK *iosb)
Definition: btrfs.c:2923