1 /* Copyright (c) Mark Harmstone 2016-17
3 * This file is part of WinBtrfs.
5 * WinBtrfs is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public Licence as published by
7 * the Free Software Foundation, either version 3 of the Licence, or
8 * (at your option) any later version.
10 * WinBtrfs is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public Licence for more details.
15 * You should have received a copy of the GNU Lesser General Public Licence
16 * along with WinBtrfs. If not, see <http://www.gnu.org/licenses/>. */
23 #include "../btrfsioctl.h"
25 #include "btrfsioctl.h"
29 #define S_IRUSR 0000400
33 #define S_IWUSR 0000200
37 #define S_IXUSR 0000100
41 #define S_IRGRP (S_IRUSR >> 3)
45 #define S_IWGRP (S_IWUSR >> 3)
49 #define S_IXGRP (S_IXUSR >> 3)
53 #define S_IROTH (S_IRGRP >> 3)
57 #define S_IWOTH (S_IWGRP >> 3)
61 #define S_IXOTH (S_IXGRP >> 3)
65 #define S_ISUID 0004000
69 #define S_ISGID 0002000
73 #define S_ISVTX 0001000
76 #define BTRFS_INODE_NODATASUM 0x001
77 #define BTRFS_INODE_NODATACOW 0x002
78 #define BTRFS_INODE_READONLY 0x004
79 #define BTRFS_INODE_NOCOMPRESS 0x008
80 #define BTRFS_INODE_PREALLOC 0x010
81 #define BTRFS_INODE_SYNC 0x020
82 #define BTRFS_INODE_IMMUTABLE 0x040
83 #define BTRFS_INODE_APPEND 0x080
84 #define BTRFS_INODE_NODUMP 0x100
85 #define BTRFS_INODE_NOATIME 0x200
86 #define BTRFS_INODE_DIRSYNC 0x400
87 #define BTRFS_INODE_COMPRESS 0x800
89 extern LONG objs_loaded
;
91 class BtrfsPropSheet
: public IShellExtInit
, IShellPropSheetExt
{
98 flags_changed
= false;
99 perms_changed
= false;
102 compress_type_changed
= false;
104 can_change_perms
= false;
105 show_admin_button
= false;
108 flags
= flags_set
= 0;
112 sizes
[0] = sizes
[1] = sizes
[2] = sizes
[3] = sizes
[4] = 0;
113 totalsize
= allocsize
= sparsesize
= 0;
120 InterlockedIncrement(&objs_loaded
);
123 virtual ~BtrfsPropSheet() {
125 GlobalUnlock(stgm
.hGlobal
);
126 ReleaseStgMedium(&stgm
);
129 InterlockedDecrement(&objs_loaded
);
134 HRESULT __stdcall
QueryInterface(REFIID riid
, void **ppObj
);
136 ULONG __stdcall
AddRef() {
137 return InterlockedIncrement(&refcount
);
140 ULONG __stdcall
Release() {
141 LONG rc
= InterlockedDecrement(&refcount
);
151 virtual HRESULT __stdcall
Initialize(PCIDLIST_ABSOLUTE pidlFolder
, IDataObject
* pdtobj
, HKEY hkeyProgID
);
153 // IShellPropSheetExt
155 virtual HRESULT __stdcall
AddPages(LPFNADDPROPSHEETPAGE pfnAddPage
, LPARAM lParam
);
156 virtual HRESULT __stdcall
ReplacePage(UINT uPageID
, LPFNADDPROPSHEETPAGE pfnReplacePage
, LPARAM lParam
);
158 void init_propsheet(HWND hwndDlg
);
159 void change_inode_flag(HWND hDlg
, uint64_t flag
, UINT state
);
160 void change_perm_flag(HWND hDlg
, ULONG perm
, UINT state
);
161 void change_uid(HWND hDlg
, uint32_t uid
);
162 void change_gid(HWND hDlg
, uint32_t gid
);
163 void apply_changes(HWND hDlg
);
164 void set_size_on_disk(HWND hwndDlg
);
165 DWORD
search_list_thread();
166 void do_search(const wstring
& fn
);
167 void update_size_details_dialog(HWND hDlg
);
168 void open_as_admin(HWND hwndDlg
);
169 void set_cmdline(const wstring
& cmdline
);
172 bool can_change_perms
;
173 bool can_change_nocow
;
174 WCHAR size_format
[255], cr_format
[255], frag_format
[255];
176 uint32_t min_mode
, max_mode
, mode
, mode_set
;
177 uint64_t min_flags
, max_flags
, flags
, flags_set
;
178 uint64_t subvol
, inode
, rdev
;
179 uint8_t type
, min_compression_type
, max_compression_type
, compress_type
;
181 bool various_subvols
, various_inodes
, various_types
, various_uids
, various_gids
, compress_type_changed
, has_subvols
,
182 ro_subvol
, various_ro
, ro_changed
, show_admin_button
;
189 bool flags_changed
, perms_changed
, uid_changed
, gid_changed
;
190 uint64_t sizes
[5], totalsize
, allocsize
, sparsesize
, num_extents
;
191 deque
<wstring
> search_list
;
193 uint32_t sector_size
;
195 void apply_changes_file(HWND hDlg
, const wstring
& fn
);
196 HRESULT
check_file(const wstring
& fn
, UINT i
, UINT num_files
, UINT
* sv
);
197 HRESULT
load_file_list();