ReactOS  0.4.14-dev-49-gfb4591c
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 726 of file devices.cpp.

726  {
727  try {
728  switch (uMsg) {
729  case WM_INITDIALOG:
730  {
731  win_handle h;
732  WCHAR s[255];
733  wstring t, u;
734 
736 
737  GetDlgItemTextW(hwndDlg, IDC_RESIZE_DEVICE_ID, s, sizeof(s) / sizeof(WCHAR));
739  SetDlgItemTextW(hwndDlg, IDC_RESIZE_DEVICE_ID, t.c_str());
740 
743 
744  if (h != INVALID_HANDLE_VALUE) {
747  btrfs_device *devices, *bd;
748  ULONG devsize;
749  bool found = false;
750  HWND slider;
751 
752  devsize = 1024;
753  devices = (btrfs_device*)malloc(devsize);
754 
755  while (true) {
756  Status = NtFsControlFile(h, nullptr, nullptr, nullptr, &iosb, FSCTL_BTRFS_GET_DEVICES, nullptr, 0, devices, devsize);
758  devsize += 1024;
759 
760  free(devices);
761  devices = (btrfs_device*)malloc(devsize);
762  } else
763  break;
764  }
765 
766  if (!NT_SUCCESS(Status)) {
767  free(devices);
768  return false;
769  }
770 
771  bd = devices;
772 
773  while (true) {
774  if (bd->dev_id == dev_id) {
775  memcpy(&dev_info, bd, sizeof(btrfs_device));
776  found = true;
777  break;
778  }
779 
780  if (bd->next_entry > 0)
781  bd = (btrfs_device*)((uint8_t*)bd + bd->next_entry);
782  else
783  break;
784  }
785 
786  if (!found) {
787  free(devices);
788  return false;
789  }
790 
791  free(devices);
792 
793  GetDlgItemTextW(hwndDlg, IDC_RESIZE_CURSIZE, s, sizeof(s) / sizeof(WCHAR));
794  format_size(dev_info.size, u, true);
795  wstring_sprintf(t, s, u.c_str());
796  SetDlgItemTextW(hwndDlg, IDC_RESIZE_CURSIZE, t.c_str());
797 
799 
801  wstring_sprintf(t, new_size_text, u.c_str());
802  SetDlgItemTextW(hwndDlg, IDC_RESIZE_NEWSIZE, t.c_str());
803 
804  slider = GetDlgItem(hwndDlg, IDC_RESIZE_SLIDER);
805  SendMessageW(slider, TBM_SETRANGEMIN, false, 0);
807  SendMessageW(slider, TBM_SETPOS, true, (LPARAM)(new_size / 1048576));
808  } else
809  return false;
810 
811  break;
812  }
813 
814  case WM_COMMAND:
815  switch (HIWORD(wParam)) {
816  case BN_CLICKED:
817  switch (LOWORD(wParam)) {
818  case IDOK:
819  do_resize(hwndDlg);
820  return true;
821 
822  case IDCANCEL:
823  EndDialog(hwndDlg, 0);
824  return true;
825  }
826  break;
827  }
828  break;
829 
830  case WM_HSCROLL:
831  {
832  wstring t, u;
833 
835 
836  format_size(new_size, u, true);
837  wstring_sprintf(t, new_size_text, u.c_str());
838  SetDlgItemTextW(hwndDlg, IDC_RESIZE_NEWSIZE, t.c_str());
839 
840  EnableWindow(GetDlgItem(hwndDlg, IDOK), new_size > 0 ? true : false);
841 
842  break;
843  }
844  }
845  } catch (const exception& e) {
846  error_message(hwndDlg, e.what());
847  }
848 
849  return false;
850 }
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:2208
#define IDOK
Definition: winuser.h:824
uint32_t next_entry
Definition: btrfsioctl.h:101
#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:331
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define TBM_SETPOS
Definition: commctrl.h:2008
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:332
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:2010
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:738
#define TBM_SETRANGEMAX
Definition: commctrl.h:2011
#define e
Definition: ke_i.h:82
#define TBM_GETPOS
Definition: commctrl.h:2003
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:426
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:685
#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:61
#define IDC_RESIZE_SLIDER
Definition: resource.h:333
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:104
uint64_t dev_id
Definition: btrfsioctl.h:102
#define CreateFileW
Definition: compat.h:400
#define IDC_RESIZE_NEWSIZE
Definition: resource.h:334
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:103
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 685 of file devices.cpp.

685  {
688  btrfs_resize br;
689 
690  {
693 
694  if (h == INVALID_HANDLE_VALUE)
695  throw last_error(GetLastError());
696 
697  br.device = dev_id;
698  br.size = new_size;
699 
700  Status = NtFsControlFile(h, nullptr, nullptr, nullptr, &iosb, FSCTL_BTRFS_RESIZE, &br, sizeof(btrfs_resize), nullptr, 0);
701 
703  throw ntstatus_error(Status);
704  }
705 
707  wstring s, t, u;
708 
710  format_size(new_size, u, true);
711  wstring_sprintf(t, s, dev_id, u.c_str());
712  MessageBoxW(hwndDlg, t.c_str(), L"", MB_OK);
713 
714  EndDialog(hwndDlg, 0);
715  } else {
716  HWND par;
717 
718  par = GetParent(hwndDlg);
719  EndDialog(hwndDlg, 0);
720 
721  BtrfsBalance bb(fn, false, true);
722  bb.ShowBalance(par);
723  }
724 }
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:63
uint64_t size
Definition: btrfsioctl.h:279
LONG NTSTATUS
Definition: precomp.h:26
GLdouble GLdouble t
Definition: gl.h:2047
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
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:193
#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:426
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:400
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:278
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 867 of file devices.cpp.

867  {
868  this->dev_id = dev_id;
869  this->fn = fn;
870 
872 }
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:852

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: