| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
#include <common.h> |
| 23 |
#include <narrow_string.h> |
| 24 |
#include <types.h> |
| 25 |
|
| 26 |
#if defined( HAVE_ERRNO_H ) || defined( WINAPI ) |
| 27 |
#include <errno.h> |
| 28 |
#endif |
| 29 |
|
| 30 |
#if defined( HAVE_STDLIB_H ) || defined( WINAPI ) |
| 31 |
#include <stdlib.h> |
| 32 |
#endif |
| 33 |
|
| 34 |
#if defined( HAVE_UNISTD_H ) |
| 35 |
#include <unistd.h> |
| 36 |
#endif |
| 37 |
|
| 38 |
#include "mount_fuse.h" |
| 39 |
#include "mount_handle.h" |
| 40 |
#include "vhditools_libcerror.h" |
| 41 |
#include "vhditools_libcnotify.h" |
| 42 |
#include "vhditools_libvhdi.h" |
| 43 |
#include "vhditools_unused.h" |
| 44 |
|
| 45 |
extern mount_handle_t *vhdimount_mount_handle; |
| 46 |
|
| 47 |
#if defined( HAVE_LIBFUSE ) || defined( HAVE_LIBFUSE3 ) || defined( HAVE_LIBOSXFUSE ) |
| 48 |
|
| 49 |
#if ( SIZEOF_OFF_T != 8 ) && ( SIZEOF_OFF_T != 4 ) |
| 50 |
#error Size of off_t not supported |
| 51 |
#endif |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
int mount_fuse_set_stat_info( |
| 58 |
struct stat *stat_info, |
| 59 |
size64_t size, |
| 60 |
uint16_t file_mode, |
| 61 |
int64_t access_time, |
| 62 |
int64_t inode_change_time, |
| 63 |
int64_t modification_time, |
| 64 |
libcerror_error_t **error ) |
| 65 |
{ |
| 66 |
static char *function = "mount_fuse_set_stat_info"; |
| 67 |
|
| 68 |
if( stat_info == NULL ) |
| 69 |
{ |
| 70 |
libcerror_error_set( |
| 71 |
error, |
| 72 |
LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
| 73 |
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
| 74 |
"%s: invalid stat info.", |
| 75 |
function ); |
| 76 |
|
| 77 |
return( -1 ); |
| 78 |
} |
| 79 |
#if SIZEOF_OFF_T <= 4 |
| 80 |
if( size > (size64_t) UINT32_MAX ) |
| 81 |
#else |
| 82 |
if( size > (size64_t) INT64_MAX ) |
| 83 |
#endif |
| 84 |
{ |
| 85 |
libcerror_error_set( |
| 86 |
error, |
| 87 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 88 |
LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS, |
| 89 |
"%s: invalid size value out of bounds.", |
| 90 |
function ); |
| 91 |
|
| 92 |
return( -1 ); |
| 93 |
} |
| 94 |
stat_info->st_size = (off_t) size; |
| 95 |
stat_info->st_mode = file_mode; |
| 96 |
|
| 97 |
if( ( file_mode & 0x4000 ) != 0 ) |
| 98 |
{ |
| 99 |
stat_info->st_nlink = 2; |
| 100 |
} |
| 101 |
else |
| 102 |
{ |
| 103 |
stat_info->st_nlink = 1; |
| 104 |
} |
| 105 |
#if defined( HAVE_GETEUID ) |
| 106 |
stat_info->st_uid = geteuid(); |
| 107 |
#endif |
| 108 |
#if defined( HAVE_GETEGID ) |
| 109 |
stat_info->st_gid = getegid(); |
| 110 |
#endif |
| 111 |
|
| 112 |
stat_info->st_atime = access_time / 1000000000; |
| 113 |
stat_info->st_ctime = inode_change_time / 1000000000; |
| 114 |
stat_info->st_mtime = modification_time / 1000000000; |
| 115 |
|
| 116 |
#if defined( STAT_HAVE_NSEC ) |
| 117 |
stat_info->st_atime_nsec = access_time % 1000000000; |
| 118 |
stat_info->st_ctime_nsec = inode_change_time % 1000000000; |
| 119 |
stat_info->st_mtime_nsec = modification_time % 1000000000; |
| 120 |
#endif |
| 121 |
return( 1 ); |
| 122 |
} |
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
int mount_fuse_filldir( |
| 128 |
void *buffer, |
| 129 |
fuse_fill_dir_t filler, |
| 130 |
const char *name, |
| 131 |
struct stat *stat_info, |
| 132 |
mount_file_entry_t *file_entry, |
| 133 |
libcerror_error_t **error ) |
| 134 |
{ |
| 135 |
static char *function = "mount_fuse_filldir"; |
| 136 |
size64_t file_size = 0; |
| 137 |
uint64_t access_time = 0; |
| 138 |
uint64_t inode_change_time = 0; |
| 139 |
uint64_t modification_time = 0; |
| 140 |
uint16_t file_mode = 0; |
| 141 |
|
| 142 |
if( filler == NULL ) |
| 143 |
{ |
| 144 |
libcerror_error_set( |
| 145 |
error, |
| 146 |
LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
| 147 |
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
| 148 |
"%s: invalid filler.", |
| 149 |
function ); |
| 150 |
|
| 151 |
return( -1 ); |
| 152 |
} |
| 153 |
if( file_entry != NULL ) |
| 154 |
{ |
| 155 |
if( mount_file_entry_get_size( |
| 156 |
file_entry, |
| 157 |
&file_size, |
| 158 |
error ) != 1 ) |
| 159 |
{ |
| 160 |
libcerror_error_set( |
| 161 |
error, |
| 162 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 163 |
LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
| 164 |
"%s: unable to retrieve file entry size.", |
| 165 |
function ); |
| 166 |
|
| 167 |
return( -1 ); |
| 168 |
} |
| 169 |
if( mount_file_entry_get_file_mode( |
| 170 |
file_entry, |
| 171 |
&file_mode, |
| 172 |
error ) != 1 ) |
| 173 |
{ |
| 174 |
libcerror_error_set( |
| 175 |
error, |
| 176 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 177 |
LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
| 178 |
"%s: unable to retrieve file mode.", |
| 179 |
function ); |
| 180 |
|
| 181 |
return( -1 ); |
| 182 |
} |
| 183 |
if( mount_file_entry_get_access_time( |
| 184 |
file_entry, |
| 185 |
&access_time, |
| 186 |
error ) != 1 ) |
| 187 |
{ |
| 188 |
libcerror_error_set( |
| 189 |
error, |
| 190 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 191 |
LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
| 192 |
"%s: unable to retrieve access time.", |
| 193 |
function ); |
| 194 |
|
| 195 |
return( -1 ); |
| 196 |
} |
| 197 |
if( mount_file_entry_get_modification_time( |
| 198 |
file_entry, |
| 199 |
&modification_time, |
| 200 |
error ) != 1 ) |
| 201 |
{ |
| 202 |
libcerror_error_set( |
| 203 |
error, |
| 204 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 205 |
LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
| 206 |
"%s: unable to retrieve modification time.", |
| 207 |
function ); |
| 208 |
|
| 209 |
return( -1 ); |
| 210 |
} |
| 211 |
if( mount_file_entry_get_inode_change_time( |
| 212 |
file_entry, |
| 213 |
&inode_change_time, |
| 214 |
error ) != 1 ) |
| 215 |
{ |
| 216 |
libcerror_error_set( |
| 217 |
error, |
| 218 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 219 |
LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
| 220 |
"%s: unable to retrieve inode change time.", |
| 221 |
function ); |
| 222 |
|
| 223 |
return( -1 ); |
| 224 |
} |
| 225 |
} |
| 226 |
if( memory_set( |
| 227 |
stat_info, |
| 228 |
0, |
| 229 |
sizeof( struct stat ) ) == NULL ) |
| 230 |
{ |
| 231 |
libcerror_error_set( |
| 232 |
error, |
| 233 |
LIBCERROR_ERROR_DOMAIN_MEMORY, |
| 234 |
LIBCERROR_MEMORY_ERROR_SET_FAILED, |
| 235 |
"%s: unable to clear stat info.", |
| 236 |
function ); |
| 237 |
|
| 238 |
return( -1 ); |
| 239 |
} |
| 240 |
if( mount_fuse_set_stat_info( |
| 241 |
stat_info, |
| 242 |
file_size, |
| 243 |
file_mode, |
| 244 |
(int64_t) access_time, |
| 245 |
(int64_t) inode_change_time, |
| 246 |
(int64_t) modification_time, |
| 247 |
error ) != 1 ) |
| 248 |
{ |
| 249 |
libcerror_error_set( |
| 250 |
error, |
| 251 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 252 |
LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
| 253 |
"%s: unable to set stat info.", |
| 254 |
function ); |
| 255 |
|
| 256 |
return( -1 ); |
| 257 |
} |
| 258 |
#if defined( HAVE_LIBFUSE3 ) |
| 259 |
if( filler( |
| 260 |
buffer, |
| 261 |
name, |
| 262 |
stat_info, |
| 263 |
0, |
| 264 |
0 ) == 1 ) |
| 265 |
#else |
| 266 |
if( filler( |
| 267 |
buffer, |
| 268 |
name, |
| 269 |
stat_info, |
| 270 |
0 ) == 1 ) |
| 271 |
#endif |
| 272 |
{ |
| 273 |
libcerror_error_set( |
| 274 |
error, |
| 275 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 276 |
LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
| 277 |
"%s: unable to set directory entry.", |
| 278 |
function ); |
| 279 |
|
| 280 |
return( -1 ); |
| 281 |
} |
| 282 |
return( 1 ); |
| 283 |
} |
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
int mount_fuse_open( |
| 289 |
const char *path, |
| 290 |
struct fuse_file_info *file_info ) |
| 291 |
{ |
| 292 |
libcerror_error_t *error = NULL; |
| 293 |
static char *function = "mount_fuse_open"; |
| 294 |
int result = 0; |
| 295 |
|
| 296 |
#if defined( HAVE_DEBUG_OUTPUT ) |
| 297 |
if( libcnotify_verbose != 0 ) |
| 298 |
{ |
| 299 |
libcnotify_printf( |
| 300 |
"%s: %s\n", |
| 301 |
function, |
| 302 |
path ); |
| 303 |
} |
| 304 |
#endif |
| 305 |
if( path == NULL ) |
| 306 |
{ |
| 307 |
libcerror_error_set( |
| 308 |
&error, |
| 309 |
LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
| 310 |
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
| 311 |
"%s: invalid path.", |
| 312 |
function ); |
| 313 |
|
| 314 |
result = -EINVAL; |
| 315 |
|
| 316 |
goto on_error; |
| 317 |
} |
| 318 |
if( file_info == NULL ) |
| 319 |
{ |
| 320 |
libcerror_error_set( |
| 321 |
&error, |
| 322 |
LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
| 323 |
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
| 324 |
"%s: invalid file information.", |
| 325 |
function ); |
| 326 |
|
| 327 |
result = -EINVAL; |
| 328 |
|
| 329 |
goto on_error; |
| 330 |
} |
| 331 |
if( file_info->fh != (uint64_t) NULL ) |
| 332 |
{ |
| 333 |
libcerror_error_set( |
| 334 |
&error, |
| 335 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 336 |
LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET, |
| 337 |
"%s: invalid file information - file handle already set.", |
| 338 |
function ); |
| 339 |
|
| 340 |
result = -EINVAL; |
| 341 |
|
| 342 |
goto on_error; |
| 343 |
} |
| 344 |
if( ( file_info->flags & 0x03 ) != O_RDONLY ) |
| 345 |
{ |
| 346 |
libcerror_error_set( |
| 347 |
&error, |
| 348 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 349 |
LIBCERROR_RUNTIME_ERROR_UNSUPPORTED_VALUE, |
| 350 |
"%s: write access currently not supported.", |
| 351 |
function ); |
| 352 |
|
| 353 |
result = -EACCES; |
| 354 |
|
| 355 |
goto on_error; |
| 356 |
} |
| 357 |
if( mount_handle_get_file_entry_by_path( |
| 358 |
vhdimount_mount_handle, |
| 359 |
path, |
| 360 |
(mount_file_entry_t **) &( file_info->fh ), |
| 361 |
&error ) != 1 ) |
| 362 |
{ |
| 363 |
libcerror_error_set( |
| 364 |
&error, |
| 365 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 366 |
LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
| 367 |
"%s: unable to retrieve file entry for path: %s.", |
| 368 |
function, |
| 369 |
path ); |
| 370 |
|
| 371 |
result = -ENOENT; |
| 372 |
|
| 373 |
goto on_error; |
| 374 |
} |
| 375 |
return( 0 ); |
| 376 |
|
| 377 |
on_error: |
| 378 |
if( error != NULL ) |
| 379 |
{ |
| 380 |
libcnotify_print_error_backtrace( |
| 381 |
error ); |
| 382 |
libcerror_error_free( |
| 383 |
&error ); |
| 384 |
} |
| 385 |
return( result ); |
| 386 |
} |
| 387 |
|
| 388 |
|
| 389 |
|
| 390 |
|
| 391 |
int mount_fuse_read( |
| 392 |
const char *path, |
| 393 |
char *buffer, |
| 394 |
size_t size, |
| 395 |
off_t offset, |
| 396 |
struct fuse_file_info *file_info ) |
| 397 |
{ |
| 398 |
libcerror_error_t *error = NULL; |
| 399 |
static char *function = "mount_fuse_read"; |
| 400 |
ssize_t read_count = 0; |
| 401 |
int result = 0; |
| 402 |
|
| 403 |
#if defined( HAVE_DEBUG_OUTPUT ) |
| 404 |
if( libcnotify_verbose != 0 ) |
| 405 |
{ |
| 406 |
libcnotify_printf( |
| 407 |
"%s: %s\n", |
| 408 |
function, |
| 409 |
path ); |
| 410 |
} |
| 411 |
#endif |
| 412 |
if( path == NULL ) |
| 413 |
{ |
| 414 |
libcerror_error_set( |
| 415 |
&error, |
| 416 |
LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
| 417 |
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
| 418 |
"%s: invalid path.", |
| 419 |
function ); |
| 420 |
|
| 421 |
result = -EINVAL; |
| 422 |
|
| 423 |
goto on_error; |
| 424 |
} |
| 425 |
if( size > (size_t) INT_MAX ) |
| 426 |
{ |
| 427 |
libcerror_error_set( |
| 428 |
&error, |
| 429 |
LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
| 430 |
LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM, |
| 431 |
"%s: invalid size value exceeds maximum.", |
| 432 |
function ); |
| 433 |
|
| 434 |
result = -EINVAL; |
| 435 |
|
| 436 |
goto on_error; |
| 437 |
} |
| 438 |
if( file_info == NULL ) |
| 439 |
{ |
| 440 |
libcerror_error_set( |
| 441 |
&error, |
| 442 |
LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
| 443 |
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
| 444 |
"%s: invalid file information.", |
| 445 |
function ); |
| 446 |
|
| 447 |
result = -EINVAL; |
| 448 |
|
| 449 |
goto on_error; |
| 450 |
} |
| 451 |
if( file_info->fh == (uint64_t) NULL ) |
| 452 |
{ |
| 453 |
libcerror_error_set( |
| 454 |
&error, |
| 455 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 456 |
LIBCERROR_RUNTIME_ERROR_VALUE_MISSING, |
| 457 |
"%s: invalid file information - missing file handle.", |
| 458 |
function ); |
| 459 |
|
| 460 |
result = -EINVAL; |
| 461 |
|
| 462 |
goto on_error; |
| 463 |
} |
| 464 |
read_count = mount_file_entry_read_buffer_at_offset( |
| 465 |
(mount_file_entry_t *) file_info->fh, |
| 466 |
(void *) buffer, |
| 467 |
size, |
| 468 |
(off64_t) offset, |
| 469 |
&error ); |
| 470 |
|
| 471 |
if( read_count < 0 ) |
| 472 |
{ |
| 473 |
libcerror_error_set( |
| 474 |
&error, |
| 475 |
LIBCERROR_ERROR_DOMAIN_IO, |
| 476 |
LIBCERROR_IO_ERROR_READ_FAILED, |
| 477 |
"%s: unable to read from file entry.", |
| 478 |
function ); |
| 479 |
|
| 480 |
result = -EIO; |
| 481 |
|
| 482 |
goto on_error; |
| 483 |
} |
| 484 |
return( (int) read_count ); |
| 485 |
|
| 486 |
on_error: |
| 487 |
if( error != NULL ) |
| 488 |
{ |
| 489 |
libcnotify_print_error_backtrace( |
| 490 |
error ); |
| 491 |
libcerror_error_free( |
| 492 |
&error ); |
| 493 |
} |
| 494 |
return( result ); |
| 495 |
} |
| 496 |
|
| 497 |
|
| 498 |
|
| 499 |
|
| 500 |
int mount_fuse_release( |
| 501 |
const char *path, |
| 502 |
struct fuse_file_info *file_info ) |
| 503 |
{ |
| 504 |
libcerror_error_t *error = NULL; |
| 505 |
static char *function = "mount_fuse_release"; |
| 506 |
int result = 0; |
| 507 |
|
| 508 |
#if defined( HAVE_DEBUG_OUTPUT ) |
| 509 |
if( libcnotify_verbose != 0 ) |
| 510 |
{ |
| 511 |
libcnotify_printf( |
| 512 |
"%s: %s\n", |
| 513 |
function, |
| 514 |
path ); |
| 515 |
} |
| 516 |
#endif |
| 517 |
if( path == NULL ) |
| 518 |
{ |
| 519 |
libcerror_error_set( |
| 520 |
&error, |
| 521 |
LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
| 522 |
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
| 523 |
"%s: invalid path.", |
| 524 |
function ); |
| 525 |
|
| 526 |
result = -EINVAL; |
| 527 |
|
| 528 |
goto on_error; |
| 529 |
} |
| 530 |
if( file_info == NULL ) |
| 531 |
{ |
| 532 |
libcerror_error_set( |
| 533 |
&error, |
| 534 |
LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
| 535 |
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
| 536 |
"%s: invalid file information.", |
| 537 |
function ); |
| 538 |
|
| 539 |
result = -EINVAL; |
| 540 |
|
| 541 |
goto on_error; |
| 542 |
} |
| 543 |
if( file_info->fh != (uint64_t) NULL ) |
| 544 |
{ |
| 545 |
if( mount_file_entry_free( |
| 546 |
(mount_file_entry_t **) &( file_info->fh ), |
| 547 |
&error ) != 1 ) |
| 548 |
{ |
| 549 |
libcerror_error_set( |
| 550 |
&error, |
| 551 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 552 |
LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED, |
| 553 |
"%s: unable to free file entry.", |
| 554 |
function ); |
| 555 |
|
| 556 |
result = -ENOENT; |
| 557 |
|
| 558 |
goto on_error; |
| 559 |
} |
| 560 |
} |
| 561 |
return( 0 ); |
| 562 |
|
| 563 |
on_error: |
| 564 |
if( error != NULL ) |
| 565 |
{ |
| 566 |
libcnotify_print_error_backtrace( |
| 567 |
error ); |
| 568 |
libcerror_error_free( |
| 569 |
&error ); |
| 570 |
} |
| 571 |
return( result ); |
| 572 |
} |
| 573 |
|
| 574 |
|
| 575 |
|
| 576 |
|
| 577 |
int mount_fuse_opendir( |
| 578 |
const char *path, |
| 579 |
struct fuse_file_info *file_info ) |
| 580 |
{ |
| 581 |
libcerror_error_t *error = NULL; |
| 582 |
static char *function = "mount_fuse_opendir"; |
| 583 |
int result = 0; |
| 584 |
|
| 585 |
#if defined( HAVE_DEBUG_OUTPUT ) |
| 586 |
if( libcnotify_verbose != 0 ) |
| 587 |
{ |
| 588 |
libcnotify_printf( |
| 589 |
"%s: %s\n", |
| 590 |
function, |
| 591 |
path ); |
| 592 |
} |
| 593 |
#endif |
| 594 |
if( path == NULL ) |
| 595 |
{ |
| 596 |
libcerror_error_set( |
| 597 |
&error, |
| 598 |
LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
| 599 |
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
| 600 |
"%s: invalid path.", |
| 601 |
function ); |
| 602 |
|
| 603 |
result = -EINVAL; |
| 604 |
|
| 605 |
goto on_error; |
| 606 |
} |
| 607 |
if( file_info == NULL ) |
| 608 |
{ |
| 609 |
libcerror_error_set( |
| 610 |
&error, |
| 611 |
LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
| 612 |
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
| 613 |
"%s: invalid file information.", |
| 614 |
function ); |
| 615 |
|
| 616 |
result = -EINVAL; |
| 617 |
|
| 618 |
goto on_error; |
| 619 |
} |
| 620 |
if( file_info->fh != (uint64_t) NULL ) |
| 621 |
{ |
| 622 |
libcerror_error_set( |
| 623 |
&error, |
| 624 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 625 |
LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET, |
| 626 |
"%s: invalid file information - file handle already set.", |
| 627 |
function ); |
| 628 |
|
| 629 |
result = -EINVAL; |
| 630 |
|
| 631 |
goto on_error; |
| 632 |
} |
| 633 |
if( mount_handle_get_file_entry_by_path( |
| 634 |
vhdimount_mount_handle, |
| 635 |
path, |
| 636 |
(mount_file_entry_t **) &( file_info->fh ), |
| 637 |
&error ) != 1 ) |
| 638 |
{ |
| 639 |
libcerror_error_set( |
| 640 |
&error, |
| 641 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 642 |
LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
| 643 |
"%s: unable to retrieve file entry for path: %s.", |
| 644 |
function, |
| 645 |
path ); |
| 646 |
|
| 647 |
result = -ENOENT; |
| 648 |
|
| 649 |
goto on_error; |
| 650 |
} |
| 651 |
return( 0 ); |
| 652 |
|
| 653 |
on_error: |
| 654 |
if( error != NULL ) |
| 655 |
{ |
| 656 |
libcnotify_print_error_backtrace( |
| 657 |
error ); |
| 658 |
libcerror_error_free( |
| 659 |
&error ); |
| 660 |
} |
| 661 |
return( result ); |
| 662 |
} |
| 663 |
|
| 664 |
|
| 665 |
|
| 666 |
|
| 667 |
#if defined( HAVE_LIBFUSE3 ) |
| 668 |
int mount_fuse_readdir( |
| 669 |
const char *path, |
| 670 |
void *buffer, |
| 671 |
fuse_fill_dir_t filler, |
| 672 |
off_t offset VHDITOOLS_ATTRIBUTE_UNUSED, |
| 673 |
struct fuse_file_info *file_info VHDITOOLS_ATTRIBUTE_UNUSED, |
| 674 |
enum fuse_readdir_flags flags VHDITOOLS_ATTRIBUTE_UNUSED ) |
| 675 |
#else |
| 676 |
int mount_fuse_readdir( |
| 677 |
const char *path, |
| 678 |
void *buffer, |
| 679 |
fuse_fill_dir_t filler, |
| 680 |
off_t offset VHDITOOLS_ATTRIBUTE_UNUSED, |
| 681 |
struct fuse_file_info *file_info VHDITOOLS_ATTRIBUTE_UNUSED ) |
| 682 |
#endif |
| 683 |
{ |
| 684 |
struct stat *stat_info = NULL; |
| 685 |
libcerror_error_t *error = NULL; |
| 686 |
mount_file_entry_t *parent_file_entry = NULL; |
| 687 |
mount_file_entry_t *sub_file_entry = NULL; |
| 688 |
static char *function = "mount_fuse_readdir"; |
| 689 |
char *name = NULL; |
| 690 |
size_t name_size = 0; |
| 691 |
int number_of_sub_file_entries = 0; |
| 692 |
int result = 0; |
| 693 |
int sub_file_entry_index = 0; |
| 694 |
|
| 695 |
VHDITOOLS_UNREFERENCED_PARAMETER( offset ) |
| 696 |
|
| 697 |
#if defined( HAVE_LIBFUSE3 ) |
| 698 |
VHDITOOLS_UNREFERENCED_PARAMETER( flags ) |
| 699 |
#endif |
| 700 |
|
| 701 |
#if defined( HAVE_DEBUG_OUTPUT ) |
| 702 |
if( libcnotify_verbose != 0 ) |
| 703 |
{ |
| 704 |
libcnotify_printf( |
| 705 |
"%s: %s\n", |
| 706 |
function, |
| 707 |
path ); |
| 708 |
} |
| 709 |
#endif |
| 710 |
if( path == NULL ) |
| 711 |
{ |
| 712 |
libcerror_error_set( |
| 713 |
&error, |
| 714 |
LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
| 715 |
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
| 716 |
"%s: invalid path.", |
| 717 |
function ); |
| 718 |
|
| 719 |
result = -EINVAL; |
| 720 |
|
| 721 |
goto on_error; |
| 722 |
} |
| 723 |
if( file_info == NULL ) |
| 724 |
{ |
| 725 |
libcerror_error_set( |
| 726 |
&error, |
| 727 |
LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
| 728 |
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
| 729 |
"%s: invalid file information.", |
| 730 |
function ); |
| 731 |
|
| 732 |
result = -EINVAL; |
| 733 |
|
| 734 |
goto on_error; |
| 735 |
} |
| 736 |
if( file_info->fh == (uint64_t) NULL ) |
| 737 |
{ |
| 738 |
libcerror_error_set( |
| 739 |
&error, |
| 740 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 741 |
LIBCERROR_RUNTIME_ERROR_VALUE_MISSING, |
| 742 |
"%s: invalid file information - missing file handle.", |
| 743 |
function ); |
| 744 |
|
| 745 |
result = -EINVAL; |
| 746 |
|
| 747 |
goto on_error; |
| 748 |
} |
| 749 |
stat_info = memory_allocate_structure( |
| 750 |
struct stat ); |
| 751 |
|
| 752 |
if( stat_info == NULL ) |
| 753 |
{ |
| 754 |
libcerror_error_set( |
| 755 |
&error, |
| 756 |
LIBCERROR_ERROR_DOMAIN_MEMORY, |
| 757 |
LIBCERROR_MEMORY_ERROR_INSUFFICIENT, |
| 758 |
"%s: unable to create stat info.", |
| 759 |
function ); |
| 760 |
|
| 761 |
result = errno; |
| 762 |
|
| 763 |
goto on_error; |
| 764 |
} |
| 765 |
if( mount_fuse_filldir( |
| 766 |
buffer, |
| 767 |
filler, |
| 768 |
".", |
| 769 |
stat_info, |
| 770 |
(mount_file_entry_t *) file_info->fh, |
| 771 |
&error ) != 1 ) |
| 772 |
{ |
| 773 |
libcerror_error_set( |
| 774 |
&error, |
| 775 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 776 |
LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
| 777 |
"%s: unable to set self directory entry.", |
| 778 |
function ); |
| 779 |
|
| 780 |
result = -EIO; |
| 781 |
|
| 782 |
goto on_error; |
| 783 |
} |
| 784 |
result = mount_file_entry_get_parent_file_entry( |
| 785 |
(mount_file_entry_t *) file_info->fh, |
| 786 |
&parent_file_entry, |
| 787 |
&error ); |
| 788 |
|
| 789 |
if( result == -1 ) |
| 790 |
{ |
| 791 |
libcerror_error_set( |
| 792 |
&error, |
| 793 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 794 |
LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
| 795 |
"%s: unable to retrieve parent file entry.", |
| 796 |
function ); |
| 797 |
|
| 798 |
result = -EIO; |
| 799 |
|
| 800 |
goto on_error; |
| 801 |
} |
| 802 |
if( mount_fuse_filldir( |
| 803 |
buffer, |
| 804 |
filler, |
| 805 |
"..", |
| 806 |
stat_info, |
| 807 |
parent_file_entry, |
| 808 |
&error ) != 1 ) |
| 809 |
{ |
| 810 |
libcerror_error_set( |
| 811 |
&error, |
| 812 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 813 |
LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
| 814 |
"%s: unable to set parent directory entry.", |
| 815 |
function ); |
| 816 |
|
| 817 |
result = -EIO; |
| 818 |
|
| 819 |
goto on_error; |
| 820 |
} |
| 821 |
if( mount_file_entry_free( |
| 822 |
&parent_file_entry, |
| 823 |
&error ) != 1 ) |
| 824 |
{ |
| 825 |
libcerror_error_set( |
| 826 |
&error, |
| 827 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 828 |
LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED, |
| 829 |
"%s: unable to free parent file entry.", |
| 830 |
function ); |
| 831 |
|
| 832 |
result = -EIO; |
| 833 |
|
| 834 |
goto on_error; |
| 835 |
} |
| 836 |
if( mount_file_entry_get_number_of_sub_file_entries( |
| 837 |
(mount_file_entry_t *) file_info->fh, |
| 838 |
&number_of_sub_file_entries, |
| 839 |
&error ) != 1 ) |
| 840 |
{ |
| 841 |
libcerror_error_set( |
| 842 |
&error, |
| 843 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 844 |
LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
| 845 |
"%s: unable to retrieve number of sub file entries.", |
| 846 |
function ); |
| 847 |
|
| 848 |
result = -EIO; |
| 849 |
|
| 850 |
goto on_error; |
| 851 |
} |
| 852 |
for( sub_file_entry_index = 0; |
| 853 |
sub_file_entry_index < number_of_sub_file_entries; |
| 854 |
sub_file_entry_index++ ) |
| 855 |
{ |
| 856 |
if( mount_file_entry_get_sub_file_entry_by_index( |
| 857 |
(mount_file_entry_t *) file_info->fh, |
| 858 |
sub_file_entry_index, |
| 859 |
&sub_file_entry, |
| 860 |
&error ) != 1 ) |
| 861 |
{ |
| 862 |
libcerror_error_set( |
| 863 |
&error, |
| 864 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 865 |
LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
| 866 |
"%s: unable to retrieve sub file entry: %d.", |
| 867 |
function, |
| 868 |
sub_file_entry_index ); |
| 869 |
|
| 870 |
result = -EIO; |
| 871 |
|
| 872 |
goto on_error; |
| 873 |
} |
| 874 |
if( mount_file_entry_get_name_size( |
| 875 |
sub_file_entry, |
| 876 |
&name_size, |
| 877 |
&error ) != 1 ) |
| 878 |
{ |
| 879 |
libcerror_error_set( |
| 880 |
&error, |
| 881 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 882 |
LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
| 883 |
"%s: unable to retrieve sub file entry: %d name size.", |
| 884 |
function, |
| 885 |
sub_file_entry_index ); |
| 886 |
|
| 887 |
result = -EIO; |
| 888 |
|
| 889 |
goto on_error; |
| 890 |
} |
| 891 |
name = narrow_string_allocate( |
| 892 |
name_size ); |
| 893 |
|
| 894 |
if( name == NULL ) |
| 895 |
{ |
| 896 |
libcerror_error_set( |
| 897 |
&error, |
| 898 |
LIBCERROR_ERROR_DOMAIN_MEMORY, |
| 899 |
LIBCERROR_MEMORY_ERROR_INSUFFICIENT, |
| 900 |
"%s: unable to create sub file entry: %d name.", |
| 901 |
function ); |
| 902 |
|
| 903 |
result = -EIO; |
| 904 |
|
| 905 |
goto on_error; |
| 906 |
} |
| 907 |
if( mount_file_entry_get_name( |
| 908 |
sub_file_entry, |
| 909 |
name, |
| 910 |
name_size, |
| 911 |
&error ) != 1 ) |
| 912 |
{ |
| 913 |
libcerror_error_set( |
| 914 |
&error, |
| 915 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 916 |
LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
| 917 |
"%s: unable to retrieve sub file entry: %d name.", |
| 918 |
function, |
| 919 |
sub_file_entry_index ); |
| 920 |
|
| 921 |
result = -EIO; |
| 922 |
|
| 923 |
goto on_error; |
| 924 |
} |
| 925 |
if( mount_fuse_filldir( |
| 926 |
buffer, |
| 927 |
filler, |
| 928 |
name, |
| 929 |
stat_info, |
| 930 |
sub_file_entry, |
| 931 |
&error ) != 1 ) |
| 932 |
{ |
| 933 |
libcerror_error_set( |
| 934 |
&error, |
| 935 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 936 |
LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
| 937 |
"%s: unable to set directory entry.", |
| 938 |
function ); |
| 939 |
|
| 940 |
result = -EIO; |
| 941 |
|
| 942 |
goto on_error; |
| 943 |
} |
| 944 |
memory_free( |
| 945 |
name ); |
| 946 |
|
| 947 |
name = NULL; |
| 948 |
|
| 949 |
if( mount_file_entry_free( |
| 950 |
&sub_file_entry, |
| 951 |
&error ) != 1 ) |
| 952 |
{ |
| 953 |
libcerror_error_set( |
| 954 |
&error, |
| 955 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 956 |
LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED, |
| 957 |
"%s: unable to free sub file entry: %d.", |
| 958 |
function, |
| 959 |
sub_file_entry_index ); |
| 960 |
|
| 961 |
result = -EIO; |
| 962 |
|
| 963 |
goto on_error; |
| 964 |
} |
| 965 |
} |
| 966 |
memory_free( |
| 967 |
stat_info ); |
| 968 |
|
| 969 |
return( 0 ); |
| 970 |
|
| 971 |
on_error: |
| 972 |
if( error != NULL ) |
| 973 |
{ |
| 974 |
libcnotify_print_error_backtrace( |
| 975 |
error ); |
| 976 |
libcerror_error_free( |
| 977 |
&error ); |
| 978 |
} |
| 979 |
if( name != NULL ) |
| 980 |
{ |
| 981 |
memory_free( |
| 982 |
name ); |
| 983 |
} |
| 984 |
if( sub_file_entry != NULL ) |
| 985 |
{ |
| 986 |
mount_file_entry_free( |
| 987 |
&sub_file_entry, |
| 988 |
NULL ); |
| 989 |
} |
| 990 |
if( parent_file_entry != NULL ) |
| 991 |
{ |
| 992 |
mount_file_entry_free( |
| 993 |
&parent_file_entry, |
| 994 |
NULL ); |
| 995 |
} |
| 996 |
if( stat_info != NULL ) |
| 997 |
{ |
| 998 |
memory_free( |
| 999 |
stat_info ); |
| 1000 |
} |
| 1001 |
return( result ); |
| 1002 |
} |
| 1003 |
|
| 1004 |
|
| 1005 |
|
| 1006 |
|
| 1007 |
int mount_fuse_releasedir( |
| 1008 |
const char *path, |
| 1009 |
struct fuse_file_info *file_info ) |
| 1010 |
{ |
| 1011 |
libcerror_error_t *error = NULL; |
| 1012 |
static char *function = "mount_fuse_releasedir"; |
| 1013 |
int result = 0; |
| 1014 |
|
| 1015 |
#if defined( HAVE_DEBUG_OUTPUT ) |
| 1016 |
if( libcnotify_verbose != 0 ) |
| 1017 |
{ |
| 1018 |
libcnotify_printf( |
| 1019 |
"%s: %s\n", |
| 1020 |
function, |
| 1021 |
path ); |
| 1022 |
} |
| 1023 |
#endif |
| 1024 |
if( path == NULL ) |
| 1025 |
{ |
| 1026 |
libcerror_error_set( |
| 1027 |
&error, |
| 1028 |
LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
| 1029 |
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
| 1030 |
"%s: invalid path.", |
| 1031 |
function ); |
| 1032 |
|
| 1033 |
result = -EINVAL; |
| 1034 |
|
| 1035 |
goto on_error; |
| 1036 |
} |
| 1037 |
if( file_info == NULL ) |
| 1038 |
{ |
| 1039 |
libcerror_error_set( |
| 1040 |
&error, |
| 1041 |
LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
| 1042 |
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
| 1043 |
"%s: invalid file information.", |
| 1044 |
function ); |
| 1045 |
|
| 1046 |
result = -EINVAL; |
| 1047 |
|
| 1048 |
goto on_error; |
| 1049 |
} |
| 1050 |
if( file_info->fh != (uint64_t) NULL ) |
| 1051 |
{ |
| 1052 |
file_info->fh = (uint64_t) NULL; |
| 1053 |
} |
| 1054 |
return( 0 ); |
| 1055 |
|
| 1056 |
on_error: |
| 1057 |
if( error != NULL ) |
| 1058 |
{ |
| 1059 |
libcnotify_print_error_backtrace( |
| 1060 |
error ); |
| 1061 |
libcerror_error_free( |
| 1062 |
&error ); |
| 1063 |
} |
| 1064 |
return( result ); |
| 1065 |
} |
| 1066 |
|
| 1067 |
|
| 1068 |
|
| 1069 |
|
| 1070 |
#if defined( HAVE_LIBFUSE3 ) |
| 1071 |
int mount_fuse_getattr( |
| 1072 |
const char *path, |
| 1073 |
struct stat *stat_info, |
| 1074 |
struct fuse_file_info *file_info VHDITOOLS_ATTRIBUTE_UNUSED ) |
| 1075 |
#else |
| 1076 |
int mount_fuse_getattr( |
| 1077 |
const char *path, |
| 1078 |
struct stat *stat_info ) |
| 1079 |
#endif |
| 1080 |
{ |
| 1081 |
libcerror_error_t *error = NULL; |
| 1082 |
mount_file_entry_t *file_entry = NULL; |
| 1083 |
static char *function = "mount_fuse_getattr"; |
| 1084 |
size64_t file_size = 0; |
| 1085 |
uint64_t access_time = 0; |
| 1086 |
uint64_t inode_change_time = 0; |
| 1087 |
uint64_t modification_time = 0; |
| 1088 |
uint16_t file_mode = 0; |
| 1089 |
int result = 0; |
| 1090 |
|
| 1091 |
#if defined( HAVE_LIBFUSE3 ) |
| 1092 |
VHDITOOLS_UNREFERENCED_PARAMETER( file_info ) |
| 1093 |
#endif |
| 1094 |
|
| 1095 |
#if defined( HAVE_DEBUG_OUTPUT ) |
| 1096 |
if( libcnotify_verbose != 0 ) |
| 1097 |
{ |
| 1098 |
libcnotify_printf( |
| 1099 |
"%s: %s\n", |
| 1100 |
function, |
| 1101 |
path ); |
| 1102 |
} |
| 1103 |
#endif |
| 1104 |
if( path == NULL ) |
| 1105 |
{ |
| 1106 |
libcerror_error_set( |
| 1107 |
&error, |
| 1108 |
LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
| 1109 |
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
| 1110 |
"%s: invalid path.", |
| 1111 |
function ); |
| 1112 |
|
| 1113 |
result = -EINVAL; |
| 1114 |
|
| 1115 |
goto on_error; |
| 1116 |
} |
| 1117 |
if( stat_info == NULL ) |
| 1118 |
{ |
| 1119 |
libcerror_error_set( |
| 1120 |
&error, |
| 1121 |
LIBCERROR_ERROR_DOMAIN_ARGUMENTS, |
| 1122 |
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE, |
| 1123 |
"%s: invalid stat info.", |
| 1124 |
function ); |
| 1125 |
|
| 1126 |
result = -EINVAL; |
| 1127 |
|
| 1128 |
goto on_error; |
| 1129 |
} |
| 1130 |
if( memory_set( |
| 1131 |
stat_info, |
| 1132 |
0, |
| 1133 |
sizeof( struct stat ) ) == NULL ) |
| 1134 |
{ |
| 1135 |
libcerror_error_set( |
| 1136 |
&error, |
| 1137 |
LIBCERROR_ERROR_DOMAIN_MEMORY, |
| 1138 |
LIBCERROR_MEMORY_ERROR_SET_FAILED, |
| 1139 |
"%s: unable to clear stat info.", |
| 1140 |
function ); |
| 1141 |
|
| 1142 |
result = errno; |
| 1143 |
|
| 1144 |
goto on_error; |
| 1145 |
} |
| 1146 |
result = mount_handle_get_file_entry_by_path( |
| 1147 |
vhdimount_mount_handle, |
| 1148 |
path, |
| 1149 |
&file_entry, |
| 1150 |
&error ); |
| 1151 |
|
| 1152 |
if( result == -1 ) |
| 1153 |
{ |
| 1154 |
libcerror_error_set( |
| 1155 |
&error, |
| 1156 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 1157 |
LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
| 1158 |
"%s: unable to retrieve value for: %s.", |
| 1159 |
function, |
| 1160 |
path ); |
| 1161 |
|
| 1162 |
result = -ENOENT; |
| 1163 |
|
| 1164 |
goto on_error; |
| 1165 |
} |
| 1166 |
else if( result == 0 ) |
| 1167 |
{ |
| 1168 |
return( -ENOENT ); |
| 1169 |
} |
| 1170 |
if( mount_file_entry_get_size( |
| 1171 |
file_entry, |
| 1172 |
&file_size, |
| 1173 |
&error ) != 1 ) |
| 1174 |
{ |
| 1175 |
libcerror_error_set( |
| 1176 |
&error, |
| 1177 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 1178 |
LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
| 1179 |
"%s: unable to retrieve file entry size.", |
| 1180 |
function ); |
| 1181 |
|
| 1182 |
result = -EIO; |
| 1183 |
|
| 1184 |
goto on_error; |
| 1185 |
} |
| 1186 |
if( mount_file_entry_get_file_mode( |
| 1187 |
file_entry, |
| 1188 |
&file_mode, |
| 1189 |
&error ) != 1 ) |
| 1190 |
{ |
| 1191 |
libcerror_error_set( |
| 1192 |
&error, |
| 1193 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 1194 |
LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
| 1195 |
"%s: unable to retrieve file mode.", |
| 1196 |
function ); |
| 1197 |
|
| 1198 |
result = -EIO; |
| 1199 |
|
| 1200 |
goto on_error; |
| 1201 |
} |
| 1202 |
if( mount_file_entry_get_access_time( |
| 1203 |
file_entry, |
| 1204 |
&access_time, |
| 1205 |
&error ) != 1 ) |
| 1206 |
{ |
| 1207 |
libcerror_error_set( |
| 1208 |
&error, |
| 1209 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 1210 |
LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
| 1211 |
"%s: unable to retrieve access time.", |
| 1212 |
function ); |
| 1213 |
|
| 1214 |
result = -EIO; |
| 1215 |
|
| 1216 |
goto on_error; |
| 1217 |
} |
| 1218 |
if( mount_file_entry_get_modification_time( |
| 1219 |
file_entry, |
| 1220 |
&modification_time, |
| 1221 |
&error ) != 1 ) |
| 1222 |
{ |
| 1223 |
libcerror_error_set( |
| 1224 |
&error, |
| 1225 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 1226 |
LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
| 1227 |
"%s: unable to retrieve modification time.", |
| 1228 |
function ); |
| 1229 |
|
| 1230 |
result = -EIO; |
| 1231 |
|
| 1232 |
goto on_error; |
| 1233 |
} |
| 1234 |
if( mount_file_entry_get_inode_change_time( |
| 1235 |
file_entry, |
| 1236 |
&inode_change_time, |
| 1237 |
&error ) != 1 ) |
| 1238 |
{ |
| 1239 |
libcerror_error_set( |
| 1240 |
&error, |
| 1241 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 1242 |
LIBCERROR_RUNTIME_ERROR_GET_FAILED, |
| 1243 |
"%s: unable to retrieve inode change time.", |
| 1244 |
function ); |
| 1245 |
|
| 1246 |
result = -EIO; |
| 1247 |
|
| 1248 |
goto on_error; |
| 1249 |
} |
| 1250 |
if( mount_fuse_set_stat_info( |
| 1251 |
stat_info, |
| 1252 |
file_size, |
| 1253 |
file_mode, |
| 1254 |
(int64_t) access_time, |
| 1255 |
(int64_t) inode_change_time, |
| 1256 |
(int64_t) modification_time, |
| 1257 |
&error ) != 1 ) |
| 1258 |
{ |
| 1259 |
libcerror_error_set( |
| 1260 |
&error, |
| 1261 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 1262 |
LIBCERROR_RUNTIME_ERROR_SET_FAILED, |
| 1263 |
"%s: unable to set stat info.", |
| 1264 |
function ); |
| 1265 |
|
| 1266 |
result = -EIO; |
| 1267 |
|
| 1268 |
goto on_error; |
| 1269 |
} |
| 1270 |
if( mount_file_entry_free( |
| 1271 |
&file_entry, |
| 1272 |
&error ) != 1 ) |
| 1273 |
{ |
| 1274 |
libcerror_error_set( |
| 1275 |
&error, |
| 1276 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 1277 |
LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED, |
| 1278 |
"%s: unable to free file entry.", |
| 1279 |
function ); |
| 1280 |
|
| 1281 |
result = -EIO; |
| 1282 |
|
| 1283 |
goto on_error; |
| 1284 |
} |
| 1285 |
return( 0 ); |
| 1286 |
|
| 1287 |
on_error: |
| 1288 |
if( error != NULL ) |
| 1289 |
{ |
| 1290 |
libcnotify_print_error_backtrace( |
| 1291 |
error ); |
| 1292 |
libcerror_error_free( |
| 1293 |
&error ); |
| 1294 |
} |
| 1295 |
if( file_entry != NULL ) |
| 1296 |
{ |
| 1297 |
mount_file_entry_free( |
| 1298 |
&file_entry, |
| 1299 |
NULL ); |
| 1300 |
} |
| 1301 |
return( result ); |
| 1302 |
} |
| 1303 |
|
| 1304 |
|
| 1305 |
|
| 1306 |
void mount_fuse_destroy( |
| 1307 |
void *private_data VHDITOOLS_ATTRIBUTE_UNUSED ) |
| 1308 |
{ |
| 1309 |
libcerror_error_t *error = NULL; |
| 1310 |
static char *function = "mount_fuse_destroy"; |
| 1311 |
|
| 1312 |
VHDITOOLS_UNREFERENCED_PARAMETER( private_data ) |
| 1313 |
|
| 1314 |
#if defined( HAVE_DEBUG_OUTPUT ) |
| 1315 |
if( libcnotify_verbose != 0 ) |
| 1316 |
{ |
| 1317 |
libcnotify_printf( |
| 1318 |
"%s\n", |
| 1319 |
function ); |
| 1320 |
} |
| 1321 |
#endif |
| 1322 |
if( vhdimount_mount_handle != NULL ) |
| 1323 |
{ |
| 1324 |
if( mount_handle_free( |
| 1325 |
&vhdimount_mount_handle, |
| 1326 |
&error ) != 1 ) |
| 1327 |
{ |
| 1328 |
libcerror_error_set( |
| 1329 |
&error, |
| 1330 |
LIBCERROR_ERROR_DOMAIN_RUNTIME, |
| 1331 |
LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED, |
| 1332 |
"%s: unable to free mount handle.", |
| 1333 |
function ); |
| 1334 |
|
| 1335 |
goto on_error; |
| 1336 |
} |
| 1337 |
} |
| 1338 |
return; |
| 1339 |
|
| 1340 |
on_error: |
| 1341 |
if( error != NULL ) |
| 1342 |
{ |
| 1343 |
libcnotify_print_error_backtrace( |
| 1344 |
error ); |
| 1345 |
libcerror_error_free( |
| 1346 |
&error ); |
| 1347 |
} |
| 1348 |
return; |
| 1349 |
} |
| 1350 |
|
| 1351 |
#endif |
| 1352 |
|