ReactOS  0.4.14-dev-599-g2d4d3f5
BtrfsScrub Class Reference

#include <scrub.h>

Public Member Functions

 BtrfsScrub (const wstring &drive)
 
INT_PTR CALLBACK ScrubDlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Private Member Functions

void RefreshScrubDlg (HWND hwndDlg, bool first_time)
 
void UpdateTextBox (HWND hwndDlg, btrfs_query_scrub *bqs)
 
void StartScrub (HWND hwndDlg)
 
void PauseScrub (HWND hwndDlg)
 
void StopScrub (HWND hwndDlg)
 

Private Attributes

wstring fn
 
uint32_t status
 
uint64_t chunks_left
 
uint32_t num_errors
 

Detailed Description

Definition at line 29 of file scrub.h.

Constructor & Destructor Documentation

◆ BtrfsScrub()

BtrfsScrub::BtrfsScrub ( const wstring &  drive)
inline

Definition at line 31 of file scrub.h.

31  {
32  fn = drive;
33  }
wstring fn
Definition: scrub.h:44
static char drive[2]
Definition: batch.c:28

Member Function Documentation

◆ PauseScrub()

void BtrfsScrub::PauseScrub ( HWND  hwndDlg)
private

Definition at line 384 of file scrub.cpp.

384  {
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 }
static PIO_STATUS_BLOCK iosb
Definition: file.c:98
#define BTRFS_SCRUB_PAUSED
Definition: btrfsioctl.h:196
LONG NTSTATUS
Definition: precomp.h:26
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
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)
wstring fn
Definition: scrub.h:44
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_SHARE_READ
Definition: compat.h:125
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define FILE_TRAVERSE
Definition: nt_native.h:643
#define FSCTL_BTRFS_PAUSE_SCRUB
Definition: btrfsioctl.h:25
#define OPEN_EXISTING
Definition: compat.h:434
#define FSCTL_BTRFS_RESUME_SCRUB
Definition: btrfsioctl.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define FSCTL_BTRFS_QUERY_SCRUB
Definition: btrfsioctl.h:24
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
Status
Definition: gdiplustypes.h:24
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define CreateFileW
Definition: compat.h:408
#define FILE_FLAG_BACKUP_SEMANTICS
Definition: disk.h:41
#define FILE_FLAG_OPEN_REPARSE_POINT
Definition: disk.h:39

Referenced by ScrubDlgProc().

◆ RefreshScrubDlg()

void BtrfsScrub::RefreshScrubDlg ( HWND  hwndDlg,
bool  first_time 
)
private

Definition at line 267 of file scrub.cpp.

