ReactOS 0.4.15-dev-5669-g09dde2c
BtrfsBalance Class Reference

#include <balance.h>

Collaboration diagram for BtrfsBalance:

Public Member Functions

 BtrfsBalance (const wstring &drive, bool RemoveDevice=false, bool ShrinkDevice=false)
 
void ShowBalance (HWND hwndDlg)
 
INT_PTR CALLBACK BalanceDlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
INT_PTR CALLBACK BalanceOptsDlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Private Member Functions

void ShowBalanceOptions (HWND hwndDlg, uint8_t type)
 
void SaveBalanceOpts (HWND hwndDlg)
 
void StartBalance (HWND hwndDlg)
 
void RefreshBalanceDlg (HWND hwndDlg, bool first)
 
void PauseBalance (HWND hwndDlg)
 
void StopBalance (HWND hwndDlg)
 

Private Attributes

uint32_t balance_status
 
btrfs_balance_opts data_opts
 
btrfs_balance_opts metadata_opts
 
btrfs_balance_opts system_opts
 
uint8_t opts_type
 
btrfs_query_balance bqb
 
bool cancelling
 
bool removing
 
bool shrinking
 
wstring fn
 
btrfs_devicedevices
 
bool readonly
 
bool called_from_RemoveDevice
 
bool called_from_ShrinkDevice
 

Detailed Description

Definition at line 27 of file balance.h.

Constructor & Destructor Documentation

◆ BtrfsBalance()

BtrfsBalance::BtrfsBalance ( const wstring &  drive,
bool  RemoveDevice = false,
bool  ShrinkDevice = false 
)
inline

Definition at line 29 of file balance.h.

29 {
30 removing = false;
31 devices = nullptr;
32 called_from_RemoveDevice = RemoveDevice;
33 called_from_ShrinkDevice = ShrinkDevice;
34 fn = drive;
35 }
btrfs_device * devices
Definition: balance.h:57
bool called_from_ShrinkDevice
Definition: balance.h:59
bool removing
Definition: balance.h:54
bool called_from_RemoveDevice
Definition: balance.h:59
wstring fn
Definition: balance.h:56

Member Function Documentation

◆ BalanceDlgProc()

INT_PTR CALLBACK BtrfsBalance::BalanceDlgProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 861 of file balance.cpp.

861 {
862 try {
863 switch (uMsg) {
864 case WM_INITDIALOG:
865 {
867
871
875 cancelling = false;
876 RefreshBalanceDlg(hwndDlg, true);
877
878 if (readonly) {
879 EnableWindow(GetDlgItem(hwndDlg, IDC_START_BALANCE), false);
880 EnableWindow(GetDlgItem(hwndDlg, IDC_PAUSE_BALANCE), false);
882 }
883
887
888 SetTimer(hwndDlg, 1, 1000, nullptr);
889
890 break;
891 }
892
893 case WM_COMMAND:
894 switch (HIWORD(wParam)) {
895 case BN_CLICKED:
896 switch (LOWORD(wParam)) {
897 case IDOK:
898 case IDCANCEL:
899 KillTimer(hwndDlg, 1);
900 EndDialog(hwndDlg, 0);
901 return true;
902
903 case IDC_DATA:
904 EnableWindow(GetDlgItem(hwndDlg, IDC_DATA_OPTIONS), IsDlgButtonChecked(hwndDlg, IDC_DATA) == BST_CHECKED ? true : false);
905
907 IsDlgButtonChecked(hwndDlg, IDC_METADATA) == BST_CHECKED || IsDlgButtonChecked(hwndDlg, IDC_SYSTEM) == BST_CHECKED) ? true: false);
908 return true;
909
910 case IDC_METADATA:
912
914 IsDlgButtonChecked(hwndDlg, IDC_METADATA) == BST_CHECKED || IsDlgButtonChecked(hwndDlg, IDC_SYSTEM) == BST_CHECKED) ? true: false);
915 return true;
916
917 case IDC_SYSTEM:
919
921 IsDlgButtonChecked(hwndDlg, IDC_METADATA) == BST_CHECKED || IsDlgButtonChecked(hwndDlg, IDC_SYSTEM) == BST_CHECKED) ? true: false);
922 return true;
923
924 case IDC_DATA_OPTIONS:
925 ShowBalanceOptions(hwndDlg, 1);
926 return true;
927
929 ShowBalanceOptions(hwndDlg, 2);
930 return true;
931
933 ShowBalanceOptions(hwndDlg, 3);
934 return true;
935
937 StartBalance(hwndDlg);
938 return true;
939
941 PauseBalance(hwndDlg);
942 RefreshBalanceDlg(hwndDlg, false);
943 return true;
944
946 StopBalance(hwndDlg);
947 RefreshBalanceDlg(hwndDlg, false);
948 return true;
949 }
950 break;
951 }
952 break;
953
954 case WM_TIMER:
955 RefreshBalanceDlg(hwndDlg, false);
956 break;
957 }
958 } catch (const exception& e) {
959 error_message(hwndDlg, e.what());
960 }
961
962 return false;
963}
#define BTRFS_BALANCE_STOPPED
Definition: btrfsioctl.h:160
#define BTRFS_BALANCE_RUNNING
Definition: btrfsioctl.h:161
void ShowBalanceOptions(HWND hwndDlg, uint8_t type)
Definition: balance.cpp:856
void StopBalance(HWND hwndDlg)
Definition: balance.cpp:176
void StartBalance(HWND hwndDlg)
Definition: balance.cpp:75
btrfs_balance_opts metadata_opts
Definition: balance.h:50
uint32_t balance_status
Definition: balance.h:49
void RefreshBalanceDlg(HWND hwndDlg, bool first)
Definition: balance.cpp:208
bool shrinking
Definition: balance.h:55
bool cancelling
Definition: balance.h:53
void PauseBalance(HWND hwndDlg)
Definition: balance.cpp:146
bool readonly
Definition: balance.h:58
btrfs_balance_opts system_opts
Definition: balance.h:50
btrfs_balance_opts data_opts
Definition: balance.h:50
WPARAM wParam
Definition: combotst.c:138
void error_message(HWND hwnd, const char *msg)
Definition: main.cpp:783
#define IDC_PAUSE_BALANCE
Definition: resource.h:296
#define IDC_DATA_OPTIONS
Definition: resource.h:273
#define IDC_SYSTEM
Definition: resource.h:270
#define IDC_CANCEL_BALANCE
Definition: resource.h:299
#define IDC_METADATA
Definition: resource.h:268
#define IDC_METADATA_OPTIONS
Definition: resource.h:280
#define IDC_DATA
Definition: resource.h:266
#define IDC_START_BALANCE
Definition: resource.h:293
#define IDC_SYSTEM_OPTIONS
Definition: resource.h:285
#define ETDT_ENABLETAB
Definition: dxdiag.c:30
#define e
Definition: ke_i.h:82
#define LOWORD(l)
Definition: pedump.c:82
#define BCM_SETSHIELD
Definition: commctrl.h:4653
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define HIWORD(l)
Definition: typedefs.h:247
HRESULT WINAPI EnableThemeDialogTexture(_In_ HWND hwnd, _In_ DWORD dwFlags)
Definition: uxthemesupp.c:55
#define IDCANCEL
Definition: winuser.h:825
#define WM_COMMAND
Definition: winuser.h:1730
#define WM_INITDIALOG
Definition: winuser.h:1729
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDOK
Definition: winuser.h:824
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
UINT WINAPI IsDlgButtonChecked(_In_ HWND, _In_ int)
#define WM_TIMER
Definition: winuser.h:1732
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define BN_CLICKED
Definition: winuser.h:1915
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define BST_CHECKED
Definition: winuser.h:197
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by stub_BalanceDlgProc().

