ReactOS 0.4.15-dev-7942-gd23573b
BtrfsDeviceResize Class Reference

#include <devices.h>

Collaboration diagram for BtrfsDeviceResize:

Public Member Functions

INT_PTR CALLBACK DeviceResizeDlgProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
void ShowDialog (HWND hwnd, const wstring &fn, uint64_t dev_id)
 

Private Member Functions

void do_resize (HWND hwndDlg)
 

Private Attributes

uint64_t dev_id
 
uint64_t new_size
 
wstring fn
 
WCHAR new_size_text [255]
 
btrfs_device dev_info
 

Detailed Description

Definition at line 156 of file devices.h.

Member Function Documentation

◆ DeviceResizeDlgProc()

INT_PTR CALLBACK BtrfsDeviceResize::DeviceResizeDlgProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 697 of file devices.cpp.

697 {
698 try {
699 switch (uMsg) {
700 case WM_INITDIALOG:
701 {
703 WCHAR s[255];
704 wstring t, u;
705
707
708 GetDlgItemTextW(hwndDlg, IDC_RESIZE_DEVICE_ID, s, sizeof(s) / sizeof(WCHAR));
710 SetDlgItemTextW(hwndDlg, IDC_RESIZE_DEVICE_ID, t.c_str());
711
714
715 if (h != INVALID_HANDLE_VALUE) {
718 btrfs_device *devices, *bd;
719 ULONG devsize;
720 bool found = false;
721 HWND slider;
722
723 devsize = 1024;
724 devices = (btrfs_device*)malloc(devsize);
725
726 while (true) {
727 Status = NtFsControlFile(h, nullptr, nullptr, nullptr, &iosb, FSCTL_BTRFS_GET_DEVICES, nullptr, 0, devices, devsize);
729 devsize += 1024;
730
731 free(devices);
732 devices = (btrfs_device*)malloc(devsize);
733 } else
734 break;
735 }
736
737 if (!NT_SUCCESS(Status)) {
738 free(devices);
739 return false;
740 }
741
742 bd = devices;
743
744 while (true) {
745 if (bd->dev_id == dev_id) {
746 memcpy(&dev_info, bd, sizeof(btrfs_device));
747 found = true;
748 break;
749 }
750
751 if (bd->next_entry > 0)
752 bd = (btrfs_device*)((uint8_t*)bd + bd->next_entry);
753 else
754 break;
755 }
756
757 if (!found) {
758 free(devices);
759 return false;
760 }
761
762 free(devices);
763
764 GetDlgItemTextW(hwndDlg, IDC_RESIZE_CURSIZE, s, sizeof(s) / sizeof(WCHAR));
765 format_size(dev_info.size, u, true);
766 wstring_sprintf(t, s, u.c_str());
767 SetDlgItemTextW(hwndDlg, IDC_RESIZE_CURSIZE, t.c_str());
768
770
772 wstring_sprintf(t, new_size_text, u.c_str());
773 SetDlgItemTextW(hwndDlg, IDC_RESIZE_NEWSIZE, t.c_str());
774
778 SendMessageW(slider, TBM_SETPOS, true, (LPARAM)(new_size / 1048576));
779 } else
780 return false;
781
782 break;
783 }
784
785 case WM_COMMAND:
786 switch (HIWORD(wParam)) {
787 case BN_CLICKED:
788 switch (LOWORD(wParam)) {
789 case IDOK:
790 do_resize(hwndDlg);
791 return true;
792
793 case IDCANCEL:
794 EndDialog(hwndDlg, 0);
795 return true;
796 }
797 break;
798 }
799 break;
800
801 case WM_HSCROLL:
802 {
803 wstring t, u;
804
806
807 format_size(new_size, u, true);
808 wstring_sprintf(t, new_size_text, u.c_str());
809 SetDlgItemTextW(hwndDlg, IDC_RESIZE_NEWSIZE, t.c_str());
810
811 EnableWindow(GetDlgItem(hwndDlg, IDOK), new_size > 0 ? true : false);
812
813 break;
814 }
815 }
816 } catch (const exception& e) {
817 error_message(hwndDlg, e.what());
818 }
819
820 return false;
821}
LONG NTSTATUS
Definition: precomp.h:26
#define FSCTL_BTRFS_GET_DEVICES
Definition: btrfsioctl.h:12
void do_resize(HWND hwndDlg)
Definition: devices.cpp:656
WCHAR new_size_text[255]
Definition: devices.h:166
uint64_t dev_id
Definition: devices.h:164
uint64_t new_size
Definition: devices.h:164
btrfs_device dev_info
Definition: devices.h:167
WPARAM wParam
Definition: combotst.c:138
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
void error_message(HWND hwnd, const char *msg)
Definition: main.cpp:783
void wstring_sprintf(wstring &s, wstring fmt,...)
Definition: main.cpp:225
void format_size(uint64_t size, wstring &s, bool show_bytes)
Definition: main.cpp:65
#define IDC_RESIZE_NEWSIZE
Definition: resource.h:336
#define IDC_RESIZE_CURSIZE
Definition: resource.h:334
#define IDC_RESIZE_DEVICE_ID
Definition: resource.h:333
#define IDC_RESIZE_SLIDER
Definition: resource.h:335
#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
static struct all_devices * devices
Definition: dsm_ctrl.c:48
#define ETDT_ENABLETAB
Definition: dxdiag.c:30
Status
Definition: gdiplustypes.h:25
GLdouble s
Definition: gl.h:2039
GLdouble GLdouble t
Definition: gl.h:2047
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
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 UInt32x32To64(a, b)
Definition: intsafe.h:252
#define e
Definition: ke_i.h:82
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#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
BYTE uint8_t
Definition: msvideo1.c:66
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_READ_ATTRIBUTES
Definition: nt_native.h:647
#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 LOWORD(l)
Definition: pedump.c:82
#define TBM_GETPOS
Definition: commctrl.h:2031
#define TBM_SETRANGEMIN
Definition: commctrl.h:2038
#define TBM_SETPOS
Definition: commctrl.h:2036
#define TBM_SETRANGEMAX
Definition: commctrl.h:2039
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
HWND slider
Definition: sndrec32.cpp:39
uint64_t dev_id
Definition: btrfsioctl.h:104
uint64_t max_size
Definition: btrfsioctl.h:106
uint64_t size
Definition: btrfsioctl.h:105
uint32_t next_entry
Definition: btrfsioctl.h:103
uint32_t ULONG
Definition: typedefs.h:59
#define HIWORD(l)
Definition: typedefs.h:247
HRESULT WINAPI EnableThemeDialogTexture(_In_ HWND hwnd, _In_ DWORD dwFlags)
Definition: uxthemesupp.c:55
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2263
LONG_PTR LPARAM
Definition: windef.h:208
#define WM_HSCROLL
Definition: winuser.h:1743
#define IDCANCEL
Definition: winuser.h:831
#define WM_COMMAND
Definition: winuser.h:1740
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
#define WM_INITDIALOG
Definition: winuser.h:1739
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDOK
Definition: winuser.h:830
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define BN_CLICKED
Definition: winuser.h:1925
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by stub_DeviceResizeDlgProc().