267  {
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 }
static PIO_STATUS_BLOCK iosb
Definition: file.c:98
#define PBM_SETRANGE32
Definition: commctrl.h:2184
#define BTRFS_SCRUB_STOPPED
Definition: btrfsioctl.h:194
#define IDC_SCRUB_PROGRESS
Definition: resource.h:312
#define BTRFS_SCRUB_PAUSED
Definition: btrfsioctl.h:196
uint64_t total_chunks
Definition: btrfsioctl.h:227
uint32_t num_errors
Definition: btrfsioctl.h:231
LONG NTSTATUS
Definition: precomp.h:26
GLdouble GLdouble t
Definition: gl.h:2047
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define PBM_SETPOS
Definition: commctrl.h:2180
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:311
wstring fn
Definition: scrub.h:44
UINT_PTR WPARAM
Definition: windef.h:207
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
uint32_t num_errors
Definition: scrub.h:47
#define FILE_SHARE_READ
Definition: compat.h:125
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
#define FILE_TRAVERSE
Definition: nt_native.h:643
#define IDS_SCRUB_FAILED
Definition: resource.h:121
#define IDS_SCRUB_RUNNING
Definition: resource.h:105
LONG_PTR LPARAM
Definition: windef.h:208
#define IDS_SCRUB_PAUSED
Definition: resource.h:107
#define OPEN_EXISTING
Definition: compat.h:434
void wstring_sprintf(wstring &s, wstring fmt,...)
Definition: main.cpp:225
#define IDS_NO_SCRUB
Definition: resource.h:104
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define FSCTL_BTRFS_QUERY_SCRUB
Definition: btrfsioctl.h:24
#define IDC_START_SCRUB
Definition: resource.h:308
void UpdateTextBox(HWND hwndDlg, btrfs_query_scrub *bqs)
Definition: scrub.cpp:45
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
GLdouble s
Definition: gl.h:2039
#define IDC_SCRUB_STATUS
Definition: resource.h:313
Status
Definition: gdiplustypes.h:24
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
static float(__cdecl *square_half_float)(float x
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
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:408
#define IDC_PAUSE_SCRUB
Definition: resource.h:310
#define FILE_FLAG_BACKUP_SEMANTICS
Definition: disk.h:41
#define FILE_FLAG_OPEN_REPARSE_POINT
Definition: disk.h:39
uint64_t chunks_left
Definition: btrfsioctl.h:226
#define IDS_SCRUB_FINISHED
Definition: resource.h:106
return STATUS_SUCCESS
Definition: btrfs.c:2938
Definition: ps.c:97

Referenced by ScrubDlgProc(), and StartScrub().

◆ ScrubDlgProc()

INT_PTR CALLBACK BtrfsScrub::ScrubDlgProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 426 of file scrub.cpp.

426  {
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 }
void StartScrub(HWND hwndDlg)
Definition: scrub.cpp:356
#define IDOK
Definition: winuser.h:824
void StopScrub(HWND hwndDlg)
Definition: scrub.cpp:410
void RefreshScrubDlg(HWND hwndDlg, bool first_time)
Definition: scrub.cpp:267
#define IDC_CANCEL_SCRUB
Definition: resource.h:311
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
void error_message(HWND hwnd, const char *msg)
Definition: main.cpp:785
#define e
Definition: ke_i.h:82
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
void PauseScrub(HWND hwndDlg)
Definition: scrub.cpp:384
#define WM_TIMER
Definition: winuser.h:1724
#define BN_CLICKED
Definition: winuser.h:1907
#define IDC_START_SCRUB
Definition: resource.h:308
#define WM_COMMAND
Definition: winuser.h:1722
#define IDC_PAUSE_SCRUB
Definition: resource.h:310
#define HIWORD(l)
Definition: typedefs.h:246
#define IDCANCEL
Definition: winuser.h:825
#define WM_INITDIALOG
Definition: winuser.h:1721
#define LOWORD(l)
Definition: pedump.c:82

◆ StartScrub()

void BtrfsScrub::StartScrub ( HWND  hwndDlg)
private

Definition at line 356 of file scrub.cpp.

356  {
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 }
#define FSCTL_BTRFS_QUERY_BALANCE
Definition: btrfsioctl.h:15
static PIO_STATUS_BLOCK iosb
Definition: file.c:98
LONG NTSTATUS
Definition: precomp.h:26
void RefreshScrubDlg(HWND hwndDlg, bool first_time)
Definition: scrub.cpp:267
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
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)
wstring fn
Definition: scrub.h:44
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define BTRFS_BALANCE_RUNNING
Definition: btrfsioctl.h:160
#define FILE_SHARE_READ
Definition: compat.h:125
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define FILE_TRAVERSE
Definition: nt_native.h:643
#define OPEN_EXISTING
Definition: compat.h:434
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define FSCTL_BTRFS_START_SCRUB
Definition: btrfsioctl.h:23
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
Status
Definition: gdiplustypes.h:24
#define CreateFileW
Definition: compat.h:408
#define IDS_SCRUB_BALANCE_RUNNING
Definition: resource.h:118
#define FILE_FLAG_BACKUP_SEMANTICS
Definition: disk.h:41
#define FILE_FLAG_OPEN_REPARSE_POINT
Definition: disk.h:39
#define BTRFS_BALANCE_PAUSED
Definition: btrfsioctl.h:161
#define STATUS_DEVICE_NOT_READY
Definition: shellext.h:70

Referenced by ScrubDlgProc().

◆ StopScrub()

void BtrfsScrub::StopScrub ( HWND  hwndDlg)
private

Definition at line 410 of file scrub.cpp.

410  {
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 }
static PIO_STATUS_BLOCK iosb
Definition: file.c:98
LONG NTSTATUS
Definition: precomp.h:26
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
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)
wstring fn
Definition: scrub.h:44
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_SHARE_READ
Definition: compat.h:125
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define FILE_TRAVERSE
Definition: nt_native.h:643
#define OPEN_EXISTING
Definition: compat.h:434
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
Status
Definition: gdiplustypes.h:24
#define FSCTL_BTRFS_STOP_SCRUB
Definition: btrfsioctl.h:27
#define CreateFileW
Definition: compat.h:408
#define FILE_FLAG_BACKUP_SEMANTICS
Definition: disk.h:41
#define FILE_FLAG_OPEN_REPARSE_POINT
Definition: disk.h:39

Referenced by ScrubDlgProc().

◆ UpdateTextBox()

void BtrfsScrub::UpdateTextBox ( HWND  hwndDlg,
btrfs_query_scrub bqs 
)
private

Definition at line 45 of file scrub.cpp.