◆ BalanceOptsDlgProc()

INT_PTR CALLBACK BtrfsBalance::BalanceOptsDlgProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 514 of file balance.cpp.

514 {
515 try {
516 switch (uMsg) {
517 case WM_INITDIALOG:
518 {
519 HWND devcb, convcb;
520 btrfs_device* bd;
521 btrfs_balance_opts* opts;
523 int i, num_devices = 0, num_writeable_devices = 0;
524 wstring s, u;
525 bool balance_started = balance_status & (BTRFS_BALANCE_RUNNING | BTRFS_BALANCE_PAUSED);
526
527 switch (opts_type) {
528 case 1:
529 opts = balance_started ? &bqb.data_opts : &data_opts;
530 break;
531
532 case 2:
533 opts = balance_started ? &bqb.metadata_opts : &metadata_opts;
534 break;
535
536 case 3:
537 opts = balance_started ? &bqb.system_opts : &system_opts;
538 break;
539
540 default:
541 return true;
542 }
543
545
546 devcb = GetDlgItem(hwndDlg, IDC_DEVID_COMBO);
547
549 throw last_error(GetLastError());
550
551 bd = devices;
552 while (true) {
553 wstring t, v;
554
555 if (bd->device_number == 0xffffffff)
556 s = wstring(bd->name, bd->namelen);
557 else if (bd->partition_number == 0) {
559 throw last_error(GetLastError());
560
562 } else {
564 throw last_error(GetLastError());
565
567 }
568
569 wstring_sprintf(t, u, bd->dev_id, s.c_str());
570
571 SendMessageW(devcb, CB_ADDSTRING, 0, (LPARAM)t.c_str());
572
573 if (opts->devid == bd->dev_id)
574 SendMessageW(devcb, CB_SETCURSEL, num_devices, 0);
575
576 num_devices++;
577
578 if (!bd->readonly)
579 num_writeable_devices++;
580
581 if (bd->next_entry > 0)
582 bd = (btrfs_device*)((uint8_t*)bd + bd->next_entry);
583 else
584 break;
585 }
586
587 convcb = GetDlgItem(hwndDlg, IDC_CONVERT_COMBO);
588
589 if (num_writeable_devices == 0)
590 num_writeable_devices = num_devices;
591
592 i = 0;
593 while (convtypes[i] != 0) {
594 if (!load_string(module, convtypes[i], s))
595 throw last_error(GetLastError());
596
597 SendMessageW(convcb, CB_ADDSTRING, 0, (LPARAM)s.c_str());
598
599 if (opts->convert == convtypes2[i])
600 SendMessageW(convcb, CB_SETCURSEL, i, 0);
601
602 i++;
603
604 if (num_writeable_devices < 2 && i == 2)
605 break;
606 else if (num_writeable_devices < 3 && i == 4)
607 break;
608 else if (num_writeable_devices < 4 && i == 6)
609 break;
610 }
611
612 // profiles
613
624
625 EnableWindow(GetDlgItem(hwndDlg, IDC_PROFILES_SINGLE), !balance_started && opts->flags & BTRFS_BALANCE_OPTS_PROFILES ? true : false);
626 EnableWindow(GetDlgItem(hwndDlg, IDC_PROFILES_DUP), !balance_started && opts->flags & BTRFS_BALANCE_OPTS_PROFILES ? true : false);
627 EnableWindow(GetDlgItem(hwndDlg, IDC_PROFILES_RAID0), !balance_started && opts->flags & BTRFS_BALANCE_OPTS_PROFILES ? true : false);
628 EnableWindow(GetDlgItem(hwndDlg, IDC_PROFILES_RAID1), !balance_started && opts->flags & BTRFS_BALANCE_OPTS_PROFILES ? true : false);
629 EnableWindow(GetDlgItem(hwndDlg, IDC_PROFILES_RAID10), !balance_started && opts->flags & BTRFS_BALANCE_OPTS_PROFILES ? true : false);
630 EnableWindow(GetDlgItem(hwndDlg, IDC_PROFILES_RAID5), !balance_started && opts->flags & BTRFS_BALANCE_OPTS_PROFILES ? true : false);
631 EnableWindow(GetDlgItem(hwndDlg, IDC_PROFILES_RAID6), !balance_started && opts->flags & BTRFS_BALANCE_OPTS_PROFILES ? true : false);
632 EnableWindow(GetDlgItem(hwndDlg, IDC_PROFILES_RAID1C3), !balance_started && opts->flags & BTRFS_BALANCE_OPTS_PROFILES ? true : false);
633 EnableWindow(GetDlgItem(hwndDlg, IDC_PROFILES_RAID1C4), !balance_started && opts->flags & BTRFS_BALANCE_OPTS_PROFILES ? true : false);
634 EnableWindow(GetDlgItem(hwndDlg, IDC_PROFILES), balance_started ? false : true);
635
636 // usage
637
639
640 s = to_wstring(opts->usage_start);
641 SetDlgItemTextW(hwndDlg, IDC_USAGE_START, s.c_str());
643
644 s = to_wstring(opts->usage_end);
645 SetDlgItemTextW(hwndDlg, IDC_USAGE_END, s.c_str());
647
648 EnableWindow(GetDlgItem(hwndDlg, IDC_USAGE_START), !balance_started && opts->flags & BTRFS_BALANCE_OPTS_USAGE ? true : false);
649 EnableWindow(GetDlgItem(hwndDlg, IDC_USAGE_START_SPINNER), !balance_started && opts->flags & BTRFS_BALANCE_OPTS_USAGE ? true : false);
650 EnableWindow(GetDlgItem(hwndDlg, IDC_USAGE_END), !balance_started && opts->flags & BTRFS_BALANCE_OPTS_USAGE ? true : false);
651 EnableWindow(GetDlgItem(hwndDlg, IDC_USAGE_END_SPINNER), !balance_started && opts->flags & BTRFS_BALANCE_OPTS_USAGE ? true : false);
652 EnableWindow(GetDlgItem(hwndDlg, IDC_USAGE), balance_started ? false : true);
653
654 // devid
655
656 if (num_devices < 2 || balance_started)
657 EnableWindow(GetDlgItem(hwndDlg, IDC_DEVID), false);
658
660 EnableWindow(devcb, (opts->flags & BTRFS_BALANCE_OPTS_DEVID && num_devices >= 2 && !balance_started) ? true : false);
661
662 // drange
663
665
666 s = to_wstring(opts->drange_start);
667 SetDlgItemTextW(hwndDlg, IDC_DRANGE_START, s.c_str());
668
669 s = to_wstring(opts->drange_end);
670 SetDlgItemTextW(hwndDlg, IDC_DRANGE_END, s.c_str());
671
672 EnableWindow(GetDlgItem(hwndDlg, IDC_DRANGE_START), !balance_started && opts->flags & BTRFS_BALANCE_OPTS_DRANGE ? true : false);
673 EnableWindow(GetDlgItem(hwndDlg, IDC_DRANGE_END), !balance_started && opts->flags & BTRFS_BALANCE_OPTS_DRANGE ? true : false);
674 EnableWindow(GetDlgItem(hwndDlg, IDC_DRANGE), balance_started ? false : true);
675
676 // vrange
677
679
680 s = to_wstring(opts->vrange_start);
681 SetDlgItemTextW(hwndDlg, IDC_VRANGE_START, s.c_str());
682
683 s = to_wstring(opts->vrange_end);
684 SetDlgItemTextW(hwndDlg, IDC_VRANGE_END, s.c_str());
685
686 EnableWindow(GetDlgItem(hwndDlg, IDC_VRANGE_START), !balance_started && opts->flags & BTRFS_BALANCE_OPTS_VRANGE ? true : false);
687 EnableWindow(GetDlgItem(hwndDlg, IDC_VRANGE_END), !balance_started && opts->flags & BTRFS_BALANCE_OPTS_VRANGE ? true : false);
688 EnableWindow(GetDlgItem(hwndDlg, IDC_VRANGE), balance_started ? false : true);
689
690 // limit
691
693
694 s = to_wstring(opts->limit_start);
695 SetDlgItemTextW(hwndDlg, IDC_LIMIT_START, s.c_str());
697
698 s = to_wstring(opts->limit_end);
699 SetDlgItemTextW(hwndDlg, IDC_LIMIT_END, s.c_str());
701
702 EnableWindow(GetDlgItem(hwndDlg, IDC_LIMIT_START), !balance_started && opts->flags & BTRFS_BALANCE_OPTS_LIMIT ? true : false);
703 EnableWindow(GetDlgItem(hwndDlg, IDC_LIMIT_START_SPINNER), !balance_started && opts->flags & BTRFS_BALANCE_OPTS_LIMIT ? true : false);
704 EnableWindow(GetDlgItem(hwndDlg, IDC_LIMIT_END), !balance_started && opts->flags & BTRFS_BALANCE_OPTS_LIMIT ? true : false);
705 EnableWindow(GetDlgItem(hwndDlg, IDC_LIMIT_END_SPINNER), !balance_started && opts->flags & BTRFS_BALANCE_OPTS_LIMIT ? true : false);
706 EnableWindow(GetDlgItem(hwndDlg, IDC_LIMIT), balance_started ? false : true);
707
708 // stripes
709
711
712 s = to_wstring(opts->stripes_start);
713 SetDlgItemTextW(hwndDlg, IDC_STRIPES_START, s.c_str());
715
716 s = to_wstring(opts->stripes_end);
717 SetDlgItemTextW(hwndDlg, IDC_STRIPES_END, s.c_str());
719
720 EnableWindow(GetDlgItem(hwndDlg, IDC_STRIPES_START), !balance_started && opts->flags & BTRFS_BALANCE_OPTS_STRIPES ? true : false);
721 EnableWindow(GetDlgItem(hwndDlg, IDC_STRIPES_START_SPINNER), !balance_started && opts->flags & BTRFS_BALANCE_OPTS_STRIPES ? true : false);
722 EnableWindow(GetDlgItem(hwndDlg, IDC_STRIPES_END), !balance_started && opts->flags & BTRFS_BALANCE_OPTS_STRIPES ? true : false);
723 EnableWindow(GetDlgItem(hwndDlg, IDC_STRIPES_END_SPINNER), !balance_started && opts->flags & BTRFS_BALANCE_OPTS_STRIPES ? true : false);
724 EnableWindow(GetDlgItem(hwndDlg, IDC_STRIPES), balance_started ? false : true);
725
726 // convert
727
730
731 EnableWindow(GetDlgItem(hwndDlg, IDC_SOFT), !balance_started && opts->flags & BTRFS_BALANCE_OPTS_CONVERT ? true : false);
732 EnableWindow(convcb, !balance_started && opts->flags & BTRFS_BALANCE_OPTS_CONVERT ? true : false);
733 EnableWindow(GetDlgItem(hwndDlg, IDC_CONVERT), balance_started ? false : true);
734
735 break;
736 }
737
738 case WM_COMMAND:
739 switch (HIWORD(wParam)) {
740 case BN_CLICKED:
741 switch (LOWORD(wParam)) {
742 case IDOK:
744 EndDialog(hwndDlg, 0);
745 else
746 SaveBalanceOpts(hwndDlg);
747 return true;
748
749 case IDCANCEL:
750 EndDialog(hwndDlg, 0);
751 return true;
752
753 case IDC_PROFILES: {
754 bool enabled = IsDlgButtonChecked(hwndDlg, IDC_PROFILES) == BST_CHECKED ? true : false;
755
765 break;
766 }
767
768 case IDC_USAGE: {
769 bool enabled = IsDlgButtonChecked(hwndDlg, IDC_USAGE) == BST_CHECKED ? true : false;
770
775 break;
776 }
777
778 case IDC_DEVID: {
779 bool enabled = IsDlgButtonChecked(hwndDlg, IDC_DEVID) == BST_CHECKED ? true : false;
780
782 break;
783 }
784
785 case IDC_DRANGE: {
786 bool enabled = IsDlgButtonChecked(hwndDlg, IDC_DRANGE) == BST_CHECKED ? true : false;
787
790 break;
791 }
792
793 case IDC_VRANGE: {
794 bool enabled = IsDlgButtonChecked(hwndDlg, IDC_VRANGE) == BST_CHECKED ? true : false;
795
798 break;
799 }
800
801 case IDC_LIMIT: {
802 bool enabled = IsDlgButtonChecked(hwndDlg, IDC_LIMIT) == BST_CHECKED ? true : false;
803
808 break;
809 }
810
811 case IDC_STRIPES: {
812 bool enabled = IsDlgButtonChecked(hwndDlg, IDC_STRIPES) == BST_CHECKED ? true : false;
813
818 break;
819 }
820
821 case IDC_CONVERT: {
822 bool enabled = IsDlgButtonChecked(hwndDlg, IDC_CONVERT) == BST_CHECKED ? true : false;
823
826 break;
827 }
828 }
829 break;
830 }
831 break;
832 }
833 } catch (const exception& e) {
834 error_message(hwndDlg, e.what());
835 }
836
837 return false;
838}
static uint64_t convtypes2[]
Definition: balance.cpp:45
#define BTRFS_BALANCE_OPTS_DRANGE
Definition: btrfsioctl.h:133
#define BTRFS_BALANCE_OPTS_SOFT
Definition: btrfsioctl.h:139
#define BTRFS_BALANCE_OPTS_PROFILES
Definition: btrfsioctl.h:131
#define BTRFS_BALANCE_OPTS_VRANGE
Definition: btrfsioctl.h:134
#define BTRFS_BALANCE_OPTS_CONVERT
Definition: btrfsioctl.h:138
#define BLOCK_FLAG_SINGLE
Definition: btrfsioctl.h:141
#define BTRFS_BALANCE_OPTS_DEVID
Definition: btrfsioctl.h:132
#define BTRFS_BALANCE_OPTS_USAGE
Definition: btrfsioctl.h:137
#define BTRFS_BALANCE_OPTS_STRIPES
Definition: btrfsioctl.h:136
#define BTRFS_BALANCE_OPTS_LIMIT
Definition: btrfsioctl.h:135
#define BTRFS_BALANCE_PAUSED
Definition: btrfsioctl.h:162
void SaveBalanceOpts(HWND hwndDlg)
Definition: balance.cpp:356
uint8_t opts_type
Definition: balance.h:51
btrfs_query_balance bqb
Definition: balance.h:52
void wstring_sprintf(wstring &s, wstring fmt,...)
Definition: main.cpp:225
#define IDC_USAGE_END
Definition: resource.h:257
#define IDC_PROFILES_RAID0
Definition: resource.h:246
#define IDC_LIMIT_END_SPINNER
Definition: resource.h:292
#define IDS_DISK_NUM
Definition: resource.h:102
#define IDS_SINGLE2
Definition: resource.h:62
#define IDC_PROFILES_RAID1C3
Definition: resource.h:314
#define IDC_USAGE_START_SPINNER
Definition: resource.h:254
#define IDC_PROFILES_RAID6
Definition: resource.h:252
#define IDS_RAID10
Definition: resource.h:47
#define IDC_LIMIT_END
Definition: resource.h:295
#define IDC_PROFILES
Definition: resource.h:241
#define IDC_PROFILES_RAID1
Definition: resource.h:249
#define IDC_USAGE
Definition: resource.h:253
#define IDC_USAGE_END_SPINNER
Definition: resource.h:256
#define IDC_LIMIT_START
Definition: resource.h:278
#define IDS_RAID1
Definition: resource.h:46
#define IDC_VRANGE_END
Definition: resource.h:283
#define IDC_CONVERT
Definition: resource.h:307
#define IDC_DRANGE_START
Definition: resource.h:260
#define IDS_RAID0
Definition: resource.h:45
#define IDC_VRANGE
Definition: resource.h:269
#define IDC_STRIPES_START
Definition: resource.h:301
#define IDC_STRIPES_START_SPINNER
Definition: resource.h:300
#define IDS_DUP
Definition: resource.h:44
#define IDC_STRIPES_END
Definition: resource.h:305
#define IDC_DEVID_COMBO
Definition: resource.h:259
#define IDC_PROFILES_RAID5
Definition: resource.h:251
#define IDC_STRIPES_END_SPINNER
Definition: resource.h:303
#define IDS_RAID6
Definition: resource.h:49
#define IDC_LIMIT
Definition: resource.h:267
#define IDC_DEVID
Definition: resource.h:258
#define IDC_PROFILES_SINGLE
Definition: resource.h:243
#define IDC_PROFILES_DUP
Definition: resource.h:244
#define IDC_PROFILES_RAID10
Definition: resource.h:250
#define IDC_STRIPES
Definition: resource.h:297
#define IDC_DRANGE
Definition: resource.h:261
#define IDS_RAID5
Definition: resource.h:48
#define IDS_DEVID_LIST
Definition: resource.h:63
#define IDC_VRANGE_START
Definition: resource.h:288
#define IDS_RAID1C3
Definition: resource.h:137
#define IDC_CONVERT_COMBO
Definition: resource.h:309
#define IDS_RAID1C4
Definition: resource.h:149
#define IDC_DRANGE_END
Definition: resource.h:265
#define IDS_DISK_PART_NUM
Definition: resource.h:103
#define IDC_USAGE_START
Definition: resource.h:255
#define IDC_SOFT
Definition: resource.h:311
#define IDC_PROFILES_RAID1C4
Definition: resource.h:316
#define IDC_LIMIT_START_SPINNER
Definition: resource.h:271
#define BLOCK_FLAG_RAID1C4
Definition: btrfs.h:88
#define BLOCK_FLAG_RAID1C3
Definition: btrfs.h:87
const GLdouble * v
Definition: gl.h:2040
GLdouble s
Definition: gl.h:2039
GLdouble GLdouble t
Definition: gl.h:2047
GLenum GLenum GLsizei const GLuint GLboolean enabled
Definition: glext.h:7750
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
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
BYTE uint8_t
Definition: msvideo1.c:66
static int load_string(HINSTANCE hModule, UINT resId, LPWSTR pwszBuffer, INT cMaxChars)
Definition: muireg.c:10
#define true
Definition: osdep.h:36
#define UDM_SETRANGE32
Definition: commctrl.h:2151
#define BLOCK_FLAG_RAID5
Definition: shellext.h:82
#define BLOCK_FLAG_DUPLICATE
Definition: shellext.h:80
#define BLOCK_FLAG_RAID10
Definition: shellext.h:81
#define BLOCK_FLAG_RAID0
Definition: shellext.h:78
#define BLOCK_FLAG_RAID6
Definition: shellext.h:83
#define BLOCK_FLAG_RAID1
Definition: shellext.h:79
uint16_t stripes_start
Definition: btrfsioctl.h:153
uint64_t drange_start
Definition: btrfsioctl.h:147
uint64_t drange_end
Definition: btrfsioctl.h:148
uint64_t limit_start
Definition: btrfsioctl.h:151
uint64_t vrange_start
Definition: btrfsioctl.h:149
uint64_t limit_end
Definition: btrfsioctl.h:152
uint16_t stripes_end
Definition: btrfsioctl.h:154
uint64_t vrange_end
Definition: btrfsioctl.h:150
USHORT namelen
Definition: btrfsioctl.h:112
uint64_t dev_id
Definition: btrfsioctl.h:104
ULONG partition_number
Definition: btrfsioctl.h:110
ULONG device_number
Definition: btrfsioctl.h:109
WCHAR name[1]
Definition: btrfsioctl.h:113
uint32_t next_entry
Definition: btrfsioctl.h:103
btrfs_balance_opts data_opts
Definition: btrfsioctl.h:172
btrfs_balance_opts metadata_opts
Definition: btrfsioctl.h:173
btrfs_balance_opts system_opts
Definition: btrfsioctl.h:174
DWORD WINAPI GetLastError(void)
Definition: except.c:1040
LONG_PTR LPARAM
Definition: windef.h:208
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)
#define BST_UNCHECKED
Definition: winuser.h:199
#define CB_SETCURSEL
Definition: winuser.h:1951
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
#define CB_ADDSTRING
Definition: winuser.h:1926