◆ do_resize()

void BtrfsDeviceResize::do_resize ( HWND  hwndDlg)
private

Definition at line 656 of file devices.cpp.

656 {
659 btrfs_resize br;
660
661 {
664
665 if (h == INVALID_HANDLE_VALUE)
666 throw last_error(GetLastError());
667
668 br.device = dev_id;
669 br.size = new_size;
670
671 Status = NtFsControlFile(h, nullptr, nullptr, nullptr, &iosb, FSCTL_BTRFS_RESIZE, &br, sizeof(btrfs_resize), nullptr, 0);
672
674 throw ntstatus_error(Status);
675 }
676
678 wstring s, t, u;
679
681 format_size(new_size, u, true);
682 wstring_sprintf(t, s, dev_id, u.c_str());
683 MessageBoxW(hwndDlg, t.c_str(), L"", MB_OK);
684
685 EndDialog(hwndDlg, 0);
686 } else {
687 HWND par;
688
689 par = GetParent(hwndDlg);
690 EndDialog(hwndDlg, 0);
691
692 BtrfsBalance bb(fn, false, true);
693 bb.ShowBalance(par);
694 }
695}
#define FSCTL_BTRFS_RESIZE
Definition: btrfsioctl.h:38
#define IDS_RESIZE_SUCCESSFUL
Definition: resource.h:194
static int load_string(HINSTANCE hModule, UINT resId, LPWSTR pwszBuffer, INT cMaxChars)
Definition: muireg.c:10
#define L(x)
Definition: ntvdm.h:50
#define STATUS_MORE_PROCESSING_REQUIRED
Definition: shellext.h:68
uint64_t size
Definition: btrfsioctl.h:281
uint64_t device
Definition: btrfsioctl.h:280
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define MB_OK
Definition: winuser.h:790
HWND WINAPI GetParent(_In_ HWND)

Referenced by DeviceResizeDlgProc().

◆ ShowDialog()

void BtrfsDeviceResize::ShowDialog ( HWND  hwnd,
const wstring &  fn,
uint64_t  dev_id 
)

Definition at line 838 of file devices.cpp.

838 {
839 this->dev_id = dev_id;
840 this->fn = fn;
841
843}
static INT_PTR CALLBACK stub_DeviceResizeDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: devices.cpp:823
#define IDD_RESIZE
Definition: resource.h:90
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#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 ResizeDeviceW().

Member Data Documentation

◆ dev_id

uint64_t BtrfsDeviceResize::dev_id
private

Definition at line 164 of file devices.h.

Referenced by DeviceResizeDlgProc(), do_resize(), and ShowDialog().

◆ dev_info

btrfs_device BtrfsDeviceResize::dev_info
private

Definition at line 167 of file devices.h.

Referenced by DeviceResizeDlgProc().

◆ fn

wstring BtrfsDeviceResize::fn
private

Definition at line 165 of file devices.h.

Referenced by DeviceResizeDlgProc(), do_resize(), and ShowDialog().

◆ new_size

uint64_t BtrfsDeviceResize::new_size
private

Definition at line 164 of file devices.h.

Referenced by DeviceResizeDlgProc(), and do_resize().

◆ new_size_text

WCHAR BtrfsDeviceResize::new_size_text[255]
private

Definition at line 166 of file devices.h.

Referenced by DeviceResizeDlgProc().


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