170
171
sizeof DND_URI_LIST_PRE_KDE - 1) == 0) {
171
172
nameStart += sizeof DND_URI_LIST_PRE_KDE - 1;
173
Warning("DnDUriListGetFile: the URI list did not begin with %s or %s\n",
174
Warning("%s: the URI list did not begin with %s or %s\n", __func__,
174
175
DND_URI_LIST_PRE, DND_URI_LIST_PRE_KDE);
244
247
* Retrieve an allocated, unescaped name. This undoes the ' ' -> "%20"
245
248
* escaping as required by RFC 1630 for entries in a uri-list.
247
251
unescapedName = Escape_Undo('%', file, fileLength, &unescapedLength);
248
252
if (!unescapedName) {
249
253
Warning("%s: error unescaping filename\n", __func__);
261
267
/* We need to make this suck less. */
262
268
#if defined(linux) || defined(sun) || defined(__FreeBSD__)
267
VMBLOCK_CONTROL(int fd, int op, const char *path)
269
return write(fd, path, op);
272
#elif defined(__FreeBSD__)
275
VMBLOCK_CONTROL(int fd, int cmd, const char *path)
277
char tpath[MAXPATHLEN];
281
* FreeBSD's ioctl data parameters must be of fixed size. Guarantee a safe
282
* buffer of size MAXPATHLEN by copying the user's string to one of our own.
284
strlcpy(tpath, path, MAXPATHLEN);
287
return ioctl(fd, cmd, tpath);
293
VMBLOCK_CONTROL(int fd, int cmd, const char *path)
295
return ioctl(fd, cmd, path);
302
271
*----------------------------------------------------------------------------
324
293
if (VMBLOCK_CONTROL(blockFd, VMBLOCK_ADD_FILEBLOCK, blockPath) != 0) {
325
294
LOG(1, ("%s: Cannot add block on %s (%s)\n",
326
295
__func__, blockPath, strerror(errno)));
355
325
if (VMBLOCK_CONTROL(blockFd, VMBLOCK_DEL_FILEBLOCK, blockedPath) != 0) {
356
326
Log("%s: Cannot delete block on %s (%s)\n",
357
327
__func__, blockedPath, strerror(errno));
361
332
LOG(4, ("%s: Could not remove block on %s: "
362
333
"fd to vmblock no longer exists.\n", __func__, blockedPath));
394
* DnD_VmblockFuseControl --
396
* Controlling function for FUSE-based blocker implementation.
397
* Passes requests to block and unblock file access to fuse module.
400
* 0 on success, -1 on failure.
408
DnD_VmblockFuseControl(int fd, // IN
410
const char *path) // IN
413
* buffer needs room for an operation character and a string with max length
417
char buffer[PATH_MAX];
420
pathLength = strlen(path);
421
if (pathLength >= PATH_MAX) {
422
errno = ENAMETOOLONG;
427
memcpy(buffer + 1, path, pathLength);
430
* The lseek is only to prevent the file pointer from overflowing;
431
* vmblock-fuse ignores the file pointer / offset. Overflowing the file
432
* pointer causes write to fail:
433
* http://article.gmane.org/gmane.comp.file-systems.fuse.devel/6648
434
* There's also a race condition here where many threads all calling
435
* VMBLOCK_CONTROL at the same time could have all their seeks executed one
436
* after the other, followed by all the writes. Again, it's not a problem
437
* unless the file pointer overflows which is very unlikely with 32 bit
438
* offsets and practically impossible with 64 bit offsets.
441
if (lseek(fd, 0, SEEK_SET) < 0) {
445
if (write(fd, buffer, pathLength + 1) < 0) {
454
366
*----------------------------------------------------------------------------
456
368
* DnD_AddBlockFuse --
474
386
ASSERT(blockFd >= 0);
476
if (DnD_VmblockFuseControl(blockFd, VMBLOCK_FUSE_ADD_FILEBLOCK,
388
if (VMBLOCK_CONTROL_FUSE(blockFd, VMBLOCK_FUSE_ADD_FILEBLOCK,
478
390
LOG(1, ("%s: Cannot add block on %s (%s)\n",
479
391
__func__, blockPath, strerror(errno)));
505
418
const char *blockedPath) // IN
507
420
if (blockFd >= 0) {
508
if (DnD_VmblockFuseControl(blockFd, VMBLOCK_FUSE_DEL_FILEBLOCK,
421
if (VMBLOCK_CONTROL_FUSE(blockFd, VMBLOCK_FUSE_DEL_FILEBLOCK,
510
423
Log("%s: Cannot delete block on %s (%s)\n",
511
424
__func__, blockedPath, strerror(errno));
548
462
LOG(4, ("%s: read failed, error %s.\n",
549
463
__func__, strerror(errno)));
553
468
if (size != sizeof(VMBLOCK_FUSE_READ_RESPONSE)) {
554
469
LOG(4, ("%s: Response too short (%"FMTSZ"d vs. %"FMTSZ"u).\n",
555
470
__func__, size, sizeof(VMBLOCK_FUSE_READ_RESPONSE)));
560
476
sizeof(VMBLOCK_FUSE_READ_RESPONSE))) {
561
477
LOG(4, ("%s: Invalid response %.*s",
562
478
__func__, (int)sizeof(VMBLOCK_FUSE_READ_RESPONSE) - 1, buf));
608
526
* In the future we can publish the mount point in VMDB so that the UI
609
527
* can use it rather than enforcing the VMBLOCK_MOUNT_POINT check here.
611
530
if (strcmp(MNTINFO_FSTYPE(mnt), vmbFsName) == 0 &&
612
531
strcmp(MNTINFO_MNTPT(mnt), vmbMntPoint) == 0) {