Referenced by stub_BalanceOptsDlgProc().

◆ PauseBalance()

void BtrfsBalance::PauseBalance ( HWND  hwndDlg)
private

Definition at line 146 of file balance.cpp.

146 {
147 WCHAR modfn[MAX_PATH];
148 wstring t;
150
151 GetModuleFileNameW(module, modfn, sizeof(modfn) / sizeof(WCHAR));
152
153#ifndef __REACTOS__
154 t = L"\""s + modfn + L"\",PauseBalance " + fn;
155#else
156 t = wstring(L"\"") + modfn + wstring(L"\",PauseBalance ") + fn;
157#endif
158
159 RtlZeroMemory(&sei, sizeof(sei));
160
161 sei.cbSize = sizeof(sei);
162 sei.hwnd = hwndDlg;
163 sei.lpVerb = L"runas";
164 sei.lpFile = L"rundll32.exe";
165 sei.lpParameters = t.c_str();
166 sei.nShow = SW_SHOW;
168
169 if (!ShellExecuteExW(&sei))
170 throw last_error(GetLastError());
171
174}
#define CloseHandle
Definition: compat.h:739
#define MAX_PATH
Definition: compat.h:34
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
#define INFINITE
Definition: serial.h:102
#define L(x)
Definition: ntvdm.h:50
#define SEE_MASK_NOCLOSEPROCESS
Definition: shellapi.h:31
BOOL WINAPI DECLSPEC_HOTPATCH ShellExecuteExW(LPSHELLEXECUTEINFOW sei)
Definition: shlexec.cpp:2335
LPCWSTR lpParameters
Definition: shellapi.h:330
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define SW_SHOW
Definition: winuser.h:769
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by BalanceDlgProc().

