ccdeck 3.49.1 → 3.51.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -3
- package/THIRD_PARTY_NOTICES.md +28 -0
- package/bin/cli/commands.js +34 -3
- package/bin/cli/second-start.js +6 -1
- package/dist/web/assets/BrowserWatchModal-CDpunrq9.js +1 -0
- package/dist/web/assets/IntegrationModal-BctMcNU8.js +7 -0
- package/dist/web/assets/{RadioPanel-gFYxdsBg.js → RadioPanel-DQNFtYOx.js} +1 -1
- package/dist/web/assets/{TrafficRadar-B9MfKca4.js → TrafficRadar-DRt3Al7E.js} +1 -1
- package/dist/web/assets/UsageHistoryModal-DlgPufgs.js +1 -0
- package/dist/web/assets/{app-D2NP6IPl.js → app-4x4wTE-L.js} +73 -73
- package/dist/web/assets/{app-DfGYllmZ.css → app-o4kL0FgZ.css} +1 -1
- package/dist/web/assets/{index-Be6Ox-74.js → index-CWUj8Kqh.js} +1 -1
- package/dist/web/index.html +3 -3
- package/node_modules/bare-addon-resolve/LICENSE +201 -0
- package/node_modules/bare-addon-resolve/README.md +226 -0
- package/node_modules/bare-addon-resolve/index.d.ts +100 -0
- package/node_modules/bare-addon-resolve/index.js +531 -0
- package/node_modules/bare-addon-resolve/lib/errors.d.ts +16 -0
- package/node_modules/bare-addon-resolve/lib/errors.js +21 -0
- package/node_modules/bare-addon-resolve/package.json +57 -0
- package/node_modules/bare-module-resolve/LICENSE +201 -0
- package/node_modules/bare-module-resolve/README.md +322 -0
- package/node_modules/bare-module-resolve/index.d.ts +171 -0
- package/node_modules/bare-module-resolve/index.js +899 -0
- package/node_modules/bare-module-resolve/lib/errors.d.ts +31 -0
- package/node_modules/bare-module-resolve/lib/errors.js +37 -0
- package/node_modules/bare-module-resolve/package.json +56 -0
- package/node_modules/bare-semver/LICENSE +201 -0
- package/node_modules/bare-semver/README.md +147 -0
- package/node_modules/bare-semver/index.d.ts +61 -0
- package/node_modules/bare-semver/index.js +13 -0
- package/node_modules/bare-semver/lib/comparator.js +37 -0
- package/node_modules/bare-semver/lib/constants.js +7 -0
- package/node_modules/bare-semver/lib/errors.js +22 -0
- package/node_modules/bare-semver/lib/range.js +256 -0
- package/node_modules/bare-semver/lib/version.js +240 -0
- package/node_modules/bare-semver/package.json +43 -0
- package/node_modules/fs-native-extensions/CMakeLists.txt +118 -0
- package/node_modules/fs-native-extensions/LICENSE +201 -0
- package/node_modules/fs-native-extensions/README.md +160 -0
- package/node_modules/fs-native-extensions/binding.c +1825 -0
- package/node_modules/fs-native-extensions/binding.js +3 -0
- package/node_modules/fs-native-extensions/include/fs-ext.h +193 -0
- package/node_modules/fs-native-extensions/index.js +356 -0
- package/node_modules/fs-native-extensions/package.json +72 -0
- package/node_modules/fs-native-extensions/prebuilds/android-arm/fs-native-extensions.bare +0 -0
- package/node_modules/fs-native-extensions/prebuilds/android-arm/fs-native-extensions.node +0 -0
- package/node_modules/fs-native-extensions/prebuilds/android-arm64/fs-native-extensions.bare +0 -0
- package/node_modules/fs-native-extensions/prebuilds/android-arm64/fs-native-extensions.node +0 -0
- package/node_modules/fs-native-extensions/prebuilds/android-ia32/fs-native-extensions.bare +0 -0
- package/node_modules/fs-native-extensions/prebuilds/android-ia32/fs-native-extensions.node +0 -0
- package/node_modules/fs-native-extensions/prebuilds/android-x64/fs-native-extensions.bare +0 -0
- package/node_modules/fs-native-extensions/prebuilds/android-x64/fs-native-extensions.node +0 -0
- package/node_modules/fs-native-extensions/prebuilds/darwin-arm64/fs-native-extensions.bare +0 -0
- package/node_modules/fs-native-extensions/prebuilds/darwin-arm64/fs-native-extensions.node +0 -0
- package/node_modules/fs-native-extensions/prebuilds/darwin-x64/fs-native-extensions.bare +0 -0
- package/node_modules/fs-native-extensions/prebuilds/darwin-x64/fs-native-extensions.node +0 -0
- package/node_modules/fs-native-extensions/prebuilds/ios-arm64/fs-native-extensions.bare +0 -0
- package/node_modules/fs-native-extensions/prebuilds/ios-arm64-simulator/fs-native-extensions.bare +0 -0
- package/node_modules/fs-native-extensions/prebuilds/ios-x64-simulator/fs-native-extensions.bare +0 -0
- package/node_modules/fs-native-extensions/prebuilds/linux-arm64/fs-native-extensions.bare +0 -0
- package/node_modules/fs-native-extensions/prebuilds/linux-arm64/fs-native-extensions.node +0 -0
- package/node_modules/fs-native-extensions/prebuilds/linux-x64/fs-native-extensions.bare +0 -0
- package/node_modules/fs-native-extensions/prebuilds/linux-x64/fs-native-extensions.node +0 -0
- package/node_modules/fs-native-extensions/prebuilds/win32-arm64/fs-native-extensions.bare +0 -0
- package/node_modules/fs-native-extensions/prebuilds/win32-arm64/fs-native-extensions.node +0 -0
- package/node_modules/fs-native-extensions/prebuilds/win32-x64/fs-native-extensions.bare +0 -0
- package/node_modules/fs-native-extensions/prebuilds/win32-x64/fs-native-extensions.node +0 -0
- package/node_modules/fs-native-extensions/src/apple.c +197 -0
- package/node_modules/fs-native-extensions/src/linux.c +146 -0
- package/node_modules/fs-native-extensions/src/platform.h +51 -0
- package/node_modules/fs-native-extensions/src/posix.c +33 -0
- package/node_modules/fs-native-extensions/src/shared.c +397 -0
- package/node_modules/fs-native-extensions/src/win32/nt.h +226 -0
- package/node_modules/fs-native-extensions/src/win32.c +531 -0
- package/node_modules/require-addon/LICENSE +201 -0
- package/node_modules/require-addon/README.md +19 -0
- package/node_modules/require-addon/lib/bare.js +1 -0
- package/node_modules/require-addon/lib/default.js +7 -0
- package/node_modules/require-addon/lib/node.js +79 -0
- package/node_modules/require-addon/package.json +64 -0
- package/node_modules/which-runtime/LICENSE +201 -0
- package/node_modules/which-runtime/README.md +29 -0
- package/node_modules/which-runtime/index.js +36 -0
- package/node_modules/which-runtime/package.json +32 -0
- package/package.json +12 -2
- package/release-notes.json +25 -0
- package/src/server/claude-accounts.mjs +19 -3
- package/src/server/claude-collector.mjs +18 -2
- package/src/server/cswap-install.mjs +60 -18
- package/src/server/integrations/jira-comment.mjs +37 -0
- package/src/server/integrations/jira-move.mjs +37 -11
- package/src/server/integrations/jira-transition.mjs +43 -0
- package/src/server/integrations/jira-write-guard.mjs +218 -0
- package/src/server/integrations/jira.mjs +16 -0
- package/src/server/integrations/routes.mjs +70 -7
- package/src/server/lan-deck.mjs +9 -0
- package/src/server/lan-engine.mjs +17 -2
- package/src/server/lan-manifest.mjs +10 -3
- package/src/server/lifecycle.mjs +27 -2
- package/src/server/login-guard.mjs +4 -0
- package/src/server/npm-upgrade.mjs +46 -18
- package/src/server/pinned-build.mjs +5 -0
- package/src/server/quota-store-resets.mjs +13 -6
- package/src/server/quota.mjs +8 -1
- package/src/server/running-deck.mjs +14 -0
- package/src/server/static-cache.mjs +34 -16
- package/src/server/terminal-cli-update.mjs +189 -0
- package/src/server/terminal-cli.mjs +93 -0
- package/src/server/traffic-radar-wire.mjs +6 -0
- package/src/server/usage-share.mjs +444 -0
- package/dist/web/assets/BrowserWatchModal-CCARqAMn.js +0 -1
- package/dist/web/assets/IntegrationModal-B8t53aE5.js +0 -7
- package/dist/web/assets/UsageHistoryModal-DvYWhsYv.js +0 -1
|
@@ -0,0 +1,531 @@
|
|
|
1
|
+
#include <io.h>
|
|
2
|
+
#include <stdbool.h>
|
|
3
|
+
#include <stdint.h>
|
|
4
|
+
#include <string.h>
|
|
5
|
+
#include <strsafe.h>
|
|
6
|
+
#include <uv.h>
|
|
7
|
+
|
|
8
|
+
#include "../include/fs-ext.h"
|
|
9
|
+
|
|
10
|
+
#include "platform.h"
|
|
11
|
+
#include "win32/nt.h"
|
|
12
|
+
|
|
13
|
+
int
|
|
14
|
+
fs_ext__try_lock(uv_os_fd_t fd, uint64_t offset, size_t length, fs_ext_lock_type_t type) {
|
|
15
|
+
if (length == 0) length = SIZE_MAX;
|
|
16
|
+
|
|
17
|
+
DWORD flags = LOCKFILE_FAIL_IMMEDIATELY;
|
|
18
|
+
|
|
19
|
+
if (type == FS_EXT_WRLOCK) flags |= LOCKFILE_EXCLUSIVE_LOCK;
|
|
20
|
+
|
|
21
|
+
OVERLAPPED data = {
|
|
22
|
+
.hEvent = 0,
|
|
23
|
+
.Offset = offset,
|
|
24
|
+
.OffsetHigh = offset >> 32,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
BOOL res = LockFileEx(
|
|
28
|
+
fd,
|
|
29
|
+
flags,
|
|
30
|
+
0,
|
|
31
|
+
length,
|
|
32
|
+
length >> 32,
|
|
33
|
+
&data
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
return res ? 0 : uv_translate_sys_error(GetLastError());
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
int
|
|
40
|
+
fs_ext__wait_for_lock(uv_os_fd_t fd, uint64_t offset, size_t length, fs_ext_lock_type_t type) {
|
|
41
|
+
if (length == 0) length = SIZE_MAX;
|
|
42
|
+
|
|
43
|
+
DWORD flags = 0;
|
|
44
|
+
|
|
45
|
+
if (type == FS_EXT_WRLOCK) flags |= LOCKFILE_EXCLUSIVE_LOCK;
|
|
46
|
+
|
|
47
|
+
OVERLAPPED data = {
|
|
48
|
+
.hEvent = 0,
|
|
49
|
+
.Offset = offset,
|
|
50
|
+
.OffsetHigh = offset >> 32,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
BOOL res = LockFileEx(
|
|
54
|
+
fd,
|
|
55
|
+
flags,
|
|
56
|
+
0,
|
|
57
|
+
length,
|
|
58
|
+
length >> 32,
|
|
59
|
+
&data
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
return res ? 0 : uv_translate_sys_error(GetLastError());
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
int
|
|
66
|
+
fs_ext__try_downgrade_lock(uv_os_fd_t fd, uint64_t offset, size_t length) {
|
|
67
|
+
int res = fs_ext__try_lock(fd, offset, length, FS_EXT_RDLOCK);
|
|
68
|
+
if (res < 0) return res;
|
|
69
|
+
|
|
70
|
+
return fs_ext__unlock(fd, offset, length);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
int
|
|
74
|
+
fs_ext__wait_for_downgrade_lock(uv_os_fd_t fd, uint64_t offset, size_t length) {
|
|
75
|
+
int res = fs_ext__wait_for_lock(fd, offset, length, FS_EXT_RDLOCK);
|
|
76
|
+
if (res < 0) return res;
|
|
77
|
+
|
|
78
|
+
return fs_ext__unlock(fd, offset, length);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
int
|
|
82
|
+
fs_ext__try_upgrade_lock(uv_os_fd_t fd, uint64_t offset, size_t length) {
|
|
83
|
+
int res = fs_ext__unlock(fd, offset, length);
|
|
84
|
+
if (res < 0) return res;
|
|
85
|
+
|
|
86
|
+
return fs_ext__try_lock(fd, offset, length, FS_EXT_WRLOCK);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
int
|
|
90
|
+
fs_ext__wait_for_upgrade_lock(uv_os_fd_t fd, uint64_t offset, size_t length) {
|
|
91
|
+
int res = fs_ext__unlock(fd, offset, length);
|
|
92
|
+
if (res < 0) return res;
|
|
93
|
+
|
|
94
|
+
return fs_ext__wait_for_lock(fd, offset, length, FS_EXT_WRLOCK);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
int
|
|
98
|
+
fs_ext__unlock(uv_os_fd_t fd, uint64_t offset, size_t length) {
|
|
99
|
+
if (length == 0) length = SIZE_MAX;
|
|
100
|
+
|
|
101
|
+
OVERLAPPED data = {
|
|
102
|
+
.hEvent = 0,
|
|
103
|
+
.Offset = offset,
|
|
104
|
+
.OffsetHigh = offset >> 32,
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
BOOL res = UnlockFileEx(
|
|
108
|
+
fd,
|
|
109
|
+
0,
|
|
110
|
+
length,
|
|
111
|
+
length >> 32,
|
|
112
|
+
&data
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
return res ? 0 : uv_translate_sys_error(GetLastError());
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
int
|
|
119
|
+
fs_ext__trim(uv_os_fd_t fd, uint64_t offset, size_t length) {
|
|
120
|
+
FILE_ZERO_DATA_INFORMATION data = {
|
|
121
|
+
.FileOffset = {
|
|
122
|
+
.QuadPart = offset,
|
|
123
|
+
},
|
|
124
|
+
.BeyondFinalZero = {
|
|
125
|
+
.QuadPart = offset + length,
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
DWORD bytes;
|
|
130
|
+
|
|
131
|
+
BOOL res = DeviceIoControl(
|
|
132
|
+
fd,
|
|
133
|
+
FSCTL_SET_ZERO_DATA,
|
|
134
|
+
&data,
|
|
135
|
+
sizeof(data),
|
|
136
|
+
NULL,
|
|
137
|
+
0,
|
|
138
|
+
&bytes, // Must be passed when lpOverlapped is NULL
|
|
139
|
+
NULL
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
return res ? 0 : uv_translate_sys_error(GetLastError());
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
int
|
|
146
|
+
fs_ext__sparse(uv_os_fd_t fd) {
|
|
147
|
+
DWORD bytes;
|
|
148
|
+
|
|
149
|
+
BOOL res = DeviceIoControl(
|
|
150
|
+
fd,
|
|
151
|
+
FSCTL_SET_SPARSE,
|
|
152
|
+
NULL,
|
|
153
|
+
0,
|
|
154
|
+
NULL,
|
|
155
|
+
0,
|
|
156
|
+
&bytes, // Must be passed when lpOverlapped is NULL
|
|
157
|
+
NULL
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
return res ? 0 : uv_translate_sys_error(GetLastError());
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
static int
|
|
164
|
+
fs_ext__temp_path(const char *base, char *path) {
|
|
165
|
+
TCHAR directory[MAX_PATH];
|
|
166
|
+
|
|
167
|
+
HRESULT res = StringCchCopy(directory, MAX_PATH, base);
|
|
168
|
+
|
|
169
|
+
if (FAILED(res)) return UV_ENAMETOOLONG;
|
|
170
|
+
|
|
171
|
+
char *backward = strrchr(directory, '\\');
|
|
172
|
+
char *forward = strrchr(directory, '/');
|
|
173
|
+
char *separator = backward > forward ? backward : forward;
|
|
174
|
+
|
|
175
|
+
if (separator == NULL) {
|
|
176
|
+
res = StringCchCopy(directory, MAX_PATH, ".");
|
|
177
|
+
|
|
178
|
+
if (FAILED(res)) return UV_ENAMETOOLONG;
|
|
179
|
+
} else {
|
|
180
|
+
if (separator == directory) separator++;
|
|
181
|
+
|
|
182
|
+
*separator = '\0';
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
UINT unique = GetCurrentProcessId();
|
|
186
|
+
|
|
187
|
+
// A nonzero unique value makes `GetTempFileName()` return a path without
|
|
188
|
+
// creating a file at it, which is required as the path may name a directory.
|
|
189
|
+
// In return, the path is not guaranteed to be unique and must be checked.
|
|
190
|
+
for (int i = 0; i < 64; i++) {
|
|
191
|
+
if (GetTempFileName(directory, "fse", unique + i, path) == 0) {
|
|
192
|
+
return uv_translate_sys_error(GetLastError());
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (GetFileAttributes(path) == INVALID_FILE_ATTRIBUTES) return 0;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return UV_EEXIST;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
static int
|
|
202
|
+
fs_ext__move(const char *from, const char *to) {
|
|
203
|
+
BOOL res = MoveFileEx(
|
|
204
|
+
from,
|
|
205
|
+
to,
|
|
206
|
+
MOVEFILE_REPLACE_EXISTING
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
return res ? 0 : uv_translate_sys_error(GetLastError());
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
int
|
|
213
|
+
fs_ext__swap(const char *from, const char *to) {
|
|
214
|
+
TCHAR swap[MAX_PATH];
|
|
215
|
+
|
|
216
|
+
int err = fs_ext__temp_path(from, swap);
|
|
217
|
+
if (err < 0) return err;
|
|
218
|
+
|
|
219
|
+
err = fs_ext__move(from, swap);
|
|
220
|
+
if (err < 0) return err;
|
|
221
|
+
|
|
222
|
+
err = fs_ext__move(to, from);
|
|
223
|
+
|
|
224
|
+
if (err < 0) {
|
|
225
|
+
fs_ext__move(swap, from);
|
|
226
|
+
|
|
227
|
+
return err;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
err = fs_ext__move(swap, to);
|
|
231
|
+
|
|
232
|
+
if (err < 0) {
|
|
233
|
+
fs_ext__move(from, to);
|
|
234
|
+
fs_ext__move(swap, from);
|
|
235
|
+
|
|
236
|
+
return err;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
return 0;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
static int
|
|
243
|
+
fs_ext__stream_name(const char *name, WCHAR unicode_name[MAX_PATH], UNICODE_STRING *object_name) {
|
|
244
|
+
unicode_name[0] = L':';
|
|
245
|
+
|
|
246
|
+
int len = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, name, -1, &unicode_name[1], MAX_PATH - 1);
|
|
247
|
+
|
|
248
|
+
if (len == 0) {
|
|
249
|
+
return GetLastError() == ERROR_INSUFFICIENT_BUFFER ? UV_ENAMETOOLONG : UV_EINVAL;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
*object_name = (UNICODE_STRING) {
|
|
253
|
+
.Length = len * sizeof(WCHAR),
|
|
254
|
+
.MaximumLength = (len + 1) * sizeof(WCHAR),
|
|
255
|
+
.Buffer = unicode_name,
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
return 0;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
int
|
|
262
|
+
fs_ext__get_attr(uv_os_fd_t fd, const char *name, uv_buf_t *value) {
|
|
263
|
+
HANDLE handle = fd;
|
|
264
|
+
HANDLE stream_handle;
|
|
265
|
+
|
|
266
|
+
WCHAR unicode_name[MAX_PATH];
|
|
267
|
+
UNICODE_STRING object_name;
|
|
268
|
+
|
|
269
|
+
int err = fs_ext__stream_name(name, unicode_name, &object_name);
|
|
270
|
+
if (err < 0) return err;
|
|
271
|
+
|
|
272
|
+
OBJECT_ATTRIBUTES object_attributes = {
|
|
273
|
+
.Length = sizeof(object_attributes),
|
|
274
|
+
.RootDirectory = handle,
|
|
275
|
+
.ObjectName = &object_name,
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
IO_STATUS_BLOCK status;
|
|
279
|
+
|
|
280
|
+
NTSTATUS res = NtOpenFile(
|
|
281
|
+
&stream_handle,
|
|
282
|
+
GENERIC_READ | SYNCHRONIZE,
|
|
283
|
+
&object_attributes,
|
|
284
|
+
&status,
|
|
285
|
+
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
|
|
286
|
+
FILE_SYNCHRONOUS_IO_NONALERT
|
|
287
|
+
);
|
|
288
|
+
|
|
289
|
+
if (res < 0) {
|
|
290
|
+
if (res == STATUS_OBJECT_NAME_NOT_FOUND) return UV_ENODATA;
|
|
291
|
+
|
|
292
|
+
return UV_EIO;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
FILE_STANDARD_INFORMATION info;
|
|
296
|
+
|
|
297
|
+
res = NtQueryInformationFile(
|
|
298
|
+
stream_handle,
|
|
299
|
+
&status,
|
|
300
|
+
&info,
|
|
301
|
+
sizeof(info),
|
|
302
|
+
FileStandardInformation
|
|
303
|
+
);
|
|
304
|
+
|
|
305
|
+
if (res < 0) {
|
|
306
|
+
NtClose(stream_handle);
|
|
307
|
+
|
|
308
|
+
return UV_EIO;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
size_t length = info.EndOfFile.QuadPart;
|
|
312
|
+
|
|
313
|
+
*value = uv_buf_init(malloc(length), length);
|
|
314
|
+
|
|
315
|
+
LARGE_INTEGER offset = {
|
|
316
|
+
.QuadPart = 0,
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
res = NtReadFile(
|
|
320
|
+
stream_handle,
|
|
321
|
+
NULL,
|
|
322
|
+
NULL,
|
|
323
|
+
NULL,
|
|
324
|
+
&status,
|
|
325
|
+
value->base,
|
|
326
|
+
value->len,
|
|
327
|
+
&offset,
|
|
328
|
+
NULL
|
|
329
|
+
);
|
|
330
|
+
|
|
331
|
+
NtClose(stream_handle);
|
|
332
|
+
|
|
333
|
+
if (res < 0 || status.Information != length) return UV_EIO;
|
|
334
|
+
|
|
335
|
+
return 0;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
int
|
|
339
|
+
fs_ext__set_attr(uv_os_fd_t fd, const char *name, const uv_buf_t *value) {
|
|
340
|
+
HANDLE handle = fd;
|
|
341
|
+
HANDLE stream_handle;
|
|
342
|
+
|
|
343
|
+
WCHAR unicode_name[MAX_PATH];
|
|
344
|
+
UNICODE_STRING object_name;
|
|
345
|
+
|
|
346
|
+
int err = fs_ext__stream_name(name, unicode_name, &object_name);
|
|
347
|
+
if (err < 0) return err;
|
|
348
|
+
|
|
349
|
+
OBJECT_ATTRIBUTES object_attributes = {
|
|
350
|
+
.Length = sizeof(object_attributes),
|
|
351
|
+
.RootDirectory = handle,
|
|
352
|
+
.ObjectName = &object_name,
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
IO_STATUS_BLOCK status;
|
|
356
|
+
|
|
357
|
+
NTSTATUS res = NtCreateFile(
|
|
358
|
+
&stream_handle,
|
|
359
|
+
GENERIC_WRITE | SYNCHRONIZE,
|
|
360
|
+
&object_attributes,
|
|
361
|
+
&status,
|
|
362
|
+
NULL,
|
|
363
|
+
FILE_ATTRIBUTE_NORMAL,
|
|
364
|
+
0,
|
|
365
|
+
FILE_OVERWRITE_IF,
|
|
366
|
+
FILE_SYNCHRONOUS_IO_NONALERT,
|
|
367
|
+
NULL,
|
|
368
|
+
0
|
|
369
|
+
);
|
|
370
|
+
|
|
371
|
+
if (res < 0) return UV_EIO;
|
|
372
|
+
|
|
373
|
+
LARGE_INTEGER offset = {
|
|
374
|
+
.QuadPart = 0,
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
res = NtWriteFile(
|
|
378
|
+
stream_handle,
|
|
379
|
+
NULL,
|
|
380
|
+
NULL,
|
|
381
|
+
NULL,
|
|
382
|
+
&status,
|
|
383
|
+
value->base,
|
|
384
|
+
value->len,
|
|
385
|
+
&offset,
|
|
386
|
+
NULL
|
|
387
|
+
);
|
|
388
|
+
|
|
389
|
+
NtClose(stream_handle);
|
|
390
|
+
|
|
391
|
+
if (res < 0 || status.Information != value->len) return UV_EIO;
|
|
392
|
+
|
|
393
|
+
return 0;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
int
|
|
397
|
+
fs_ext__remove_attr(uv_os_fd_t fd, const char *name) {
|
|
398
|
+
HANDLE handle = fd;
|
|
399
|
+
HANDLE stream_handle;
|
|
400
|
+
|
|
401
|
+
WCHAR unicode_name[MAX_PATH];
|
|
402
|
+
UNICODE_STRING object_name;
|
|
403
|
+
|
|
404
|
+
int err = fs_ext__stream_name(name, unicode_name, &object_name);
|
|
405
|
+
if (err < 0) return err;
|
|
406
|
+
|
|
407
|
+
OBJECT_ATTRIBUTES object_attributes = {
|
|
408
|
+
.Length = sizeof(object_attributes),
|
|
409
|
+
.RootDirectory = handle,
|
|
410
|
+
.ObjectName = &object_name,
|
|
411
|
+
};
|
|
412
|
+
|
|
413
|
+
IO_STATUS_BLOCK status;
|
|
414
|
+
|
|
415
|
+
NTSTATUS res = NtOpenFile(
|
|
416
|
+
&stream_handle,
|
|
417
|
+
DELETE,
|
|
418
|
+
&object_attributes,
|
|
419
|
+
&status,
|
|
420
|
+
FILE_SHARE_DELETE,
|
|
421
|
+
0
|
|
422
|
+
);
|
|
423
|
+
|
|
424
|
+
if (res < 0) {
|
|
425
|
+
if (res == STATUS_OBJECT_NAME_NOT_FOUND) return UV_ENODATA;
|
|
426
|
+
|
|
427
|
+
return UV_EIO;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
res = NtDeleteFile(&object_attributes);
|
|
431
|
+
|
|
432
|
+
NtClose(stream_handle);
|
|
433
|
+
|
|
434
|
+
if (res < 0) return UV_EIO;
|
|
435
|
+
|
|
436
|
+
return 0;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
int
|
|
440
|
+
fs_ext__list_attrs(uv_os_fd_t fd, char **names, size_t *length) {
|
|
441
|
+
HANDLE handle = fd;
|
|
442
|
+
|
|
443
|
+
size_t info_size = 64;
|
|
444
|
+
|
|
445
|
+
PFILE_STREAM_INFORMATION info = malloc(info_size);
|
|
446
|
+
memset(info, 0, info_size);
|
|
447
|
+
|
|
448
|
+
NTSTATUS res;
|
|
449
|
+
|
|
450
|
+
do {
|
|
451
|
+
IO_STATUS_BLOCK status;
|
|
452
|
+
|
|
453
|
+
res = NtQueryInformationFile(
|
|
454
|
+
handle,
|
|
455
|
+
&status,
|
|
456
|
+
&info[0],
|
|
457
|
+
info_size,
|
|
458
|
+
FileStreamInformation
|
|
459
|
+
);
|
|
460
|
+
|
|
461
|
+
if (res == STATUS_BUFFER_OVERFLOW) {
|
|
462
|
+
info = realloc(info, info_size *= 2);
|
|
463
|
+
memset(info, 0, info_size);
|
|
464
|
+
} else {
|
|
465
|
+
break;
|
|
466
|
+
}
|
|
467
|
+
} while (true);
|
|
468
|
+
|
|
469
|
+
if (res < 0) {
|
|
470
|
+
free(info);
|
|
471
|
+
|
|
472
|
+
return UV_EIO;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
PFILE_STREAM_INFORMATION next = info;
|
|
476
|
+
|
|
477
|
+
size_t names_len = 0;
|
|
478
|
+
*length = 0;
|
|
479
|
+
|
|
480
|
+
do {
|
|
481
|
+
PWCHAR unicode_name = &next->StreamName[1];
|
|
482
|
+
|
|
483
|
+
unicode_name[wcslen(unicode_name) - wcslen(L":$DATA")] = L'\0';
|
|
484
|
+
|
|
485
|
+
if (wcscmp(unicode_name, L"") != 0) {
|
|
486
|
+
size_t name_len = WideCharToMultiByte(CP_UTF8, 0, unicode_name, -1, NULL, 0, NULL, NULL);
|
|
487
|
+
|
|
488
|
+
*length += 1;
|
|
489
|
+
|
|
490
|
+
names_len += sizeof(char *) + name_len;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
if (next->NextEntryOffset) {
|
|
494
|
+
next = (PFILE_STREAM_INFORMATION) (((uintptr_t) next) + next->NextEntryOffset);
|
|
495
|
+
} else {
|
|
496
|
+
break;
|
|
497
|
+
}
|
|
498
|
+
} while (true);
|
|
499
|
+
|
|
500
|
+
*names = malloc(names_len);
|
|
501
|
+
|
|
502
|
+
size_t offset = *length * sizeof(char *), i = 0, j = 0;
|
|
503
|
+
|
|
504
|
+
next = info;
|
|
505
|
+
|
|
506
|
+
do {
|
|
507
|
+
PWCHAR unicode_name = &next->StreamName[1];
|
|
508
|
+
|
|
509
|
+
if (wcscmp(unicode_name, L"") != 0) {
|
|
510
|
+
size_t name_len = WideCharToMultiByte(CP_UTF8, 0, unicode_name, -1, NULL, 0, NULL, NULL);
|
|
511
|
+
|
|
512
|
+
char *name = *names + offset + i;
|
|
513
|
+
i += name_len;
|
|
514
|
+
|
|
515
|
+
WideCharToMultiByte(CP_UTF8, 0, unicode_name, -1, name, name_len, NULL, NULL);
|
|
516
|
+
|
|
517
|
+
memcpy(*names + j, &name, sizeof(char *));
|
|
518
|
+
j += sizeof(char *);
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
if (next->NextEntryOffset) {
|
|
522
|
+
next = (PFILE_STREAM_INFORMATION) (((uintptr_t) next) + next->NextEntryOffset);
|
|
523
|
+
} else {
|
|
524
|
+
break;
|
|
525
|
+
}
|
|
526
|
+
} while (true);
|
|
527
|
+
|
|
528
|
+
free(info);
|
|
529
|
+
|
|
530
|
+
return 0;
|
|
531
|
+
}
|