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/>. */
22 #include "../btrfsioctl.h"
24 #include "btrfsioctl.h"
28 #define S_IRUSR 0000400
32 #define S_IWUSR 0000200
36 #define S_IXUSR 0000100
40 #define S_IRGRP (S_IRUSR >> 3)
44 #define S_IWGRP (S_IWUSR >> 3)
48 #define S_IXGRP (S_IXUSR >> 3)
52 #define S_IROTH (S_IRGRP >> 3)
56 #define S_IWOTH (S_IWGRP >> 3)
60 #define S_IXOTH (S_IXGRP >> 3)
64 #define S_ISUID 0004000
68 #define S_ISGID 0002000
72 #define S_ISVTX 0001000
75 #define BTRFS_INODE_NODATASUM 0x001
76 #define BTRFS_INODE_NODATACOW 0x002
77 #define BTRFS_INODE_READONLY 0x004
78 #define BTRFS_INODE_NOCOMPRESS 0x008
79 #define BTRFS_INODE_PREALLOC 0x010
80 #define BTRFS_INODE_SYNC 0x020
81 #define BTRFS_INODE_IMMUTABLE 0x040
82 #define BTRFS_INODE_APPEND 0x080
83 #define BTRFS_INODE_NODUMP 0x100
84 #define BTRFS_INODE_NOATIME 0x200
85 #define BTRFS_INODE_DIRSYNC 0x400
86 #define BTRFS_INODE_COMPRESS 0x800
88 extern LONG objs_loaded
;
90 class BtrfsPropSheet
: public IShellExtInit
, IShellPropSheetExt
{
97 flags_changed
= FALSE
;
98 perms_changed
= FALSE
;
101 compress_type_changed
= FALSE
;
103 can_change_perms
= FALSE
;
104 show_admin_button
= FALSE
;
107 flags
= flags_set
= 0;
111 sizes
[0] = sizes
[1] = sizes
[2] = sizes
[3] = 0;
114 InterlockedIncrement(&objs_loaded
);
117 virtual ~BtrfsPropSheet() {
119 GlobalUnlock(stgm
.hGlobal
);
120 ReleaseStgMedium(&stgm
);
123 InterlockedDecrement(&objs_loaded
);
128 HRESULT __stdcall
QueryInterface(REFIID riid
, void **ppObj
);
130 ULONG __stdcall
AddRef() {
131 return InterlockedIncrement(&refcount
);
134 ULONG __stdcall
Release() {
135 LONG rc
= InterlockedDecrement(&refcount
);
145 virtual HRESULT __stdcall
Initialize(PCIDLIST_ABSOLUTE pidlFolder
, IDataObject
* pdtobj
, HKEY hkeyProgID
);
147 // IShellPropSheetExt
149 virtual HRESULT __stdcall
AddPages(LPFNADDPROPSHEETPAGE pfnAddPage
, LPARAM lParam
);
150 virtual HRESULT __stdcall
ReplacePage(UINT uPageID
, LPFNADDPROPSHEETPAGE pfnReplacePage
, LPARAM lParam
);
152 void init_propsheet(HWND hwndDlg
);
153 void change_inode_flag(HWND hDlg
, UINT64 flag
, UINT state
);
154 void change_perm_flag(HWND hDlg
, ULONG perm
, UINT state
);
155 void change_uid(HWND hDlg
, UINT32 uid
);
156 void change_gid(HWND hDlg
, UINT32 gid
);
157 void apply_changes(HWND hDlg
);
158 void set_size_on_disk(HWND hwndDlg
);
159 void add_to_search_list(WCHAR
* fn
);
160 DWORD
search_list_thread();
161 void do_search(WCHAR
* fn
);
162 void update_size_details_dialog(HWND hDlg
);
163 void open_as_admin(HWND hwndDlg
);
164 void set_cmdline(std::wstring cmdline
);
167 BOOL can_change_perms
;
168 BOOL can_change_nocow
;
169 WCHAR size_format
[255];
171 UINT32 min_mode
, max_mode
, mode
, mode_set
;
172 UINT64 min_flags
, max_flags
, flags
, flags_set
;
173 UINT64 subvol
, inode
, rdev
;
174 UINT8 type
, min_compression_type
, max_compression_type
, compress_type
;
176 BOOL various_subvols
, various_inodes
, various_types
, various_uids
, various_gids
, compress_type_changed
, has_subvols
,
177 ro_subvol
, various_ro
, ro_changed
, show_admin_button
;
184 BOOL flags_changed
, perms_changed
, uid_changed
, gid_changed
;
185 UINT64 sizes
[4], totalsize
;
186 std::deque
<WCHAR
*> search_list
;
187 std::wstring filename
;
189 void apply_changes_file(HWND hDlg
, std::wstring fn
);
190 HRESULT
check_file(std::wstring fn
, UINT i
, UINT num_files
, UINT
* sv
);
191 HRESULT
load_file_list();