◆ RefreshBalanceDlg()

void BtrfsBalance::RefreshBalanceDlg ( HWND  hwndDlg,
bool  first 
)
private

Definition at line 208 of file balance.cpp.

208 {
209 bool balancing = false;
210 wstring s, t;
211
212 {
215
216 if (h != INVALID_HANDLE_VALUE) {
219
220 Status = NtFsControlFile(h, nullptr, nullptr, nullptr, &iosb, FSCTL_BTRFS_QUERY_BALANCE, nullptr, 0, &bqb, sizeof(btrfs_query_balance));
221
222 if (!NT_SUCCESS(Status))
223 throw ntstatus_error(Status);
224 } else
225 throw last_error(GetLastError());
226 }
227
228 if (cancelling)
230
232
233 if (!balancing) {
235 int resid;
236
237 EnableWindow(GetDlgItem(hwndDlg, IDC_PAUSE_BALANCE), false);
239 SendMessageW(GetDlgItem(hwndDlg, IDC_BALANCE_PROGRESS), PBM_SETSTATE, PBST_NORMAL, 0);
241 EnableWindow(GetDlgItem(hwndDlg, IDC_DATA), true);
242 EnableWindow(GetDlgItem(hwndDlg, IDC_METADATA), true);
243 EnableWindow(GetDlgItem(hwndDlg, IDC_SYSTEM), true);
244
249
251 }
252
253 EnableWindow(GetDlgItem(hwndDlg, IDC_DATA_OPTIONS), IsDlgButtonChecked(hwndDlg, IDC_DATA) == BST_CHECKED ? true : false);
256
258 if (removing)
260 else if (shrinking)
262 else
263 resid = IDS_BALANCE_FAILED;
264
265 if (!load_string(module, resid, s))
266 throw last_error(GetLastError());
267
269
270 SetDlgItemTextW(hwndDlg, IDC_BALANCE_STATUS, t.c_str());
271 } else {
272 if (cancelling)
276 else
277 resid = IDS_NO_BALANCE;
278
279 if (!load_string(module, resid, s))
280 throw last_error(GetLastError());
281
282 SetDlgItemTextW(hwndDlg, IDC_BALANCE_STATUS, s.c_str());
283 }
284
286 IsDlgButtonChecked(hwndDlg, IDC_METADATA) == BST_CHECKED || IsDlgButtonChecked(hwndDlg, IDC_SYSTEM) == BST_CHECKED) ? true: false);
287
289 cancelling = false;
290 }
291
292 return;
293 }
294
299 EnableWindow(GetDlgItem(hwndDlg, IDC_DATA), false);
300 EnableWindow(GetDlgItem(hwndDlg, IDC_METADATA), false);
301 EnableWindow(GetDlgItem(hwndDlg, IDC_SYSTEM), false);
302
306
310
311 EnableWindow(GetDlgItem(hwndDlg, IDC_START_BALANCE), false);
312 }
313
316
318 SendMessageW(GetDlgItem(hwndDlg, IDC_BALANCE_PROGRESS), PBM_SETSTATE, PBST_PAUSED, 0);
320 SendMessageW(GetDlgItem(hwndDlg, IDC_BALANCE_PROGRESS), PBM_SETSTATE, PBST_NORMAL, 0);
321
323
326 throw last_error(GetLastError());
327
329 (float)(bqb.total_chunks - bqb.chunks_left) * 100.0f / (float)bqb.total_chunks);
330
331 removing = true;
332 shrinking = false;
333 } else if (bqb.status & BTRFS_BALANCE_SHRINKING) {
335 throw last_error(GetLastError());
336
338 (float)(bqb.total_chunks - bqb.chunks_left) * 100.0f / (float)bqb.total_chunks);
339
340 removing = false;
341 shrinking = true;
342 } else {
344 throw last_error(GetLastError());
345
347 (float)(bqb.total_chunks - bqb.chunks_left) * 100.0f / (float)bqb.total_chunks);
348
349 removing = false;
350 shrinking = false;
351 }
352
353 SetDlgItemTextW(hwndDlg, IDC_BALANCE_STATUS, t.c_str());
354}
LONG NTSTATUS
Definition: precomp.h:26
#define BTRFS_BALANCE_OPTS_ENABLED
Definition: btrfsioctl.h:130
#define FSCTL_BTRFS_QUERY_BALANCE
Definition: btrfsioctl.h:15
#define BTRFS_BALANCE_ERROR
Definition: btrfsioctl.h:164
#define BTRFS_BALANCE_SHRINKING
Definition: btrfsioctl.h:165
#define BTRFS_BALANCE_REMOVAL
Definition: btrfsioctl.h:163
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
wstring format_ntstatus(NTSTATUS Status)
Definition: main.cpp:184
#define IDS_BALANCE_FAILED_SHRINK
Definition: resource.h:199
#define IDS_BALANCE_COMPLETE_REMOVAL
Definition: resource.h:91
#define IDS_BALANCE_RUNNING_SHRINK
Definition: resource.h:195
#define IDS_BALANCE_RUNNING
Definition: resource.h:64
#define IDS_BALANCE_PAUSED
Definition: resource.h:72
#define IDS_BALANCE_CANCELLED_SHRINK
Definition: resource.h:197
#define IDS_BALANCE_COMPLETE_SHRINK
Definition: resource.h:198
#define IDS_BALANCE_FAILED_REMOVAL
Definition: resource.h:101
#define IDS_BALANCE_PAUSED_REMOVAL
Definition: resource.h:87
#define IDC_BALANCE_PROGRESS
Definition: resource.h:263
#define IDS_NO_BALANCE
Definition: resource.h:61
#define IDS_BALANCE_PAUSED_SHRINK
Definition: resource.h:196
#define IDS_BALANCE_CANCELLED_REMOVAL
Definition: resource.h:89
#define IDS_BALANCE_RUNNING_REMOVAL
Definition: resource.h:85
#define IDS_BALANCE_COMPLETE
Definition: resource.h:71
#define IDS_BALANCE_CANCELLED
Definition: resource.h:73
#define IDC_BALANCE_STATUS
Definition: resource.h:289
#define IDS_BALANCE_FAILED
Definition: resource.h:100
#define OPEN_EXISTING
Definition: compat.h:775
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileW
Definition: compat.h:741
#define FILE_SHARE_READ
Definition: compat.h:136
Status
Definition: gdiplustypes.h:25
const GLint * first
Definition: glext.h:5794
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define FILE_FLAG_OPEN_REPARSE_POINT
Definition: disk.h:39
#define FILE_FLAG_BACKUP_SEMANTICS
Definition: disk.h:41
static PIO_STATUS_BLOCK iosb
Definition: file.c:98
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
#define FILE_TRAVERSE
Definition: nt_native.h:643
NTSYSAPI NTSTATUS NTAPI NtFsControlFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG DeviceIoControlCode, IN PVOID InBuffer OPTIONAL, IN ULONG InBufferLength, OUT PVOID OutBuffer OPTIONAL, IN ULONG OutBufferLength)
#define PBM_SETRANGE32
Definition: commctrl.h:2188
#define PBM_SETPOS
Definition: commctrl.h:2184
uint64_t total_chunks
Definition: btrfsioctl.h:170
uint64_t chunks_left
Definition: btrfsioctl.h:169
UINT_PTR WPARAM
Definition: windef.h:207

