ReactOS  0.4.14-dev-845-g8381e29
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  {
702  win_handle h;
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 
775  slider = GetDlgItem(hwndDlg, IDC_RESIZE_SLIDER);
776  SendMessageW(slider, TBM_SETRANGEMIN, false, 0);
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 }
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
static PIO_STATUS_BLOCK iosb
Definition: file.c:98
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2265
#define IDOK
Definition: winuser.h:824
uint32_t next_entry
Definition: btrfsioctl.h:102
#define free
Definition: debug_ros.c:5
const char * devices
Definition: diskspace.c:793
btrfs_device dev_info
Definition: devices.h:167
LONG NTSTATUS
Definition: precomp.h:26
GLdouble GLdouble t
Definition: gl.h:2047
#define IDC_RESIZE_DEVICE_ID
Definition: resource.h:329
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
#define TBM_SETPOS
Definition: commctrl.h:2032
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 FILE_SHARE_WRITE
Definition: nt_native.h:681
HWND slider
Definition: sndrec32.cpp:39
#define IDC_RESIZE_CURSIZE
Definition: resource.h:330
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
#define TBM_SETRANGEMIN
Definition: commctrl.h:2034
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
#define FILE_TRAVERSE
Definition: nt_native.h:643
void error_message(HWND hwnd, const char *msg)
Definition: main.cpp:785
#define TBM_SETRANGEMAX
Definition: commctrl.h:2035
#define e
Definition: ke_i.h:82
#define TBM_GETPOS
Definition: commctrl.h:2027
uint64_t dev_id
Definition: devices.h:164
#define ETDT_ENABLETAB
Definition: dxdiag.c:30
LONG_PTR LPARAM
Definition: windef.h:208
#define OPEN_EXISTING
Definition: compat.h:434
void wstring_sprintf(wstring &s, wstring fmt,...)
Definition: main.cpp:225
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
HRESULT WINAPI EnableThemeDialogTexture(_In_ HWND hwnd, _In_ DWORD dwFlags)
Definition: uxthemesupp.c:55
#define BN_CLICKED
Definition: winuser.h:1907
#define FILE_READ_ATTRIBUTES
Definition: nt_native.h:647
void do_resize(HWND hwndDlg)
Definition: devices.cpp:656
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLdouble s
Definition: gl.h:2039
#define WM_COMMAND
Definition: winuser.h:1722
BYTE uint8_t
Definition: msvideo1.c:66
Status
Definition: gdiplustypes.h:24
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define IDC_RESIZE_SLIDER
Definition: resource.h:331
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_HSCROLL
Definition: winuser.h:1725
#define FSCTL_BTRFS_GET_DEVICES
Definition: btrfsioctl.h:12
uint64_t max_size
Definition: btrfsioctl.h:105
uint64_t dev_id
Definition: btrfsioctl.h:103
#define CreateFileW
Definition: compat.h:408
#define IDC_RESIZE_NEWSIZE
Definition: resource.h:332
uint64_t new_size
Definition: devices.h:164
#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
#define malloc
Definition: debug_ros.c:4
#define IDCANCEL
Definition: winuser.h:825
#define UInt32x32To64(a, b)
Definition: intsafe.h:258
#define WM_INITDIALOG
Definition: winuser.h:1721
#define LOWORD(l)
Definition: pedump.c:82
WCHAR new_size_text[255]
Definition: devices.h:166
uint64_t size
Definition: btrfsioctl.h:104
void format_size(uint64_t size, wstring &s, bool show_bytes)
Definition: main.cpp:65

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 }
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
static PIO_STATUS_BLOCK iosb
Definition: file.c:98
#define FSCTL_BTRFS_RESIZE
Definition: btrfsioctl.h:38
#define STATUS_MORE_PROCESSING_REQUIRED
Definition: shellext.h:68
uint64_t size
Definition: btrfsioctl.h:280
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
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 IDS_RESIZE_SUCCESSFUL
Definition: resource.h:192
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
#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
uint64_t dev_id
Definition: devices.h:164
#define OPEN_EXISTING
Definition: compat.h:434
void wstring_sprintf(wstring &s, wstring fmt,...)
Definition: main.cpp:225
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define FILE_READ_ATTRIBUTES
Definition: nt_native.h:647
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
static const WCHAR L[]
Definition: oid.c:1250
GLdouble s
Definition: gl.h:2039
Status
Definition: gdiplustypes.h:24
HWND WINAPI GetParent(_In_ HWND)
#define MB_OK
Definition: winuser.h:784
static int load_string(HINSTANCE hModule, UINT resId, LPWSTR pwszBuffer, INT cMaxChars)
Definition: muireg.c:10
#define CreateFileW
Definition: compat.h:408
uint64_t new_size
Definition: devices.h:164
#define FILE_FLAG_BACKUP_SEMANTICS
Definition: disk.h:41
#define FILE_FLAG_OPEN_REPARSE_POINT
Definition: disk.h:39
uint64_t device
Definition: btrfsioctl.h:279
void format_size(uint64_t size, wstring &s, bool show_bytes)
Definition: main.cpp:65

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 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
#define IDD_RESIZE
Definition: resource.h:90
uint64_t dev_id
Definition: devices.h:164
LONG_PTR LPARAM
Definition: windef.h:208
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
static INT_PTR CALLBACK stub_DeviceResizeDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: devices.cpp:823

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: