- Timestamp:
- Sep 12, 2007 11:45:18 AM (17 years ago)
- Location:
- trunk/src/VBox/Additions/linux
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/linux/module/Makefile.module
r4707 r4729 36 36 strformatrt.o \ 37 37 strformat-vbox.o \ 38 divdi3.o \ 39 moddi3.o \ 38 40 udivdi3.o \ 39 41 umoddi3.o \ -
trunk/src/VBox/Additions/linux/module/files_vboxadd
r4707 r4729 48 48 ${PATH_ROOT}/src/VBox/Runtime/include/internal/magics.h=>include/internal/magics.h \ 49 49 ${PATH_ROOT}/src/VBox/Runtime/include/internal/string.h=>include/internal/string.h \ 50 ${PATH_ROOT}/src/VBox/Runtime/math/gcc/divdi3.c=>divdi3.c \ 51 ${PATH_ROOT}/src/VBox/Runtime/math/gcc/moddi3.c=>moddi3.c \ 50 52 ${PATH_ROOT}/src/VBox/Runtime/math/gcc/qdivrem.c=>qdivrem.c \ 51 53 ${PATH_ROOT}/src/VBox/Runtime/math/gcc/quad.h=>quad.h \ -
trunk/src/VBox/Additions/linux/sharedfolders/Makefile.kmk
r4707 r4729 44 44 # 45 45 vboxvfs_TEMPLATE = VBOXLNX32GUESTR0 46 vboxvfs_DEFS := KBUILD_MODNAME=KBUILD_STR\(vboxadd\) KBUILD_BASENAME=KBUILD_STR\(vboxadd\) MODULE IN_RING0 IN_RT_R0 VBOXGUEST VBOX_HGCM 46 vboxvfs_DEFS := KBUILD_MODNAME=KBUILD_STR\(vboxadd\) \ 47 KBUILD_BASENAME=KBUILD_STR\(vboxadd\) \ 48 MODULE IN_RING0 IN_RT_R0 VBOXGUEST VBOX_HGCM 47 49 vboxvfs_LIBS = $(PATH_LIB)/VBoxGuestLibLinux.a $(PATH_LIB)/RuntimeLnx32GuestR0.a 48 vboxvfs_SOURCES = vfsmod.c 50 vboxvfs_SOURCES = \ 51 vfsmod.c \ 52 utils.c \ 53 dirops.c \ 54 regops.c 49 55 vboxvfs_NOINST = 1 50 56 vboxvfs_CFLAGS += -fshort-wchar -
trunk/src/VBox/Additions/linux/sharedfolders/Makefile.module
r4707 r4729 18 18 OBJS = \ 19 19 vfsmod.o \ 20 dirops.o \ 21 regops.o \ 22 utils.o \ 20 23 GenericRequest.o \ 21 24 SysHlp.o \ … … 28 31 r0drv/linux/alloc-r0drv-linux.o \ 29 32 r0drv/linux/semaphore-r0drv-linux.o 33 #ifdef DEBUG 34 OBJS += \ 35 divdi3.o \ 36 moddi3.o \ 37 udivdi3.o \ 38 umoddi3.o \ 39 qdivrem.o 40 #endif 41 42 30 43 EXTRA_CFLAGS = -fshort-wchar 31 44 -
trunk/src/VBox/Additions/linux/sharedfolders/dirops.c
r4071 r4729 17 17 */ 18 18 19 #include "vfsmod.h" 20 19 21 static int 20 22 sf_dir_open (struct inode *inode, struct file *file) … … 32 34 33 35 if (file->private_data) { 34 elog("dir_open called on already opened directory %s\n",35 sf_i->path->String.utf8);36 LogFunc(("dir_open called on already opened directory %s\n", 37 sf_i->path->String.utf8)); 36 38 return 0; 37 39 } … … 40 42 41 43 if (!sf_d) { 42 elog ("could not allocate directory info for %s\n", 43 sf_i->path->String.utf8); 44 LogRelPrintFunc("could not allocate directory info for"); 45 LogRelPrint(sf_i->path->String.utf8); 46 LogRelPrint("\n"); 44 47 return -ENOMEM; 45 48 } … … 51 54 ; 52 55 56 LogFunc(("sf_dir_open: calling vboxCallCreate, folder %s, flags %#x\n", 57 sf_i->path->String.utf8, params.CreateFlags)); 53 58 rc = vboxCallCreate (&client_handle, &sf_g->map, sf_i->path, ¶ms); 54 59 if (VBOX_FAILURE (rc)) { 55 elog ("vboxCallCreate(%s) failed rc=%d\n",56 sf_i->path->String.utf8, rc);60 LogFunc(("vboxCallCreate(%s) failed rc=%Vrc\n", 61 sf_i->path->String.utf8, rc)); 57 62 sf_dir_info_free (sf_d); 58 63 return -EPERM; … … 60 65 61 66 if (params.Result != SHFL_FILE_EXISTS) { 62 elog ("directory %s does not exist\n", sf_i->path->String.utf8);67 LogFunc(("directory %s does not exist\n", sf_i->path->String.utf8)); 63 68 sf_dir_info_free (sf_d); 64 69 return -ENOENT; … … 69 74 rc = vboxCallClose (&client_handle, &sf_g->map, params.Handle); 70 75 if (VBOX_FAILURE (rc)) { 71 elog ("vboxCallClose(%s) after err=%d failed rc=%d\n",72 sf_i->path->String.utf8, err, rc);76 LogFunc(("vboxCallClose(%s) after err=%d failed rc=%Vrc\n", 77 sf_i->path->String.utf8, err, rc)); 73 78 } 74 79 sf_dir_info_free (sf_d); … … 79 84 rc = vboxCallClose (&client_handle, &sf_g->map, params.Handle); 80 85 if (VBOX_FAILURE (rc)) { 81 elog ("vboxCallClose(%s) failed rc=%d\n",82 sf_i->path->String.utf8, rc);86 LogFunc(("vboxCallClose(%s) failed rc=%Vrc\n", 87 sf_i->path->String.utf8, rc)); 83 88 } 84 89 … … 196 201 default: 197 202 /* skip erroneous entry and proceed */ 198 elog ("sf_getdent error %d\n", err);203 LogFunc(("sf_getdent error %d\n", err)); 199 204 dir->f_pos += 1; 200 205 continue; … … 206 211 fake_ino = sanity; 207 212 if (sanity - fake_ino) { 208 elog2("can not compute ino\n");213 LogRelPrintFunc("can not compute ino\n"); 209 214 return -EINVAL; 210 215 } … … 213 218 dir->f_pos, fake_ino, DT_UNKNOWN); 214 219 if (err) { 215 DBGC elog ("filldir returned error %d\n", err);220 LogFunc(("filldir returned error %d\n", err)); 216 221 /* Rely on the fact that filldir returns error 217 222 only when it runs out of space in opaque */ … … 225 230 } 226 231 227 st atic struct file_operations sf_dir_fops = {232 struct file_operations sf_dir_fops = { 228 233 .open = sf_dir_open, 229 234 .readdir = sf_dir_read, … … 281 286 sf_new_i = kmalloc (sizeof (*sf_new_i), GFP_KERNEL); 282 287 if (!sf_new_i) { 283 elog2("could not allocate memory for new inode info\n");288 LogRelPrintFunc("could not allocate memory for new inode info\n"); 284 289 err = -ENOMEM; 285 290 goto fail1; … … 289 294 inode = iget (parent->i_sb, ino); 290 295 if (!inode) { 291 elog2 ("iget failed\n");296 LogFunc(("iget failed\n")); 292 297 err = -ENOMEM; /* XXX: ??? */ 293 298 goto fail2; … … 332 337 sf_new_i = kmalloc (sizeof (*sf_new_i), GFP_KERNEL); 333 338 if (!sf_new_i) { 334 elog3 ("%s: %s: could not allocate inode info\n", 335 caller, __func__); 339 LogRelPrintFunc("could not allocate inode info. caller="); 340 LogRelPrint(caller); 341 LogRelPrint("\n"); 336 342 err = -ENOMEM; 337 343 goto fail0; … … 341 347 inode = iget (parent->i_sb, ino); 342 348 if (!inode) { 343 elog3 ("%s: %s: iget failed\n", caller, __func__);349 LogFunc(("iget failed. caller=%s\n", caller)); 344 350 err = -ENOMEM; 345 351 goto fail1; … … 403 409 } 404 410 411 LogFunc(("sf_create_aux: calling vboxCallCreate, folder %s, flags %#x\n", 412 path->String.utf8, params.CreateFlags)); 405 413 rc = vboxCallCreate (&client_handle, &sf_g->map, path, ¶ms); 406 414 if (VBOX_FAILURE (rc)) { 407 415 err = -EPROTO; 408 elog ("(%d): vboxCallCreate(%s) failed rc=%d\n", dirop,409 sf_i->path->String.utf8, rc);416 LogFunc(("(%d): vboxCallCreate(%s) failed rc=%Vrc\n", dirop, 417 sf_i->path->String.utf8, rc)); 410 418 goto fail0; 411 419 } … … 413 421 if (params.Result != SHFL_FILE_CREATED) { 414 422 err = -EPERM; 415 elog("(%d): could not create file %s result=%d\n", dirop,416 sf_i->path->String.utf8, params.Result);423 LogFunc(("(%d): could not create file %s result=%d\n", dirop, 424 sf_i->path->String.utf8, params.Result)); 417 425 goto fail0; 418 426 } … … 420 428 err = sf_instantiate (__func__, parent, dentry, path, ¶ms.Info); 421 429 if (err) { 422 elog("(%d): could not instantiate dentry for %s err=%d\n",423 dirop, sf_i->path->String.utf8, err);430 LogFunc(("(%d): could not instantiate dentry for %s err=%d\n", 431 dirop, sf_i->path->String.utf8, err)); 424 432 goto fail1; 425 433 } … … 427 435 rc = vboxCallClose (&client_handle, &sf_g->map, params.Handle); 428 436 if (VBOX_FAILURE (rc)) { 429 elog ("(%d): vboxCallClose failed rc=%d\n", dirop, rc);437 LogFunc(("(%d): vboxCallClose failed rc=%Vrc\n", dirop, rc)); 430 438 } 431 439 … … 436 444 rc = vboxCallClose (&client_handle, &sf_g->map, params.Handle); 437 445 if (VBOX_FAILURE (rc)) { 438 elog ("(%d): vboxCallClose failed rc=%d\n", dirop, rc);446 LogFunc(("(%d): vboxCallClose failed rc=%Vrc\n", dirop, rc)); 439 447 } 440 448 … … 481 489 dirop ? SHFL_REMOVE_DIR : SHFL_REMOVE_FILE); 482 490 if (VBOX_FAILURE (rc)) { 483 DBGC elog ("(%d): vboxCallRemove(%s) failed rc=%d\n", dirop,484 path->String.utf8, rc);491 LogFunc(("(%d): vboxCallRemove(%s) failed rc=%Vrc\n", dirop, 492 path->String.utf8, rc)); 485 493 486 494 switch (rc) { … … 495 503 default: 496 504 err = -EPROTO; 497 elog ("(%d): vboxCallRemove(%s) failed rc=%d\n", dirop,498 path->String.utf8, rc);505 LogFunc(("(%d): vboxCallRemove(%s) failed rc=%Vrc\n", dirop, 506 path->String.utf8, rc)); 499 507 break; 500 508 } … … 535 543 SHFLSTRING *old_path; 536 544 SHFLSTRING *new_path; 545 int is_dir = ((old_dentry->d_inode->i_mode & S_IFDIR) != 0); 537 546 538 547 TRACE (); … … 541 550 542 551 if (sf_g != GET_GLOB_INFO (new_parent->i_sb)) { 543 elog2 ("rename with different roots\n");552 LogFunc(("rename with different roots\n")); 544 553 return -EINVAL; 545 554 } … … 548 557 old_dentry, &old_path); 549 558 if (err) { 550 elog2 ("failed to create old path\n");559 LogFunc(("failed to create old path\n")); 551 560 return err; 552 561 } … … 555 564 new_dentry, &new_path); 556 565 if (err) { 557 elog2 ("failed to create new path\n");566 LogFunc(("failed to create new path\n")); 558 567 goto fail0; 559 568 } 560 569 561 570 rc = vboxCallRename (&client_handle, &sf_g->map, old_path, 562 new_path, SHFL_RENAME_FILE);571 new_path, is_dir ? 0 : SHFL_RENAME_FILE); 563 572 if (VBOX_FAILURE (rc)) { 564 573 switch (rc) { 574 /** @todo we need a function to convert VBox error 575 codes back to Linux. */ 576 case VERR_ACCESS_DENIED: 577 err = -EACCES; 578 goto fail1; 579 case VERR_DEV_IO_ERROR: 580 return -EBUSY; 581 goto fail1; 582 case VERR_INVALID_POINTER: 583 return -EFAULT; 584 goto fail1; 565 585 case VERR_FILE_NOT_FOUND: 566 586 case VERR_PATH_NOT_FOUND: … … 570 590 default: 571 591 err = -EPROTO; 572 elog ("vboxCallRename failed rc=%d\n", rc);592 LogFunc(("vboxCallRename failed rc=%Vrc\n", rc)); 573 593 goto fail1; 574 594 } … … 586 606 } 587 607 588 st atic struct inode_operations sf_dir_iops = {608 struct inode_operations sf_dir_iops = { 589 609 .lookup = sf_lookup, 590 610 .create = sf_create, -
trunk/src/VBox/Additions/linux/sharedfolders/files_vboxvfs
r4707 r4729 14 14 15 15 FILES_VBOXVFS_NOBIN=" \ 16 ${PATH_ROOT}/include/iprt/nocrt/limits.h=>include/iprt/nocrt/limits.h \ 16 17 ${PATH_ROOT}/include/iprt/alloc.h=>include/iprt/alloc.h \ 17 18 ${PATH_ROOT}/include/iprt/asm.h=>include/iprt/asm.h \ … … 51 52 ${PATH_ROOT}/src/VBox/Additions/common/VBoxGuestLib/VMMDev.cpp=>VMMDev.c \ 52 53 ${PATH_ROOT}/src/VBox/Runtime/include/internal/magics.h=>include/internal/magics.h \ 54 ${PATH_ROOT}/src/VBox/Runtime/math/gcc/divdi3.c=>divdi3.c \ 55 ${PATH_ROOT}/src/VBox/Runtime/math/gcc/moddi3.c=>moddi3.c \ 56 ${PATH_ROOT}/src/VBox/Runtime/math/gcc/qdivrem.c=>qdivrem.c \ 57 ${PATH_ROOT}/src/VBox/Runtime/math/gcc/quad.h=>quad.h \ 58 ${PATH_ROOT}/src/VBox/Runtime/math/gcc/udivdi3.c=>udivdi3.c \ 59 ${PATH_ROOT}/src/VBox/Runtime/math/gcc/umoddi3.c=>umoddi3.c \ 53 60 ${PATH_ROOT}/src/VBox/Runtime/r0drv/alloc-r0drv.cpp=>r0drv/alloc-r0drv.c \ 54 61 ${PATH_ROOT}/src/VBox/Runtime/r0drv/alloc-r0drv.h=>r0drv/alloc-r0drv.h \ -
trunk/src/VBox/Additions/linux/sharedfolders/regops.c
r4385 r4729 21 21 */ 22 22 23 #include "vfsmod.h" 24 23 25 #define CHUNK_SIZE 4096 24 26 … … 32 34 pos, nread, buf, false /* already locked? */); 33 35 if (VBOX_FAILURE (rc)) { 34 elog3 ("%s: %s: vboxCallRead failed rc=%d\n",35 caller, __func__, rc);36 LogFunc(("vboxCallRead failed. caller=%s, rc=%Vrc\n", 37 caller, rc)); 36 38 return -EPROTO; 37 39 } … … 53 55 TRACE (); 54 56 if (!S_ISREG (inode->i_mode)) { 55 elog ("read from non regular file %d\n", inode->i_mode);57 LogFunc(("read from non regular file %d\n", inode->i_mode)); 56 58 return -EINVAL; 57 59 } … … 63 65 tmp = kmalloc (CHUNK_SIZE, GFP_KERNEL); 64 66 if (!tmp) { 65 elog ("could not allocate bounce buffer memory %u bytes\n", 66 CHUNK_SIZE); 67 LogRelPrintFunc("could not allocate bounce buffer memory "); 68 LogRelPrintQuote(CHUNK_SIZE); 69 LogRelPrint(" bytes\n"); 67 70 return -ENOMEM; 68 71 } … … 124 127 125 128 if (!S_ISREG (inode->i_mode)) { 126 elog ("write to non regular file %d\n", inode->i_mode);129 LogFunc(("write to non regular file %d\n", inode->i_mode)); 127 130 return -EINVAL; 128 131 } … … 134 137 tmp = kmalloc (CHUNK_SIZE, GFP_KERNEL); 135 138 if (!tmp) { 136 elog ("could not allocate bounce buffer memory %u bytes\n", 137 CHUNK_SIZE); 139 LogRelPrintFunc("could not allocate bounce buffer memory "); 140 LogRelPrintQuote(CHUNK_SIZE); 141 LogRelPrint("bytes\n"); 138 142 return -ENOMEM; 139 143 } … … 158 162 if (VBOX_FAILURE (rc)) { 159 163 err = -EPROTO; 160 elog ("vboxCallWrite(%s) failed rc=%d\n",161 sf_i->path->String.utf8, rc);164 LogFunc(("vboxCallWrite(%s) failed rc=%Vrc\n", 165 sf_i->path->String.utf8, rc)); 162 166 goto fail; 163 167 } … … 189 193 sf_reg_open (struct inode *inode, struct file *file) 190 194 { 191 int rc ;195 int rc, rc_linux = 0; 192 196 struct sf_glob_info *sf_g = GET_GLOB_INFO (inode->i_sb); 193 197 struct sf_inode_info *sf_i = GET_INODE_INFO (inode); … … 201 205 sf_r = kmalloc (sizeof (*sf_r), GFP_KERNEL); 202 206 if (!sf_r) { 203 elog2("could not allocate reg info\n");207 LogRelPrintFunc("could not allocate reg info\n"); 204 208 return -ENOMEM; 205 209 } 206 210 207 #if 0 208 printk ("open %s\n", sf_i->path->String.utf8); 209 #endif 211 LogFunc(("open %s\n", sf_i->path->String.utf8)); 210 212 211 213 params.CreateFlags = 0; 212 214 params.Info.cbObject = 0; 215 /* We check this afterwards to find out if the call succeeded 216 or failed, as the API does not seem to cleanly distinguish 217 error and informational messages. */ 218 params.Handle = 0; 213 219 214 220 if (file->f_flags & O_CREAT) { 221 LogFunc(("O_CREAT set\n")); 222 params.CreateFlags |= SHFL_CF_ACT_CREATE_IF_NEW; 215 223 if (file->f_flags & O_EXCL) { 216 params.CreateFlags |= SHFL_CF_ACCESS_READWRITE;224 LogFunc(("O_EXCL set\n")); 217 225 params.CreateFlags |= SHFL_CF_ACT_FAIL_IF_EXISTS; 218 226 } 219 227 else { 220 params.CreateFlags |= SHFL_CF_ACT_CREATE_IF_NEW; 221 params.CreateFlags |= SHFL_CF_ACCESS_READWRITE; 228 /* O_TRUNC combined with O_EXCL is undefined. */ 222 229 if (file->f_flags & O_TRUNC) { 230 LogFunc(("O_TRUNC set\n")); 223 231 params.CreateFlags |= SHFL_CF_ACT_OVERWRITE_IF_EXISTS; 224 232 } … … 229 237 } 230 238 else { 239 params.CreateFlags |= SHFL_CF_ACT_FAIL_IF_NEW; 231 240 if (file->f_flags & O_TRUNC) { 232 params.CreateFlags |= SHFL_CF_ACCESS_READWRITE;241 LogFunc(("O_TRUNC set\n")); 233 242 params.CreateFlags |= SHFL_CF_ACT_OVERWRITE_IF_EXISTS; 234 }235 else {236 params.CreateFlags |= SHFL_CF_ACT_FAIL_IF_NEW;237 243 } 238 244 } … … 257 263 } 258 264 265 LogFunc(("sf_reg_open: calling vboxCallCreate, file %s, flags=%d, %#x\n", 266 sf_i->path->String.utf8 , file->f_flags, params.CreateFlags)); 259 267 rc = vboxCallCreate (&client_handle, &sf_g->map, sf_i->path, ¶ms); 260 268 261 /* XXX: here i probably should check rc and convert some values to 262 EEXISTS ENOENT etc */ 263 if (VBOX_FAILURE (rc)) 264 { 265 elog ("vboxCallCreate failed flags=%d,%#x rc=%d\n", 266 file->f_flags, params.CreateFlags, rc); 267 kfree (sf_r); 268 return -EPROTO; 269 } 270 271 /** @todo handle these return codes!! */ 272 switch (params.Result) 273 { 274 case SHFL_PATH_NOT_FOUND: 275 break; 276 case SHFL_FILE_NOT_FOUND: 277 break; 278 case SHFL_FILE_EXISTS: 279 break; 280 case SHFL_FILE_REPLACED: 281 break; 282 case SHFL_FILE_CREATED: 283 break; 269 if (VBOX_FAILURE (rc)) { 270 LogFunc(("vboxCallCreate failed flags=%d,%#x rc=%Vrc\n", 271 file->f_flags, params.CreateFlags, rc)); 272 kfree (sf_r); 273 return -EPROTO; 274 } 275 276 if (SHFL_HANDLE_NIL == params.Handle) { 277 switch (params.Result) { 278 case SHFL_PATH_NOT_FOUND: 279 case SHFL_FILE_NOT_FOUND: 280 rc_linux = -ENOENT; 281 break; 282 case SHFL_FILE_EXISTS: 283 rc_linux = -EEXIST; 284 break; 285 default: 286 break; 287 } 284 288 } 285 289 … … 287 291 sf_r->handle = params.Handle; 288 292 file->private_data = sf_r; 289 return 0;293 return rc_linux; 290 294 } 291 295 … … 306 310 rc = vboxCallClose (&client_handle, &sf_g->map, sf_r->handle); 307 311 if (VBOX_FAILURE (rc)) { 308 elog ("vboxCallClose failed rc=%d\n", rc);312 LogFunc(("vboxCallClose failed rc=%Vrc\n", rc)); 309 313 } 310 314 … … 341 345 page = alloc_page (GFP_HIGHUSER); 342 346 if (!page) { 343 elog2("failed to allocate page\n");347 LogRelPrintFunc("failed to allocate page\n"); 344 348 SET_TYPE (VM_FAULT_OOM); 345 349 return NOPAGE_OOM; … … 384 388 TRACE (); 385 389 if (vma->vm_flags & VM_SHARED) { 386 elog2 ("shared mmapping not available\n");390 LogFunc(("shared mmapping not available\n")); 387 391 return -EINVAL; 388 392 } … … 392 396 } 393 397 394 st atic struct file_operations sf_reg_fops = {398 struct file_operations sf_reg_fops = { 395 399 .read = sf_reg_read, 396 400 .open = sf_reg_open, … … 403 407 /* iops */ 404 408 405 st atic struct inode_operations sf_reg_iops = {409 struct inode_operations sf_reg_iops = { 406 410 #if LINUX_VERSION_CODE < KERNEL_VERSION (2, 6, 0) 407 411 .revalidate = sf_inode_revalidate -
trunk/src/VBox/Additions/linux/sharedfolders/utils.c
r4071 r4729 18 18 */ 19 19 20 #include "vfsmod.h" 21 20 22 /* #define USE_VMALLOC */ 21 23 … … 43 45 44 46 /* set [inode] attributes based on [info], uid/gid based on [sf_g] */ 45 staticvoid47 void 46 48 sf_init_inode (struct sf_glob_info *sf_g, struct inode *inode, 47 49 RTFSOBJINFO *info) … … 101 103 } 102 104 103 staticint105 int 104 106 sf_stat (const char *caller, struct sf_glob_info *sf_g, 105 107 SHFLSTRING *path, RTFSOBJINFO *result, int ok_to_fail) … … 110 112 TRACE (); 111 113 params.CreateFlags = SHFL_CF_LOOKUP | SHFL_CF_ACT_FAIL_IF_NEW; 114 LogFunc(("calling vboxCallCreate, file %s, flags %#x\n", 115 path->String.utf8, params.CreateFlags)); 112 116 rc = vboxCallCreate (&client_handle, &sf_g->map, path, ¶ms); 113 117 if (VBOX_FAILURE (rc)) { 114 elog3 ("%s: %s: vboxCallCreate(%s) failed rc=%d\n",115 caller, __func__, path->String.utf8, rc);118 LogFunc(("vboxCallCreate(%s) failed. caller=%s, rc=%Vrc\n", 119 path->String.utf8, rc, caller)); 116 120 return -EPROTO; 117 121 } … … 119 123 if (params.Result != SHFL_FILE_EXISTS) { 120 124 if (!ok_to_fail) { 121 elog3 ("%s: %s: vboxCallCreate(%s)" 122 " file does not exist result=%d\n", 123 caller, __func__, path->String.utf8, params.Result); 125 LogFunc(("vboxCallCreate(%s) file does not exist. caller=%s, result=%d\n", 126 path->String.utf8, params.Result, caller)); 124 127 } 125 128 return -ENOENT; … … 146 149 TRACE (); 147 150 if (!dentry || !dentry->d_inode) { 148 DBGC elog ("no dentry(%p) or inode(%p)\n", dentry, dentry->d_inode);151 LogFunc(("no dentry(%p) or inode(%p)\n", dentry, dentry->d_inode)); 149 152 return -EINVAL; 150 153 } … … 201 204 [generic_fillattr] */ 202 205 #if LINUX_VERSION_CODE >= KERNEL_VERSION (2, 6, 0) 203 staticint206 int 204 207 sf_getattr (struct vfsmount *mnt, struct dentry *dentry, struct kstat *kstat) 205 208 { … … 240 243 path_len = p_len + d_len + 2; 241 244 if (path_len > 0xffff) { 242 elog ("%s: path to big %zu\n", caller, path_len);245 LogFunc(("path too long. caller=%s, path_len=%zu\n", caller, path_len)); 243 246 return -ENAMETOOLONG; 244 247 } … … 248 251 tmp = kmalloc (shflstring_len, GFP_KERNEL); 249 252 if (!tmp) { 250 elog ("%s: kmalloc failed\n", caller); 253 LogRelPrintFunc("kmalloc failed, caller="); 254 LogRelPrint(caller); 251 255 return -ENOMEM; 252 256 } … … 272 276 to [sf_g]->nls, we must convert it to UTF8 here and pass down to 273 277 [sf_make_path] which will allocate SHFLSTRING and fill it in */ 274 staticint278 int 275 279 sf_path_from_dentry (const char *caller, struct sf_glob_info *sf_g, 276 280 struct sf_inode_info *sf_i, struct dentry *dentry, … … 307 311 nb = sf_g->nls->char2uni (in, in_len, &uni); 308 312 if (nb < 0) { 309 elog("nls->char2uni failed %x %d\n",310 *in, in_len);313 LogFunc(("nls->char2uni failed %x %d\n", 314 *in, in_len)); 311 315 err = -EINVAL; 312 316 goto fail1; … … 317 321 nb = utf8_wctomb (out, uni, out_bound_len); 318 322 if (nb < 0) { 319 elog("nls->uni2char failed %x %d\n",320 uni, out_bound_len);323 LogFunc(("nls->uni2char failed %x %d\n", 324 uni, out_bound_len)); 321 325 err = -EINVAL; 322 326 goto fail1; … … 331 335 } 332 336 333 DBGC printk (KERN_DEBUG "result(%d) = %.*s\n", len, len, name);337 LogFunc(("result(%d) = %.*s\n", len, len, name)); 334 338 *out = 0; 335 339 } … … 350 354 } 351 355 352 staticint356 int 353 357 sf_nlscpy (struct sf_glob_info *sf_g, 354 358 char *name, size_t name_bound_len, … … 375 379 nb = utf8_mbtowc (&uni, in, in_bound_len); 376 380 if (nb < 0) { 377 elog("utf8_mbtowc failed(%s) %x:%d\n",378 utf8_name, *in, in_bound_len);381 LogFunc(("utf8_mbtowc failed(%s) %x:%d\n", 382 (const char *) utf8_name, *in, in_bound_len)); 379 383 return -EINVAL; 380 384 } … … 384 388 nb = sf_g->nls->uni2char (uni, out, out_bound_len); 385 389 if (nb < 0) { 386 elog("nls->uni2char failed(%s) %x:%d\n",387 utf8_name, uni, out_bound_len);390 LogFunc(("nls->uni2char failed(%s) %x:%d\n", 391 utf8_name, uni, out_bound_len)); 388 392 return nb; 389 393 } … … 415 419 b = kmalloc (sizeof (*b), GFP_KERNEL); 416 420 if (!b) { 417 elog2("could not alloc directory buffer\n");421 LogRelPrintFunc("could not alloc directory buffer\n"); 418 422 return NULL; 419 423 } … … 426 430 if (!b->buf) { 427 431 kfree (b); 428 elog2("could not alloc directory buffer storage\n");432 LogRelPrintFunc("could not alloc directory buffer storage\n"); 429 433 return NULL; 430 434 } … … 452 456 } 453 457 454 staticvoid458 void 455 459 sf_dir_info_free (struct sf_dir_info *p) 456 460 { … … 468 472 } 469 473 470 st atic struct sf_dir_info *474 struct sf_dir_info * 471 475 sf_dir_info_alloc (void) 472 476 { … … 476 480 p = kmalloc (sizeof (*p), GFP_KERNEL); 477 481 if (!p) { 478 elog2("could not alloc directory info\n");482 LogRelPrintFunc("could not alloc directory info\n"); 479 483 return NULL; 480 484 } … … 507 511 } 508 512 509 staticint513 int 510 514 sf_dir_read_all (struct sf_glob_info *sf_g, struct sf_inode_info *sf_i, 511 515 struct sf_dir_info *sf_d, SHFLHANDLE handle) … … 532 536 if (!b) { 533 537 err = -ENOMEM; 534 elog2("could not alloc directory buffer\n");538 LogRelPrintFunc("could not alloc directory buffer\n"); 535 539 goto fail1; 536 540 } … … 560 564 561 565 case VERR_NO_TRANSLATION: 562 elog2 ("host could not translte entry\n");566 LogFunc(("host could not translate entry\n")); 563 567 /* XXX */ 564 568 break; … … 566 570 default: 567 571 err = -EPROTO; 568 elog ("vboxCallDirInfo failed rc=%d\n", rc);572 LogFunc(("vboxCallDirInfo failed rc=%Vrc\n", rc)); 569 573 goto fail1; 570 574 } … … 587 591 } 588 592 589 st atic struct dentry_operations sf_dentry_ops = {593 struct dentry_operations sf_dentry_ops = { 590 594 .d_revalidate = sf_dentry_revalidate 591 595 }; -
trunk/src/VBox/Additions/linux/sharedfolders/vfsmod.c
r4071 r4729 22 22 */ 23 23 24 #include "the-linux-kernel.h"25 #include "version-generated.h"26 27 24 /* 28 25 * Suppress the definition of wchar_t from stddef.h that occurs below. … … 34 31 #endif 35 32 #endif 33 36 34 #include "vfsmod.h" 37 #include "VBoxCalls.h"38 #include "vbsfmount.h"39 35 40 36 // #define wchar_t linux_wchar_t … … 47 43 #endif 48 44 49 /* structs */50 struct sf_glob_info {51 VBSFMAP map;52 struct nls_table *nls;53 int ttl;54 int uid;55 int gid;56 };57 58 struct sf_inode_info {59 SHFLSTRING *path;60 int force_restat;61 };62 63 struct sf_dir_info {64 struct list_head info_list;65 };66 67 struct sf_dir_buf {68 size_t nb_entries;69 size_t free_bytes;70 size_t used_bytes;71 void *buf;72 struct list_head head;73 };74 75 struct sf_reg_info {76 SHFLHANDLE handle;77 };78 79 45 /* globals */ 80 staticVBSFCLIENT client_handle;46 VBSFCLIENT client_handle; 81 47 82 48 /* forward declarations */ 83 static struct inode_operations sf_dir_iops;84 static struct inode_operations sf_reg_iops;85 static struct file_operations sf_dir_fops;86 static struct file_operations sf_reg_fops;87 49 static struct super_operations sf_super_ops; 88 static struct dentry_operations sf_dentry_ops; 89 90 #include "utils.c" 91 #include "dirops.c" 92 #include "regops.c" 50 51 // #include "utils.c" 52 // #include "dirops.c" 53 // #include "regops.c" 93 54 94 55 /* allocate global info, try to map host share */ … … 105 66 if (!sf_g) { 106 67 err = -ENOMEM; 107 elog2("could not allocate memory for global info\n");68 LogRelPrintFunc("could not allocate memory for global info\n"); 108 69 goto fail0; 109 70 } … … 115 76 if (name_len > 0xfffe) { 116 77 err = -ENAMETOOLONG; 117 elog2 ("map name too big\n");78 LogFunc(("map name too big\n")); 118 79 goto fail1; 119 80 } … … 123 84 if (!str_name) { 124 85 err = -ENOMEM; 125 elog2("could not allocate memory for host name\n");86 LogRelPrintFunc("could not allocate memory for host name\n"); 126 87 goto fail1; 127 88 } … … 135 96 if (!sf_g->nls) { 136 97 err = -EINVAL; 137 elog ("failed to load nls %.*s\n", 138 sizeof (info->nls_name), info->nls_name); 98 LogFunc(("failed to load nls %s\n", info->nls_name)); 139 99 goto fail1; 140 100 } … … 149 109 if (VBOX_FAILURE (rc)) { 150 110 err = -EPROTO; 151 elog ("vboxCallMapFolder failed rc=%d\n", rc);111 LogFunc(("vboxCallMapFolder failed rc=%d\n", rc)); 152 112 goto fail2; 153 113 } … … 179 139 rc = vboxCallUnmapFolder (&client_handle, &sf_g->map); 180 140 if (VBOX_FAILURE (rc)) { 181 elog ("vboxCallUnmapFolder failed rc=%d\n", rc);141 LogFunc(("vboxCallUnmapFolder failed rc=%d\n", rc)); 182 142 } 183 143 … … 210 170 TRACE (); 211 171 if (!data) { 212 elog2 ("no mount info specified\n");172 LogFunc(("no mount info specified\n")); 213 173 return -EINVAL; 214 174 } … … 217 177 218 178 if (flags & MS_REMOUNT) { 219 elog2 ("remounting is not supported\n");179 LogFunc(("remounting is not supported\n")); 220 180 return -ENOSYS; 221 181 } … … 229 189 if (!sf_i) { 230 190 err = -ENOMEM; 231 elog2("could not allocate memory for root inode info\n");191 LogRelPrintFunc ("could not allocate memory for root inode info\n"); 232 192 goto fail1; 233 193 } … … 236 196 if (!sf_i->path) { 237 197 err = -ENOMEM; 238 elog2("could not allocate memory for root inode path\n");198 LogRelPrintFunc ("could not allocate memory for root inode path\n"); 239 199 goto fail2; 240 200 } … … 247 207 err = sf_stat (__func__, sf_g, sf_i->path, &fsinfo, 0); 248 208 if (err) { 249 elog2 ("could not stat root of share\n");209 LogFunc(("could not stat root of share\n")); 250 210 goto fail3; 251 211 } … … 258 218 if (!iroot) { 259 219 err = -ENOMEM; /* XXX */ 260 elog2 ("could not get root inode\n");220 LogFunc(("could not get root inode\n")); 261 221 goto fail3; 262 222 } … … 268 228 if (!droot) { 269 229 err = -ENOMEM; /* XXX */ 270 elog2 ("d_alloc_root failed\n");230 LogFunc(("d_alloc_root failed\n")); 271 231 goto fail4; 272 232 } … … 441 401 err = register_filesystem (&vboxsf_fs_type); 442 402 if (err) { 443 elog ("register_filesystem err=%d\n", err);403 LogFunc(("register_filesystem err=%d\n", err)); 444 404 return err; 445 405 } … … 451 411 rc = vboxInit (); 452 412 if (VBOX_FAILURE (rc)) { 453 elog ("vboxInit failed rc=%d\n", rc); 413 LogRelPrintFunc ("vboxInit failed\n"); 414 Log (("rc=%d\n", rc)); 454 415 goto fail0; 455 416 } … … 457 418 rc = vboxConnect (&client_handle); 458 419 if (VBOX_FAILURE (rc)) { 459 elog ("vboxConnect failed rc=%d\n", rc); 420 LogRelPrintFunc ("vboxConnect failed\n"); 421 Log (("rc=%d\n", rc)); 460 422 goto fail1; 461 423 } … … 463 425 rc = vboxCallSetUtf8 (&client_handle); 464 426 if (VBOX_FAILURE (rc)) { 465 elog ("vboxCallSetUtf8 failed rc=%d\n", rc); 427 LogRelPrintFunc ("vboxCallSetUtf8 failed\n"); 428 Log (("rc=%d\n", rc)); 466 429 goto fail2; 467 430 } … … 496 459 int __gxx_personality_v0 = 0xdeadbeef; 497 460 461 #if 0 498 462 /* long long hacks (as far as i can see, gcc emits the refs to those 499 463 symbols, notwithstanding the fact that those aren't referenced … … 510 474 BUG (); 511 475 } 476 #endif /* 0 */ 512 477 513 478 /* -
trunk/src/VBox/Additions/linux/sharedfolders/vfsmod.h
r4071 r4729 19 19 #define VFSMOD_H 20 20 21 #define elog(fmt, ...) \ 22 printk (KERN_ERR "vboxvfs: %s: " fmt, __func__, __VA_ARGS__) 23 #define elog2(s) printk (KERN_ERR "vboxvfs: %s: " s, __func__) 24 #define elog3(...) printk (KERN_ERR "vboxvfs: " __VA_ARGS__) 21 #include "the-linux-kernel.h" 22 #include "version-generated.h" 23 24 #include "VBoxCalls.h" 25 #include "vbsfmount.h" 26 27 /* structs */ 28 struct sf_glob_info { 29 VBSFMAP map; 30 struct nls_table *nls; 31 int ttl; 32 int uid; 33 int gid; 34 }; 35 36 struct sf_inode_info { 37 SHFLSTRING *path; 38 int force_restat; 39 }; 40 41 struct sf_dir_info { 42 struct list_head info_list; 43 }; 44 45 struct sf_dir_buf { 46 size_t nb_entries; 47 size_t free_bytes; 48 size_t used_bytes; 49 void *buf; 50 struct list_head head; 51 }; 52 53 struct sf_reg_info { 54 SHFLHANDLE handle; 55 }; 56 57 /* globals */ 58 extern VBSFCLIENT client_handle; 59 60 /* forward declarations */ 61 extern struct inode_operations sf_dir_iops; 62 extern struct inode_operations sf_reg_iops; 63 extern struct file_operations sf_dir_fops; 64 extern struct file_operations sf_reg_fops; 65 extern struct dentry_operations sf_dentry_ops; 66 67 extern int 68 sf_stat (const char *caller, struct sf_glob_info *sf_g, 69 SHFLSTRING *path, RTFSOBJINFO *result, int ok_to_fail); 70 extern void 71 sf_init_inode (struct sf_glob_info *sf_g, struct inode *inode, 72 RTFSOBJINFO *info); 73 #if LINUX_VERSION_CODE >= KERNEL_VERSION (2, 6, 0) 74 extern int 75 sf_getattr (struct vfsmount *mnt, struct dentry *dentry, struct kstat *kstat); 76 #endif 77 extern int 78 sf_path_from_dentry (const char *caller, struct sf_glob_info *sf_g, 79 struct sf_inode_info *sf_i, struct dentry *dentry, 80 SHFLSTRING **result); 81 extern int 82 sf_nlscpy (struct sf_glob_info *sf_g, 83 char *name, size_t name_bound_len, 84 const unsigned char *utf8_name, size_t utf8_len); 85 extern void 86 sf_dir_info_free (struct sf_dir_info *p); 87 extern struct sf_dir_info * 88 sf_dir_info_alloc (void); 89 extern int 90 sf_dir_read_all (struct sf_glob_info *sf_g, struct sf_inode_info *sf_i, 91 struct sf_dir_info *sf_d, SHFLHANDLE handle); 25 92 26 93 #ifdef ALIGN … … 30 97 #define CMC_API __attribute__ ((cdecl, regparm (0))) 31 98 32 #define DBGC if (0) 33 #define TRACE() DBGC printk (KERN_DEBUG "%s\n", __func__) 99 #define TRACE() LogFlow (("%s, tracepoint\n", __func__)) 34 100 35 101 /* Following casts are here to prevent assignment of void * to
Note:
See TracChangeset
for help on using the changeset viewer.