Referenced by BalanceDlgProc().

◆ SaveBalanceOpts()

void BtrfsBalance::SaveBalanceOpts ( HWND  hwndDlg)
private

Definition at line 356 of file balance.cpp.

356 {
357 btrfs_balance_opts* opts;
358
359 switch (opts_type) {
360 case 1:
361 opts = &data_opts;
362 break;
363
364 case 2:
365 opts = &metadata_opts;
366 break;
367
368 case 3:
369 opts = &system_opts;
370 break;
371
372 default:
373 return;
374 }
375
376 RtlZeroMemory(opts, sizeof(btrfs_balance_opts));
377
380
390 }
391
392 if (IsDlgButtonChecked(hwndDlg, IDC_DEVID) == BST_CHECKED) {
394
395 auto sel = SendMessageW(GetDlgItem(hwndDlg, IDC_DEVID_COMBO), CB_GETCURSEL, 0, 0);
396
397 if (sel == CB_ERR)
398 opts->flags &= ~BTRFS_BALANCE_OPTS_DEVID;
399 else {
400 btrfs_device* bd = devices;
401 int i = 0;
402
403 while (true) {
404 if (i == sel) {
405 opts->devid = bd->dev_id;
406 break;
407 }
408
409 i++;
410
411 if (bd->next_entry > 0)
412 bd = (btrfs_device*)((uint8_t*)bd + bd->next_entry);
413 else
414 break;
415 }
416
417 if (opts->devid == 0)
418 opts->flags &= ~BTRFS_BALANCE_OPTS_DEVID;
419 }
420 }
421
422 if (IsDlgButtonChecked(hwndDlg, IDC_DRANGE) == BST_CHECKED) {
423 WCHAR s[255];
424
426
427 GetWindowTextW(GetDlgItem(hwndDlg, IDC_DRANGE_START), s, sizeof(s) / sizeof(WCHAR));
428 opts->drange_start = _wtoi64(s);
429
430 GetWindowTextW(GetDlgItem(hwndDlg, IDC_DRANGE_END), s, sizeof(s) / sizeof(WCHAR));
431 opts->drange_end = _wtoi64(s);
432
433 if (opts->drange_end < opts->drange_start)
435 }
436
437 if (IsDlgButtonChecked(hwndDlg, IDC_VRANGE) == BST_CHECKED) {
438 WCHAR s[255];
439
441
442 GetWindowTextW(GetDlgItem(hwndDlg, IDC_VRANGE_START), s, sizeof(s) / sizeof(WCHAR));
443 opts->vrange_start = _wtoi64(s);
444
445 GetWindowTextW(GetDlgItem(hwndDlg, IDC_VRANGE_END), s, sizeof(s) / sizeof(WCHAR));
446 opts->vrange_end = _wtoi64(s);
447
448 if (opts->vrange_end < opts->vrange_start)
450 }
451
452 if (IsDlgButtonChecked(hwndDlg, IDC_LIMIT) == BST_CHECKED) {
453 WCHAR s[255];
454
456
457 GetWindowTextW(GetDlgItem(hwndDlg, IDC_LIMIT_START), s, sizeof(s) / sizeof(WCHAR));
458 opts->limit_start = _wtoi64(s);
459
460 GetWindowTextW(GetDlgItem(hwndDlg, IDC_LIMIT_END), s, sizeof(s) / sizeof(WCHAR));
461 opts->limit_end = _wtoi64(s);
462
463 if (opts->limit_end < opts->limit_start)
465 }
466
467 if (IsDlgButtonChecked(hwndDlg, IDC_STRIPES) == BST_CHECKED) {
468 WCHAR s[255];
469
471
472 GetWindowTextW(GetDlgItem(hwndDlg, IDC_STRIPES_START), s, sizeof(s) / sizeof(WCHAR));
473 opts->stripes_start = (uint8_t)_wtoi(s);
474
475 GetWindowTextW(GetDlgItem(hwndDlg, IDC_STRIPES_END), s, sizeof(s) / sizeof(WCHAR));
476 opts->stripes_end = (uint8_t)_wtoi(s);
477
478 if (opts->stripes_end < opts->stripes_start)
480 }
481
482 if (IsDlgButtonChecked(hwndDlg, IDC_USAGE) == BST_CHECKED) {
483 WCHAR s[255];
484
486
487 GetWindowTextW(GetDlgItem(hwndDlg, IDC_USAGE_START), s, sizeof(s) / sizeof(WCHAR));
488 opts->usage_start = (uint8_t)_wtoi(s);
489
490 GetWindowTextW(GetDlgItem(hwndDlg, IDC_USAGE_END), s, sizeof(s) / sizeof(WCHAR));
491 opts->usage_end = (uint8_t)_wtoi(s);
492
493 if (opts->usage_end < opts->usage_start)
495 }
496
497 if (IsDlgButtonChecked(hwndDlg, IDC_CONVERT) == BST_CHECKED) {
499
500 auto sel = SendMessageW(GetDlgItem(hwndDlg, IDC_CONVERT_COMBO), CB_GETCURSEL, 0, 0);
501
502 if (sel == CB_ERR || (unsigned int)sel >= sizeof(convtypes2) / sizeof(convtypes2[0]))
503 opts->flags &= ~BTRFS_BALANCE_OPTS_CONVERT;
504 else {
505 opts->convert = convtypes2[sel];
506
508 }
509 }
510
511 EndDialog(hwndDlg, 0);
512}
#define IDS_LIMIT_END_BEFORE_START
Definition: resource.h:67
#define IDS_VRANGE_END_BEFORE_START
Definition: resource.h:66
#define IDS_STRIPES_END_BEFORE_START
Definition: resource.h:68
#define IDS_DRANGE_END_BEFORE_START
Definition: resource.h:65
#define IDS_USAGE_END_BEFORE_START
Definition: resource.h:69
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
#define uint8_t
Definition: nsiface.idl:59
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1412
#define CB_ERR
Definition: winuser.h:2425
#define CB_GETCURSEL
Definition: winuser.h:1933
__int64 CDECL _wtoi64(const wchar_t *str)
Definition: wtoi64.c:34

Referenced by BalanceOptsDlgProc().

◆ ShowBalance()

void BtrfsBalance::ShowBalance ( HWND  hwndDlg)

Definition at line 981 of file balance.cpp.

981 {
982 btrfs_device* bd;
983
984 if (devices) {
985 free(devices);
986 devices = nullptr;
987 }
988
989 {
992
993 if (h != INVALID_HANDLE_VALUE) {
996 ULONG devsize, i;
997
998 i = 0;
999 devsize = 1024;
1000
1001 devices = (btrfs_device*)malloc(devsize);
1002
1003 while (true) {
1004 Status = NtFsControlFile(h, nullptr, nullptr, nullptr, &iosb, FSCTL_BTRFS_GET_DEVICES, nullptr, 0, devices, devsize);
1006 if (i < 8) {
1007 devsize += 1024;
1008
1009 free(devices);
1010 devices = (btrfs_device*)malloc(devsize);
1011
1012 i++;
1013 } else
1014 return;
1015 } else
1016 break;
1017 }
1018
1019 if (!NT_SUCCESS(Status))
1020 throw ntstatus_error(Status);
1021 } else
1022 throw last_error(GetLastError());
1023 }
1024
1025 readonly = true;
1026 bd = devices;
1027
1028 while (true) {
1029 if (!bd->readonly) {
1030 readonly = false;
1031 break;
1032 }
1033
1034 if (bd->next_entry > 0)
1035 bd = (btrfs_device*)((uint8_t*)bd + bd->next_entry);
1036 else
1037 break;
1038 }
1039
1041}
static INT_PTR CALLBACK stub_BalanceDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: balance.cpp:965
#define FSCTL_BTRFS_GET_DEVICES
Definition: btrfsioctl.h:12
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define IDD_BALANCE
Definition: resource.h:19
#define FILE_READ_ATTRIBUTES
Definition: nt_native.h:647
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
uint32_t ULONG
Definition: typedefs.h:59
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)