45  {
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 }
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
btrfs_scrub_error errors
Definition: btrfsioctl.h:232
static PIO_STATUS_BLOCK iosb
Definition: file.c:98
uint32_t next_entry
Definition: btrfsioctl.h:199
Definition: tftpd.h:59
LARGE_INTEGER start_time
Definition: btrfsioctl.h:224
#define IDS_SCRUB_MSG_STARTED
Definition: resource.h:108
#define IDS_SCRUB_MSG_RECOVERABLE_DATA
Definition: resource.h:109
#define IDS_SCRUB_MSG_UNRECOVERABLE_DATA_SUBVOL
Definition: resource.h:112
uint64_t data_scrubbed
Definition: btrfsioctl.h:228
uint32_t num_errors
Definition: btrfsioctl.h:231
#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:114
LONG NTSTATUS
Definition: precomp.h:26
GLenum GLuint GLenum GLsizei const GLchar * message
Definition: glext.h:5579
#define IDS_SCRUB_MSG_UNRECOVERABLE_DATA
Definition: resource.h:111
GLdouble GLdouble t
Definition: gl.h:2047
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
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)
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
wstring fn
Definition: scrub.h:44
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
struct btrfs_scrub_error::@639::@642 metadata
#define IDS_SCRUB_MSG_UNRECOVERABLE_METADATA
Definition: resource.h:113
#define FILE_SHARE_READ
Definition: compat.h:125
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
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
uint64_t address
Definition: btrfsioctl.h:200
#define IDS_SCRUB_MSG_SUMMARY_ERRORS_UNRECOVERABLE
Definition: resource.h:120
#define IDS_SCRUB_MSG_SUMMARY_ERRORS_RECOVERABLE
Definition: resource.h:119
#define IDC_SCRUB_INFO
Definition: resource.h:306
#define OPEN_EXISTING
Definition: compat.h:434
void wstring_sprintf(wstring &s, wstring fmt,...)
Definition: main.cpp:225
BOOL WINAPI FileTimeToSystemTime(IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:188
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
uint64_t duration
Definition: btrfsioctl.h:229
#define FSCTL_BTRFS_QUERY_SCRUB
Definition: btrfsioctl.h:24
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
static const WCHAR L[]
Definition: oid.c:1250
ULONG LowPart
Definition: typedefs.h:104
GLenum GLsizei len
Definition: glext.h:6722
GLdouble s
Definition: gl.h:2039
Definition: time.h:76
BYTE uint8_t
Definition: msvideo1.c:66
INT WINAPI GetDateFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpDateStr, INT cchOut)
Definition: lcformat.c:979
Status
Definition: gdiplustypes.h:24
#define IDS_SCRUB_MSG_RECOVERABLE_PARITY
Definition: resource.h:123
UINT64 uint64_t
Definition: types.h:77
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
static float(__cdecl *square_half_float)(float x
struct btrfs_scrub_error::@639::@641 data
LARGE_INTEGER finish_time
Definition: btrfsioctl.h:225
#define IDS_SCRUB_MSG_FINISHED
Definition: resource.h:115
static int load_string(HINSTANCE hModule, UINT resId, LPWSTR pwszBuffer, INT cMaxChars)
Definition: muireg.c:10
#define CreateFileW
Definition: compat.h:408
#define FILE_FLAG_BACKUP_SEMANTICS
Definition: disk.h:41
#define FILE_FLAG_OPEN_REPARSE_POINT
Definition: disk.h:39
unsigned int ULONG
Definition: retypes.h:1
#define malloc
Definition: debug_ros.c:4
#define IDS_SCRUB_MSG_RECOVERABLE_METADATA
Definition: resource.h:110
INT WINAPI GetTimeFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpTimeStr, INT cchOut)
Definition: lcformat.c:1079
#define IDS_SCRUB_MSG_SUMMARY
Definition: resource.h:116
LONGLONG QuadPart
Definition: typedefs.h:112
void format_size(uint64_t size, wstring &s, bool show_bytes)
Definition: main.cpp:65

Referenced by RefreshScrubDlg().

Member Data Documentation

◆ chunks_left

uint64_t BtrfsScrub::chunks_left
private

Definition at line 46 of file scrub.h.

Referenced by RefreshScrubDlg().

◆ fn

wstring BtrfsScrub::fn
private

Definition at line 44 of file scrub.h.

Referenced by BtrfsScrub(), PauseScrub(), RefreshScrubDlg(), StartScrub(), StopScrub(), and UpdateTextBox().

◆ num_errors

uint32_t BtrfsScrub::num_errors
private

Definition at line 47 of file scrub.h.

Referenced by RefreshScrubDlg().

◆ status

uint32_t BtrfsScrub::status
private

Definition at line 45 of file scrub.h.


The documentation for this class was generated from the following files: