ReactOS  0.4.12-dev-409-g9f418243
scrub.cpp
Go to the documentation of this file.
1 /* Copyright (c) Mark Harmstone 2017
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 #include "shellext.h"
19 #include "scrub.h"
20 #include "resource.h"
21 #ifndef __REACTOS__
22 #include "../btrfsioctl.h"
23 #else
24 #include "btrfsioctl.h"
25 #endif
26 #include <shlobj.h>
27 #include <uxtheme.h>
28 #include <stdio.h>
29 #ifndef __REACTOS__
30 #include <strsafe.h>
31 #include <winternl.h>
32 #else
33 #define WIN32_NO_STATUS
34 #include <windef.h>
35 #include <winbase.h>
36 #include <strsafe.h>
37 #include <ndk/iofuncs.h>
38 #include <ndk/iotypes.h>
39 #endif
40 
41 #define NO_SHLWAPI_STRFCNS
42 #include <shlwapi.h>
43 #include <uxtheme.h>
44 
46  btrfs_query_scrub* bqs2 = nullptr;
47  bool alloc_bqs2 = false;
49  wstring s, t, u;
50  WCHAR dt[255], tm[255];
52  SYSTEMTIME systime;
53  uint64_t recoverable_errors = 0, unrecoverable_errors = 0;
54 
55  try {
56  if (bqs->num_errors > 0) {
57  win_handle h;
59  ULONG len;
60 
63  if (h == INVALID_HANDLE_VALUE)
64  throw last_error(GetLastError());
65 
66  len = 0;
67 
68  try {
69  do {
70  len += 1024;
71 
72  if (bqs2) {
73  free(bqs2);
74  bqs2 = nullptr;
75  }
76 
77  bqs2 = (btrfs_query_scrub*)malloc(len);
78 
79  Status = NtFsControlFile(h, nullptr, nullptr, nullptr, &iosb, FSCTL_BTRFS_QUERY_SCRUB, nullptr, 0, bqs2, len);
80 
82  throw ntstatus_error(Status);
83  } while (Status == STATUS_BUFFER_OVERFLOW);
84  } catch (...) {
85  if (bqs2)
86  free(bqs2);
87 
88  throw;
89  }
90 
91  alloc_bqs2 = true;
92  } else
93  bqs2 = bqs;
94 
95  // "scrub started"
96  if (bqs2->start_time.QuadPart > 0) {
97  filetime.dwLowDateTime = bqs2->start_time.LowPart;
98  filetime.dwHighDateTime = bqs2->start_time.HighPart;
99 
100  if (!FileTimeToSystemTime(&filetime, &systime))
101  throw last_error(GetLastError());
102 
103  if (!SystemTimeToTzSpecificLocalTime(nullptr, &systime, &systime))
104  throw last_error(GetLastError());
105 
107  throw last_error(GetLastError());
108 
109  if (!GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &systime, nullptr, dt, sizeof(dt) / sizeof(WCHAR)))
110  throw last_error(GetLastError());
111 
112  if (!GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &systime, nullptr, tm, sizeof(tm) / sizeof(WCHAR)))
113  throw last_error(GetLastError());
114 
115  wstring_sprintf(u, t, dt, tm);
116 
117  s += u;
118  s += L"\r\n";
119  }
120 
121  // errors
122  if (bqs2->num_errors > 0) {
123  btrfs_scrub_error* bse = &bqs2->errors;
124 
125  do {
126  if (bse->recovered)
127  recoverable_errors++;
128  else
129  unrecoverable_errors++;
130 
131  if (bse->parity) {
133  throw last_error(GetLastError());
134 
135  wstring_sprintf(u, t, bse->address, bse->device);
136  } else if (bse->is_metadata) {
137  int message;
138 
139  if (bse->recovered)
141  else if (bse->metadata.firstitem.obj_id == 0 && bse->metadata.firstitem.obj_type == 0 && bse->metadata.firstitem.offset == 0)
143  else
145 
146  if (!load_string(module, message, t))
147  throw last_error(GetLastError());
148 
149  if (bse->recovered)
150  wstring_sprintf(u, t, bse->address, bse->device);
151  else if (bse->metadata.firstitem.obj_id == 0 && bse->metadata.firstitem.obj_type == 0 && bse->metadata.firstitem.offset == 0)
152  wstring_sprintf(u, t, bse->address, bse->device, bse->metadata.root, bse->metadata.level);
153  else
154  wstring_sprintf(u, t, bse->address, bse->device, bse->metadata.root, bse->metadata.level, bse->metadata.firstitem.obj_id,
155  bse->metadata.firstitem.obj_type, bse->metadata.firstitem.offset);
156  } else {
157  int message;
158 
159  if (bse->recovered)
161  else if (bse->data.subvol != 0)
163  else
165 
166  if (!load_string(module, message, t))
167  throw last_error(GetLastError());
168 
169  if (bse->recovered)
170  wstring_sprintf(u, t, bse->address, bse->device);
171  else if (bse->data.subvol != 0)
172  wstring_sprintf(u, t, bse->address, bse->device, bse->data.subvol,
173  bse->data.filename_length / sizeof(WCHAR), bse->data.filename, bse->data.offset);
174  else
175  wstring_sprintf(u, t, bse->address, bse->device, bse->data.filename_length / sizeof(WCHAR),
176  bse->data.filename, bse->data.offset);
177  }
178 
179  s += u;
180  s += L"\r\n";
181 
182  if (bse->next_entry == 0)
183  break;
184  else
185  bse = (btrfs_scrub_error*)((uint8_t*)bse + bse->next_entry);
186  } while (true);
187  }
188 
189  if (bqs2->finish_time.QuadPart > 0) {
190  wstring d1, d2;
191  float speed;
192 
193  // "scrub finished"
194 
195  filetime.dwLowDateTime = bqs2->finish_time.LowPart;
196  filetime.dwHighDateTime = bqs2->finish_time.HighPart;
197 
198  if (!FileTimeToSystemTime(&filetime, &systime))
199  throw last_error(GetLastError());
200 
201  if (!SystemTimeToTzSpecificLocalTime(nullptr, &systime, &systime))
202  throw last_error(GetLastError());
203 
205  throw last_error(GetLastError());
206 
207  if (!GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &systime, nullptr, dt, sizeof(dt) / sizeof(WCHAR)))
208  throw last_error(GetLastError());
209 
210  if (!GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &systime, nullptr, tm, sizeof(tm) / sizeof(WCHAR)))
211  throw last_error(GetLastError());
212 
213  wstring_sprintf(u, t, dt, tm);
214 
215  s += u;
216  s += L"\r\n";
217 
218  // summary
219 
221  throw last_error(GetLastError());
222 
223  format_size(bqs2->data_scrubbed, d1, false);
224 
225  speed = (float)bqs2->data_scrubbed / ((float)bqs2->duration / 10000000.0f);
226 
227  format_size((uint64_t)speed, d2, false);
228 
229  wstring_sprintf(u, t, d1.c_str(), bqs2->duration / 10000000, d2.c_str());
230 
231  s += u;
232  s += L"\r\n";
233 
234  // recoverable errors
235 
237  throw last_error(GetLastError());
238 
239  wstring_sprintf(u, t, recoverable_errors);
240 
241  s += u;
242  s += L"\r\n";
243 
244  // unrecoverable errors
245 
247  throw last_error(GetLastError());
248 
249  wstring_sprintf(u, t, unrecoverable_errors);
250 
251  s += u;
252  s += L"\r\n";
253  }
254 
255  SetWindowTextW(GetDlgItem(hwndDlg, IDC_SCRUB_INFO), s.c_str());
256  } catch (...) {
257  if (alloc_bqs2)
258  free(bqs2);
259 
260  throw;
261  }
262 
263  if (alloc_bqs2)
264  free(bqs2);
265 }
266 
267 void BtrfsScrub::RefreshScrubDlg(HWND hwndDlg, bool first_time) {
268  btrfs_query_scrub bqs;
269 
270  {
273  if (h != INVALID_HANDLE_VALUE) {
276 
277  Status = NtFsControlFile(h, nullptr, nullptr, nullptr, &iosb, FSCTL_BTRFS_QUERY_SCRUB, nullptr, 0, &bqs, sizeof(btrfs_query_scrub));
278 
280  throw ntstatus_error(Status);
281  } else
282  throw last_error(GetLastError());
283  }
284 
285  if (first_time || status != bqs.status || chunks_left != bqs.chunks_left) {
286  wstring s;
287 
288  if (bqs.status == BTRFS_SCRUB_STOPPED) {
289  EnableWindow(GetDlgItem(hwndDlg, IDC_START_SCRUB), true);
290  EnableWindow(GetDlgItem(hwndDlg, IDC_PAUSE_SCRUB), false);
291  EnableWindow(GetDlgItem(hwndDlg, IDC_CANCEL_SCRUB), false);
292 
293  if (bqs.error != STATUS_SUCCESS) {
294  wstring t;
295 
297  throw last_error(GetLastError());
298 
299  wstring_sprintf(s, t, bqs.error);
300  } else {
302  throw last_error(GetLastError());
303  }
304  } else {
305  wstring t;
306  float pc;
307 
308  EnableWindow(GetDlgItem(hwndDlg, IDC_START_SCRUB), false);
309  EnableWindow(GetDlgItem(hwndDlg, IDC_PAUSE_SCRUB), true);
310  EnableWindow(GetDlgItem(hwndDlg, IDC_CANCEL_SCRUB), true);
311 
313  throw last_error(GetLastError());
314 
315  pc = ((float)(bqs.total_chunks - bqs.chunks_left) / (float)bqs.total_chunks) * 100.0f;
316 
317  wstring_sprintf(s, t, bqs.total_chunks - bqs.chunks_left, bqs.total_chunks, pc);
318  }
319 
320  SetDlgItemTextW(hwndDlg, IDC_SCRUB_STATUS, s.c_str());
321 
322  if (first_time || status != bqs.status) {
324 
325  if (bqs.status != BTRFS_SCRUB_STOPPED) {
328 
329  if (bqs.status == BTRFS_SCRUB_PAUSED)
330  SendMessageW(GetDlgItem(hwndDlg, IDC_SCRUB_PROGRESS), PBM_SETSTATE, PBST_PAUSED, 0);
331  else
332  SendMessageW(GetDlgItem(hwndDlg, IDC_SCRUB_PROGRESS), PBM_SETSTATE, PBST_NORMAL, 0);
333  } else {
336  }
337 
338  chunks_left = bqs.chunks_left;
339  }
340  }
341 
342  if (bqs.status != BTRFS_SCRUB_STOPPED && chunks_left != bqs.chunks_left) {
344  chunks_left = bqs.chunks_left;
345  }
346 
347  if (first_time || status != bqs.status || num_errors != bqs.num_errors) {
348  UpdateTextBox(hwndDlg, &bqs);
349 
350  num_errors = bqs.num_errors;
351  }
352 
353  status = bqs.status;
354 }
355 
359 
360  if (h != INVALID_HANDLE_VALUE) {
363 
364  Status = NtFsControlFile(h, nullptr, nullptr, nullptr, &iosb, FSCTL_BTRFS_START_SCRUB, nullptr, 0, nullptr, 0);
365 
368  NTSTATUS Status2;
369 
370  Status2 = NtFsControlFile(h, nullptr, nullptr, nullptr, &iosb, FSCTL_BTRFS_QUERY_BALANCE, nullptr, 0, &bqb, sizeof(btrfs_query_balance));
371 
374  }
375 
376  if (!NT_SUCCESS(Status))
377  throw ntstatus_error(Status);
378 
379  RefreshScrubDlg(hwndDlg, true);
380  } else
381  throw last_error(GetLastError());
382 }
383 
385  btrfs_query_scrub bqs;
386 
389 
390  if (h != INVALID_HANDLE_VALUE) {
393 
394  Status = NtFsControlFile(h, nullptr, nullptr, nullptr, &iosb, FSCTL_BTRFS_QUERY_SCRUB, nullptr, 0, &bqs, sizeof(btrfs_query_scrub));
395 
397  throw ntstatus_error(Status);
398 
399  if (bqs.status == BTRFS_SCRUB_PAUSED)
400  Status = NtFsControlFile(h, nullptr, nullptr, nullptr, &iosb, FSCTL_BTRFS_RESUME_SCRUB, nullptr, 0, nullptr, 0);
401  else
402  Status = NtFsControlFile(h, nullptr, nullptr, nullptr, &iosb, FSCTL_BTRFS_PAUSE_SCRUB, nullptr, 0, nullptr, 0);
403 
404  if (!NT_SUCCESS(Status))
405  throw ntstatus_error(Status);
406  } else
407  throw last_error(GetLastError());
408 }
409 
413 
414  if (h != INVALID_HANDLE_VALUE) {
417 
418  Status = NtFsControlFile(h, nullptr, nullptr, nullptr, &iosb, FSCTL_BTRFS_STOP_SCRUB, nullptr, 0, nullptr, 0);
419 
420  if (!NT_SUCCESS(Status))
421  throw ntstatus_error(Status);
422  } else
423  throw last_error(GetLastError());
424 }
425 
427  try {
428  switch (uMsg) {
429  case WM_INITDIALOG:
430  RefreshScrubDlg(hwndDlg, true);
431  SetTimer(hwndDlg, 1, 1000, nullptr);
432  break;
433 
434  case WM_COMMAND:
435  switch (HIWORD(wParam)) {
436  case BN_CLICKED:
437  switch (LOWORD(wParam)) {
438  case IDOK:
439  case IDCANCEL:
440  EndDialog(hwndDlg, 0);
441  return true;
442 
443  case IDC_START_SCRUB:
444  StartScrub(hwndDlg);
445  return true;
446 
447  case IDC_PAUSE_SCRUB:
448  PauseScrub(hwndDlg);
449  return true;
450 
451  case IDC_CANCEL_SCRUB:
452  StopScrub(hwndDlg);
453  return true;
454  }
455  break;
456  }
457  break;
458 
459  case WM_TIMER:
460  RefreshScrubDlg(hwndDlg, false);
461  break;
462  }
463  } catch (const exception& e) {
464  error_message(hwndDlg, e.what());
465  }
466 
467  return false;
468 }
469 
471  BtrfsScrub* bs;
472 
473  if (uMsg == WM_INITDIALOG) {
475  bs = (BtrfsScrub*)lParam;
476  } else {
478  }
479 
480  if (bs)
481  return bs->ScrubDlgProc(hwndDlg, uMsg, wParam, lParam);
482  else
483  return false;
484 }
485 
486 #ifdef __REACTOS__
487 extern "C" {
488 #endif
489 
490 void CALLBACK ShowScrubW(HWND hwnd, HINSTANCE hinst, LPWSTR lpszCmdLine, int nCmdShow) {
491  try {
494  LUID luid;
495 
497  throw last_error(GetLastError());
498 
499  if (!LookupPrivilegeValueW(nullptr, L"SeManageVolumePrivilege", &luid))
500  throw last_error(GetLastError());
501 
502  tp.PrivilegeCount = 1;
503  tp.Privileges[0].Luid = luid;
504  tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
505 
506  if (!AdjustTokenPrivileges(token, false, &tp, sizeof(TOKEN_PRIVILEGES), nullptr, nullptr))
507  throw last_error(GetLastError());
508 
509  set_dpi_aware();
510 
511  BtrfsScrub scrub(lpszCmdLine);
512 
514  } catch (const exception& e) {
515  error_message(hwnd, e.what());
516  }
517 }
518 
519 void CALLBACK StartScrubW(HWND hwnd, HINSTANCE hinst, LPWSTR lpszCmdLine, int nCmdShow) {
521 
522  command_line_to_args(lpszCmdLine, args);
523 
524  if (args.size() >= 1) {
525  LUID luid;
527 
528  {
530 
532  return;
533 
534  if (!LookupPrivilegeValueW(nullptr, L"SeManageVolumePrivilege", &luid))
535  return;
536 
537  tp.PrivilegeCount = 1;
538  tp.Privileges[0].Luid = luid;
539  tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
540 
541  if (!AdjustTokenPrivileges(token, false, &tp, sizeof(TOKEN_PRIVILEGES), nullptr, nullptr))
542  return;
543  }
544 
547  if (h != INVALID_HANDLE_VALUE) {
549 
550  NtFsControlFile(h, nullptr, nullptr, nullptr, &iosb, FSCTL_BTRFS_START_SCRUB, nullptr, 0, nullptr, 0);
551  }
552  }
553 }
554 
555 void CALLBACK StopScrubW(HWND hwnd, HINSTANCE hinst, LPWSTR lpszCmdLine, int nCmdShow) {
557 
558  command_line_to_args(lpszCmdLine, args);
559 
560  if (args.size() >= 1) {
561  LUID luid;
563 
564  {
566 
568  return;
569 
570  if (!LookupPrivilegeValueW(nullptr, L"SeManageVolumePrivilege", &luid))
571  return;
572 
573  tp.PrivilegeCount = 1;
574  tp.Privileges[0].Luid = luid;
575  tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
576 
577  if (!AdjustTokenPrivileges(token, false, &tp, sizeof(TOKEN_PRIVILEGES), nullptr, nullptr))
578  return;
579  }
580 
583  if (h != INVALID_HANDLE_VALUE) {
585 
586  NtFsControlFile(h, nullptr, nullptr, nullptr, &iosb, FSCTL_BTRFS_STOP_SCRUB, nullptr, 0, nullptr, 0);
587  }
588  }
589 }
590 
591 #ifdef __REACTOS__
592 } /* extern "C" */
593 #endif
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
#define FSCTL_BTRFS_QUERY_BALANCE
Definition: btrfsioctl.h:16
btrfs_scrub_error errors
Definition: btrfsioctl.h:246
void CALLBACK StartScrubW(HWND hwnd, HINSTANCE hinst, LPWSTR lpszCmdLine, int nCmdShow)
Definition: scrub.cpp:519
static PIO_STATUS_BLOCK iosb
Definition: file.c:98
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
Definition: tftpd.h:59
#define PBM_SETRANGE32
Definition: commctrl.h:2158
void StartScrub(HWND hwndDlg)
Definition: scrub.cpp:356
#define BTRFS_SCRUB_STOPPED
Definition: btrfsioctl.h:208
#define IDOK
Definition: winuser.h:824
BOOL WINAPI LookupPrivilegeValueW(LPCWSTR lpSystemName, LPCWSTR lpPrivilegeName, PLUID lpLuid)
Definition: misc.c:782
#define IDC_SCRUB_PROGRESS
Definition: resource.h:314
LARGE_INTEGER start_time
Definition: btrfsioctl.h:238
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
#define IDS_SCRUB_MSG_STARTED
Definition: resource.h:107
#define IDS_SCRUB_MSG_RECOVERABLE_DATA
Definition: resource.h:108
void StopScrub(HWND hwndDlg)
Definition: scrub.cpp:410
#define BTRFS_SCRUB_PAUSED
Definition: btrfsioctl.h:210
#define IDS_SCRUB_MSG_UNRECOVERABLE_DATA_SUBVOL
Definition: resource.h:111
INT_PTR CALLBACK ScrubDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: scrub.cpp:426
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define IDD_SCRUB
Definition: resource.h:82
#define LOCALE_USER_DEFAULT
#define DATE_SHORTDATE
Definition: winnls.h:193
#define free
Definition: debug_ros.c:5
#define IDS_SCRUB_MSG_UNRECOVERABLE_METADATA_FIRSTITEM
Definition: resource.h:113
LONG NTSTATUS
Definition: precomp.h:26
GLenum GLuint GLenum GLsizei const GLchar * message
Definition: glext.h:5579
#define CALLBACK
Definition: compat.h:27
void RefreshScrubDlg(HWND hwndDlg, bool first_time)
Definition: scrub.cpp:267
#define IDS_SCRUB_MSG_UNRECOVERABLE_DATA
Definition: resource.h:110
GLdouble GLdouble t
Definition: gl.h:2047
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define PBM_SETPOS
Definition: commctrl.h:2154
NTSYSCALLAPI NTSTATUS NTAPI NtFsControlFile(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, ULONG FsControlCode, PVOID InputBuffer, ULONG InputBufferLength, PVOID OutputBuffer, ULONG OutputBufferLength)
#define IDC_CANCEL_SCRUB
Definition: resource.h:313
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
wstring fn
Definition: scrub.h:44
_In_ UINT64 _In_ UINT64 _In_ UINT64 _In_opt_ traverse_ptr * tp
Definition: btrfs.c:2645
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
int32_t INT_PTR
Definition: typedefs.h:62
#define IDS_SCRUB_MSG_UNRECOVERABLE_METADATA
Definition: resource.h:112
void CALLBACK StopScrubW(HWND hwnd, HINSTANCE hinst, LPWSTR lpszCmdLine, int nCmdShow)
Definition: scrub.cpp:555
uint32_t num_errors
Definition: scrub.h:47
#define BTRFS_BALANCE_RUNNING
Definition: btrfsioctl.h:174
Definition: match.c:390
#define SetWindowLongPtr
Definition: treelist.c:70
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
#define FILE_SHARE_READ
Definition: compat.h:125
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
UINT_PTR WPARAM
Definition: windef.h:207
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
struct btrfs_scrub_error::@616::@618 data
BOOL WINAPI SystemTimeToTzSpecificLocalTime(CONST TIME_ZONE_INFORMATION *lpTimeZoneInformation, CONST SYSTEMTIME *lpUniversalTime, LPSYSTEMTIME lpLocalTime)
Definition: timezone.c:377
#define FILE_TRAVERSE
Definition: nt_native.h:643
#define SE_PRIVILEGE_ENABLED
Definition: setypes.h:63
void error_message(HWND hwnd, const char *msg)
Definition: main.cpp:738
struct btrfs_scrub_error::@616::@619 metadata
#define IDS_SCRUB_FAILED
Definition: resource.h:120
#define IDS_SCRUB_MSG_SUMMARY_ERRORS_UNRECOVERABLE
Definition: resource.h:119
#define e
Definition: ke_i.h:82
LONG_PTR LPARAM
Definition: windef.h:208
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat token
Definition: glfuncs.h:210
#define GWLP_USERDATA
Definition: treelist.c:63
#define IDS_SCRUB_MSG_SUMMARY_ERRORS_RECOVERABLE
Definition: resource.h:118
#define IDS_SCRUB_RUNNING
Definition: resource.h:104
#define IDC_SCRUB_INFO
Definition: resource.h:308
#define FSCTL_BTRFS_PAUSE_SCRUB
Definition: btrfsioctl.h:26
#define IDS_SCRUB_PAUSED
Definition: resource.h:106
#define OPEN_EXISTING
Definition: compat.h:426
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
void wstring_sprintf(wstring &s, wstring fmt,...)
Definition: main.cpp:225
void PauseScrub(HWND hwndDlg)
Definition: scrub.cpp:384
BOOL WINAPI FileTimeToSystemTime(IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:178
#define IDS_NO_SCRUB
Definition: resource.h:103
#define FSCTL_BTRFS_RESUME_SCRUB
Definition: btrfsioctl.h:27
#define TOKEN_QUERY
Definition: setypes.h:874
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
#define WM_TIMER
Definition: winuser.h:1718
#define FSCTL_BTRFS_QUERY_SCRUB
Definition: btrfsioctl.h:25
HANDLE WINAPI GetCurrentProcess(VOID)
Definition: proc.c:1168
UINT64 data_scrubbed
Definition: btrfsioctl.h:242
unsigned int UINT
Definition: ndis.h:50
#define BN_CLICKED
Definition: winuser.h:1886
#define IDC_START_SCRUB
Definition: resource.h:310
void UpdateTextBox(HWND hwndDlg, btrfs_query_scrub *bqs)
Definition: scrub.cpp:45
#define FSCTL_BTRFS_START_SCRUB
Definition: btrfsioctl.h:24
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
static const WCHAR L[]
Definition: oid.c:1087
ULONG LowPart
Definition: typedefs.h:104
GLenum GLsizei len
Definition: glext.h:6722
GLdouble s
Definition: gl.h:2039
Definition: time.h:76
#define WM_COMMAND
Definition: winuser.h:1716
#define IDC_SCRUB_STATUS
Definition: resource.h:315
BYTE uint8_t
Definition: msvideo1.c:66
BOOL WINAPI AdjustTokenPrivileges(HANDLE TokenHandle, BOOL DisableAllPrivileges, PTOKEN_PRIVILEGES NewState, DWORD BufferLength, PTOKEN_PRIVILEGES PreviousState, PDWORD ReturnLength)
Definition: security.c:376
INT WINAPI GetDateFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpDateStr, INT cchOut)
Definition: lcformat.c:916
Status
Definition: gdiplustypes.h:24
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define IDS_SCRUB_MSG_RECOVERABLE_PARITY
Definition: resource.h:122
UINT64 uint64_t
Definition: types.h:77
#define FSCTL_BTRFS_STOP_SCRUB
Definition: btrfsioctl.h:28
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LARGE_INTEGER finish_time
Definition: btrfsioctl.h:239
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:296
#define IDS_SCRUB_MSG_FINISHED
Definition: resource.h:114
static int load_string(HINSTANCE hModule, UINT resId, LPWSTR pwszBuffer, INT cMaxChars)
Definition: muireg.c:10
uint64_t chunks_left
Definition: scrub.h:46
#define CreateFileW
Definition: compat.h:400
#define IDC_PAUSE_SCRUB
Definition: resource.h:312
#define IDS_SCRUB_BALANCE_RUNNING
Definition: resource.h:117
#define FILE_FLAG_BACKUP_SEMANTICS
Definition: disk.h:41
#define FILE_FLAG_OPEN_REPARSE_POINT
Definition: disk.h:39
#define HIWORD(l)
Definition: typedefs.h:246
unsigned int ULONG
Definition: retypes.h:1
static HINSTANCE hinst
Definition: edit.c:551
#define malloc
Definition: debug_ros.c:4
static INT_PTR CALLBACK stub_ScrubDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: scrub.cpp:470
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define GetWindowLongPtr
Definition: treelist.c:73
#define IDS_SCRUB_FINISHED
Definition: resource.h:105
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define IDCANCEL
Definition: winuser.h:825
#define IDS_SCRUB_MSG_RECOVERABLE_METADATA
Definition: resource.h:109
#define BTRFS_BALANCE_PAUSED
Definition: btrfsioctl.h:175
static struct msdos_boot_sector bs
Definition: mkdosfs.c:539
return STATUS_SUCCESS
Definition: btrfs.c:2725
INT WINAPI GetTimeFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpTimeStr, INT cchOut)
Definition: lcformat.c:1016
#define TOKEN_ADJUST_PRIVILEGES
Definition: setypes.h:876
#define args
Definition: format.c:66
void set_dpi_aware()
Definition: main.cpp:50
void CALLBACK ShowScrubW(HWND hwnd, HINSTANCE hinst, LPWSTR lpszCmdLine, int nCmdShow)
Definition: scrub.cpp:490
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define IDS_SCRUB_MSG_SUMMARY
Definition: resource.h:115
LONGLONG QuadPart
Definition: typedefs.h:112
#define STATUS_DEVICE_NOT_READY
Definition: shellext.h:65
void command_line_to_args(LPWSTR cmdline, vector< wstring > args)
Definition: main.cpp:610
void format_size(uint64_t size, wstring &s, bool show_bytes)
Definition: main.cpp:65
Definition: ps.c:97