Referenced by BtrfsDeviceResize::do_resize(), PropSheetDlgProc(), and RemoveDeviceW().

◆ ShowBalanceOptions()

void BtrfsBalance::ShowBalanceOptions ( HWND  hwndDlg,
uint8_t  type 
)
private

Definition at line 856 of file balance.cpp.

856 {
857 opts_type = type;
859}
static INT_PTR CALLBACK stub_BalanceOptsDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: balance.cpp:840
#define IDD_BALANCE_OPTIONS
Definition: resource.h:17
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545

Referenced by BalanceDlgProc().

◆ StartBalance()

void BtrfsBalance::StartBalance ( HWND  hwndDlg)
private

Definition at line 75 of file balance.cpp.

75 {
76 wstring t;
77 WCHAR modfn[MAX_PATH], u[600];
80
81 GetModuleFileNameW(module, modfn, sizeof(modfn) / sizeof(WCHAR));
82
83#ifndef __REACTOS__
84 t = L"\""s + modfn + L"\",StartBalance "s + fn + L" "s;
85#else
86 t = wstring(L"\"") + modfn + wstring(L"\",StartBalance ") + fn + wstring(L" ");
87#endif
88
92
95 else
96 bsb.opts[0].flags &= ~BTRFS_BALANCE_OPTS_ENABLED;
97
100 else
101 bsb.opts[1].flags &= ~BTRFS_BALANCE_OPTS_ENABLED;
102
105 else
106 bsb.opts[2].flags &= ~BTRFS_BALANCE_OPTS_ENABLED;
107
108 serialize(&bsb, sizeof(btrfs_start_balance), u);
109
110 t += u;
111
112 RtlZeroMemory(&sei, sizeof(sei));
113
114 sei.cbSize = sizeof(sei);
115 sei.hwnd = hwndDlg;
116 sei.lpVerb = L"runas";
117 sei.lpFile = L"rundll32.exe";
118 sei.lpParameters = t.c_str();
119 sei.nShow = SW_SHOW;
121
122 if (!ShellExecuteExW(&sei))
123 throw last_error(GetLastError());
124
125 cancelling = false;
126 removing = false;
127 shrinking = false;
129
133 EnableWindow(GetDlgItem(hwndDlg, IDC_DATA), false);
134 EnableWindow(GetDlgItem(hwndDlg, IDC_METADATA), false);
135 EnableWindow(GetDlgItem(hwndDlg, IDC_SYSTEM), false);
139
140 EnableWindow(GetDlgItem(hwndDlg, IDC_START_BALANCE), false);
141
144}
static void serialize(void *data, ULONG len, WCHAR *s)
Definition: balance.cpp:56
btrfs_balance_opts opts[3]
Definition: btrfsioctl.h:178
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263

Referenced by BalanceDlgProc().

◆ StopBalance()

void BtrfsBalance::StopBalance ( HWND  hwndDlg)
private

Definition at line 176 of file balance.cpp.

176 {
177 WCHAR modfn[MAX_PATH];
178 wstring t;
180
181 GetModuleFileNameW(module, modfn, sizeof(modfn) / sizeof(WCHAR));
182
183#ifndef __REACTOS__
184 t = L"\""s + modfn + L"\",StopBalance " + fn;
185#else
186 t = wstring(L"\"") + modfn + wstring(L"\",StopBalance ") + fn;
187#endif
188
189 RtlZeroMemory(&sei, sizeof(sei));
190
191 sei.cbSize = sizeof(sei);
192 sei.hwnd = hwndDlg;
193 sei.lpVerb = L"runas";
194 sei.lpFile = L"rundll32.exe";
195 sei.lpParameters = t.c_str();
196 sei.nShow = SW_SHOW;
198
199 if (!ShellExecuteExW(&sei))
200 throw last_error(GetLastError());
201
202 cancelling = true;
203
206}

Referenced by BalanceDlgProc().

Member Data Documentation

◆ balance_status

uint32_t BtrfsBalance::balance_status
private

Definition at line 49 of file balance.h.

Referenced by BalanceDlgProc(), BalanceOptsDlgProc(), RefreshBalanceDlg(), and StartBalance().

◆ bqb

btrfs_query_balance BtrfsBalance::bqb
private

Definition at line 52 of file balance.h.

Referenced by BalanceOptsDlgProc(), and RefreshBalanceDlg().

◆ called_from_RemoveDevice

bool BtrfsBalance::called_from_RemoveDevice
private

Definition at line 59 of file balance.h.

Referenced by BalanceDlgProc(), and BtrfsBalance().

◆ called_from_ShrinkDevice

bool BtrfsBalance::called_from_ShrinkDevice
private

Definition at line 59 of file balance.h.

Referenced by BalanceDlgProc(), and BtrfsBalance().

◆ cancelling

bool BtrfsBalance::cancelling
private

Definition at line 53 of file balance.h.

Referenced by BalanceDlgProc(), RefreshBalanceDlg(), StartBalance(), and StopBalance().

◆ data_opts

btrfs_balance_opts BtrfsBalance::data_opts
private

Definition at line 50 of file balance.h.

Referenced by BalanceDlgProc(), BalanceOptsDlgProc(), SaveBalanceOpts(), and StartBalance().

◆ devices

btrfs_device* BtrfsBalance::devices
private

Definition at line 57 of file balance.h.

Referenced by BalanceOptsDlgProc(), BtrfsBalance(), SaveBalanceOpts(), and ShowBalance().

◆ fn

wstring BtrfsBalance::fn
private

◆ metadata_opts

btrfs_balance_opts BtrfsBalance::metadata_opts
private

Definition at line 50 of file balance.h.

Referenced by BalanceDlgProc(), BalanceOptsDlgProc(), SaveBalanceOpts(), and StartBalance().

◆ opts_type

uint8_t BtrfsBalance::opts_type
private

Definition at line 51 of file balance.h.

Referenced by BalanceOptsDlgProc(), SaveBalanceOpts(), and ShowBalanceOptions().

◆ readonly

bool BtrfsBalance::readonly
private

Definition at line 58 of file balance.h.

Referenced by BalanceDlgProc(), RefreshBalanceDlg(), and ShowBalance().

◆ removing

bool BtrfsBalance::removing
private

Definition at line 54 of file balance.h.

Referenced by BalanceDlgProc(), BtrfsBalance(), RefreshBalanceDlg(), and StartBalance().

◆ shrinking

bool BtrfsBalance::shrinking
private

Definition at line 55 of file balance.h.

Referenced by BalanceDlgProc(), RefreshBalanceDlg(), and StartBalance().

◆ system_opts

btrfs_balance_opts BtrfsBalance::system_opts
private

Definition at line 50 of file balance.h.

Referenced by BalanceDlgProc(), BalanceOptsDlgProc(), SaveBalanceOpts(), and StartBalance().


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