Changeset 9395
- Timestamp:
- 07/23/12 17:17:51 (11 months ago)
- Files:
-
- 1 modified
-
trunk/src/client/otherint/JNI/libPVFS2JNI.c (modified) (130 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/client/otherint/JNI/libPVFS2JNI.c
r9386 r9395 28 28 #include "PVFS2JNI.h" 29 29 30 #define JNI_DBG 0 31 30 32 void disp(struct stat *abc) 31 33 { … … 68 70 } 69 71 70 / /pvfs_open72 /* pvfs_open */ 71 73 JNIEXPORT int JNICALL 72 74 Java_PVFS2JNI_pvfsOpen( … … 78 80 ) 79 81 { 80 printf("pvfsOpen\n"); 81 fflush(stdout); 82 if(JNI_DBG) printf("pvfsOpen\n"); 82 83 int rc = 0; 83 84 char cpath[PVFS_PATH_MAX]; … … 86 87 if((flags & O_CREAT) == O_CREAT) 87 88 { 88 printf("\tO_CREAT detected!\n");89 if(JNI_DBG) printf("\tO_CREAT detected!\n"); 89 90 rc = pvfs_open(cpath, flags, mode); 90 91 } 91 92 else 92 93 { 93 printf("\tNo O_CREAT detected\n");94 if(JNI_DBG) printf("\tNo O_CREAT detected\n"); 94 95 rc = pvfs_open(cpath, flags); 95 96 } … … 97 98 { 98 99 perror("pvfs_open error"); 99 fflush(stdout); 100 return -1; 101 } 102 return rc; 103 } 104 //pvfs_open64 06/08/2012 100 rc = -1; 101 } 102 if(JNI_DBG) fflush(stdout); 103 return rc; 104 } 105 106 /* pvfs_open64 06/08/2012 */ 105 107 JNIEXPORT int JNICALL 106 108 Java_PVFS2JNI_pvfsOpen64 (JNIEnv *env, jobject obj, jstring path, int flags) 107 109 { 108 printf("pvfsOpen64\n"); 109 fflush(stdout); 110 if(JNI_DBG) printf("pvfsOpen64\n"); 110 111 int rc = 0; 111 112 char cpath[PVFS_PATH_MAX]; … … 116 117 { 117 118 perror("pvfs_open64 error"); 118 fflush(stdout);119 return -1;120 }121 return rc; 122 } 123 124 / /pvfs_openat119 rc -1; 120 } 121 if(JNI_DBG) fflush(stdout); 122 return rc; 123 } 124 125 /* pvfs_openat */ 125 126 JNIEXPORT jint JNICALL 126 127 Java_PVFS2JNI_pvfsOpenat (JNIEnv *env, jobject obj, int dirfd, jstring path, int flags) 127 128 { 128 printf("pvfsOpenat\n"); 129 fflush(stdout); 129 if(JNI_DBG) printf("pvfsOpenat\n"); 130 130 int rc = 0; 131 131 char cpath[PVFS_PATH_MAX]; … … 136 136 { 137 137 perror("pvfs_openat error"); 138 fflush(stdout); 139 return -1; 140 } 141 return rc; 142 } 143 138 rc = -1; 139 } 140 if(JNI_DBG) fflush(stdout); 141 return rc; 142 } 143 144 /* pvfs_openat64 */ 144 145 JNIEXPORT jint JNICALL 145 146 Java_PVFS2JNI_pvfsOpenat64 (JNIEnv *env, jobject obj, int dirfd, jstring path, int flags) 146 147 { 147 printf("pvfsOpenat64\n"); 148 fflush(stdout); 148 if(JNI_DBG) printf("pvfsOpenat64\n"); 149 149 int rc = 0; 150 150 char cpath[PVFS_PATH_MAX]; … … 155 155 { 156 156 perror("pvfs_openat64 error"); 157 fflush(stdout); 158 return -1; 159 } 160 return rc; 161 } 162 163 164 //pvfs_creat 157 rc = -1; 158 } 159 if(JNI_DBG) fflush(stdout); 160 return rc; 161 } 162 163 /* pvfs_creat */ 165 164 JNIEXPORT int JNICALL 166 165 Java_PVFS2JNI_pvfsCreat(JNIEnv *env, jobject obj, jstring path, int mode) 167 166 { 168 printf("pvfsCreat\n"); 169 fflush(stdout); 167 if(JNI_DBG) printf("pvfsCreat\n"); 170 168 int rc = 0; 171 169 char cpath[PVFS_PATH_MAX]; … … 176 174 { 177 175 perror("pvfs_creat error"); 178 fflush(stdout);179 return -1;180 }181 return rc; 182 } 183 184 / /pvfs_creat64176 rc = -1; 177 } 178 if(JNI_DBG) fflush(stdout); 179 return rc; 180 } 181 182 /* pvfs_creat64 */ 185 183 JNIEXPORT int JNICALL 186 184 Java_PVFS2JNI_pvfsCreat64(JNIEnv *env, jobject obj, jstring path, int mode) 187 185 { 188 printf("pvfsCreat64\n"); 189 fflush(stdout); 186 if(JNI_DBG) printf("pvfsCreat64\n"); 190 187 int rc = 0; 191 188 char cpath[PVFS_PATH_MAX]; … … 196 193 { 197 194 perror("pvfs_creat error"); 198 fflush(stdout);199 return -1;200 }201 return rc; 202 } 203 204 / /pvfs_unlink195 rc = -1; 196 } 197 if(JNI_DBG) fflush(stdout); 198 return rc; 199 } 200 201 /* pvfs_unlink */ 205 202 JNIEXPORT int JNICALL 206 203 Java_PVFS2JNI_pvfsUnlink(JNIEnv *env, jobject obj, jstring path) 207 204 { 208 printf("pvfsUnlink\n"); 209 fflush(stdout); 205 if(JNI_DBG) printf("pvfsUnlink\n"); 210 206 int rc = 0; 211 207 char cpath[PVFS_PATH_MAX]; … … 216 212 { 217 213 perror("pvfs_unlink error"); 218 fflush(stdout); 219 return -1; 220 } 221 return 0; 222 } 223 224 //pvfs_unlinkat 225 214 rc = -1; 215 } 216 if(JNI_DBG) fflush(stdout); 217 return rc; 218 } 219 220 /* pvfs_unlinkat */ 226 221 JNIEXPORT jint JNICALL 227 222 Java_PVFS2JNI_pvfsUnlinkat (JNIEnv *env, jobject obj, int dirfd, jstring path, int flags) 228 223 { 229 printf("pvfsUnlinkat\n"); 230 fflush(stdout); 224 if(JNI_DBG) printf("pvfsUnlinkat\n"); 231 225 int rc = 0; 232 226 char cpath[PVFS_PATH_MAX]; … … 237 231 { 238 232 perror("pvfs_unlinkat error"); 239 fflush(stdout); 240 return -1; 241 } 242 return 0; 243 } 244 //pvfs_rename 233 rc = -1; 234 } 235 if(JNI_DBG) fflush(stdout); 236 return rc; 237 } 238 239 /* pvfs_rename */ 245 240 JNIEXPORT int JNICALL 246 241 Java_PVFS2JNI_pvfsRename(JNIEnv *env, … … 250 245 ) 251 246 { 252 printf("pvfsRename\n"); 253 fflush(stdout); 247 if(JNI_DBG) printf("pvfsRename\n"); 254 248 int rc = 0; 255 249 char coldpath[PVFS_PATH_MAX]; … … 259 253 int cnewpath_len = (*env)->GetStringLength(env, newpath); 260 254 (*env)->GetStringUTFRegion(env, newpath, 0, cnewpath_len, cnewpath); 261 //printf("oldpath=%s\tnewpath=%s\n", coldpath, cnewpath);262 255 rc = pvfs_rename(coldpath, cnewpath); 263 256 if(rc < 0) 264 257 { 265 258 perror("pvfs_rename error"); 266 fflush(stdout);267 return -1;268 }269 return 0;270 } 271 272 / /pvfs_RenameAt259 rc = -1; 260 } 261 if(JNI_DBG) fflush(stdout); 262 return rc; 263 } 264 265 /* pvfs_RenameAt */ 273 266 JNIEXPORT int JNICALL 274 267 Java_PVFS2JNI_pvfsRenameAt(JNIEnv *env, … … 280 273 ) 281 274 { 282 printf("pvfsRenameAt\n"); 283 fflush(stdout); 275 if(JNI_DBG) printf("pvfsRenameAt\n"); 284 276 int rc = 0; 285 277 char coldpath[PVFS_PATH_MAX]; … … 289 281 int cnewpath_len = (*env)->GetStringLength(env, newpath); 290 282 (*env)->GetStringUTFRegion(env, newpath, 0, cnewpath_len, cnewpath); 291 //printf("oldpath=%s\tnewpath=%s\n", coldpath, cnewpath);292 283 rc = pvfs_renameat(olddirfd, coldpath, newdirfd, cnewpath); 293 284 if(rc < 0) 294 285 { 295 286 perror("pvfs_renameat error"); 296 fflush(stdout);297 return -1;298 }299 return 0;300 } 301 302 / /pvfs_close287 rc = -1; 288 } 289 if(JNI_DBG) fflush(stdout); 290 return rc; 291 } 292 293 /* pvfs_close */ 303 294 JNIEXPORT int JNICALL 304 295 Java_PVFS2JNI_pvfsClose(JNIEnv *env, jobject obj, int fd) 305 296 { 306 printf("pvfsClose\n"); 307 fflush(stdout); 297 if(JNI_DBG) printf("pvfsClose\n"); 308 298 int rc = 0; 309 299 rc = pvfs_close(fd); … … 311 301 { 312 302 perror("pvfs_close error"); 313 fflush(stdout);314 return -1;315 }316 return 0;317 } 318 319 / /pvfs_flush303 rc = -1; 304 } 305 if(JNI_DBG) fflush(stdout); 306 return rc; 307 } 308 309 /* pvfs_flush */ 320 310 JNIEXPORT int JNICALL 321 311 Java_PVFS2JNI_pvfsFlush(JNIEnv *env, jobject obj, int fd) 322 312 { 323 printf("pvfsFlush\n"); 324 fflush(stdout); 313 if(JNI_DBG) printf("pvfsFlush\n"); 325 314 int rc = 0; 326 315 rc = pvfs_flush(fd); … … 328 317 { 329 318 perror("pvfs_close error"); 330 fflush(stdout); 331 return -1; 332 } 333 return 0; 334 } 335 336 //pvfs_prdwr64 (INCOMPLETE) 337 338 JNIEXPORT jint JNICALL 339 Java_PVFS2JNI_pvfsPrdwr64 (JNIEnv *env, jobject obj, int fd, jlong buf, jlong count, jlong offset, int which) 319 rc = -1; 320 } 321 if(JNI_DBG) fflush(stdout); 322 return rc; 323 } 324 325 /* pvfs_prdwr64 (INCOMPLETE) */ 326 JNIEXPORT jint JNICALL 327 Java_PVFS2JNI_pvfsPrdwr64(JNIEnv *env, jobject obj, int fd, jlong buf, jlong count, jlong offset, int which) 340 328 { 341 329 printf("pvfsPrdwr64\n"); … … 355 343 } 356 344 357 358 359 // pvfs_lseek 360 361 JNIEXPORT jlong JNICALL 362 Java_PVFS2JNI_pvfsLseek (JNIEnv *env, jobject obj, int fd, jlong offset, int whence) 363 { 364 printf("pvfsLseek\n"); 365 fflush(stdout); 345 /* pvfs_lseek */ 346 JNIEXPORT jlong JNICALL 347 Java_PVFS2JNI_pvfsLseek(JNIEnv *env, jobject obj, int fd, jlong offset, int whence) 348 { 349 if(JNI_DBG) printf("pvfsLseek\n"); 366 350 off_t offsetc = (off_t) offset; 367 351 off_t rc = pvfs_lseek(fd, offsetc, whence); … … 370 354 { 371 355 perror("pvfs_lseek error"); 372 fflush(stdout);373 return -1;374 }356 op = -1; 357 } 358 if(JNI_DBG) fflush(stdout); 375 359 return op; 376 360 } 377 361 378 // pvfs_lseek64 379 380 JNIEXPORT jlong JNICALL 381 Java_PVFS2JNI_pvfsLseek64 (JNIEnv *env, jobject obj, int fd, jlong offset, int whence) 382 { 383 printf("pvfsLseek64\n"); 384 fflush(stdout); 362 /* pvfs_lseek64 */ 363 JNIEXPORT jlong JNICALL 364 Java_PVFS2JNI_pvfsLseek64(JNIEnv *env, jobject obj, int fd, jlong offset, int whence) 365 { 366 if(JNI_DBG) printf("pvfsLseek64\n"); 385 367 off_t offsetc = (off_t) offset; 386 368 off_t rc = pvfs_lseek(fd, offsetc, whence); 387 if(rc < 0) 369 jlong op = (jlong)rc; 370 if(op < 0) 388 371 { 389 372 perror("pvfs_lseek64 error"); 390 fflush(stdout); 391 return -1; 392 } 393 jlong op = (jlong)rc; 373 op = -1; 374 } 375 if(JNI_DBG) fflush(stdout); 394 376 return op; 395 377 } 396 378 397 // pvfs_truncate 398 JNIEXPORT jint JNICALL 399 Java_PVFS2JNI_pvfsTruncate (JNIEnv *env, jobject obj, jstring path, jlong length) 400 { 401 printf("pvfsTruncate\n"); 402 fflush(stdout); 379 /* pvfs_truncate */ 380 JNIEXPORT jint JNICALL 381 Java_PVFS2JNI_pvfsTruncate(JNIEnv *env, jobject obj, jstring path, jlong length) 382 { 383 if(JNI_DBG) printf("pvfsTruncate\n"); 403 384 char cpath[PVFS_PATH_MAX]; 404 385 int cpath_len = (*env)->GetStringLength(env, path); 405 386 (*env)->GetStringUTFRegion(env, path, 0, cpath_len, cpath); 406 387 off_t clength = (off_t) length; 407 int rc = 0; 408 rc = pvfs_truncate(cpath, clength); 388 int rc = pvfs_truncate(cpath, clength); 409 389 if(rc < 0) 410 390 { 411 391 perror("pvfs_truncate error"); 412 fflush(stdout); 413 return -1; 414 } 415 return rc; 416 } 417 418 419 420 // pvfs_truncate64 421 JNIEXPORT jint JNICALL 422 Java_PVFS2JNI_pvfsTruncate64 (JNIEnv *env, jobject obj, jstring path, jlong length) 423 { 424 printf("pvfsTruncate64\n"); 425 fflush(stdout); 392 rc = -1; 393 } 394 if(JNI_DBG) fflush(stdout); 395 return rc; 396 } 397 398 /* pvfs_truncate64 */ 399 JNIEXPORT jint JNICALL 400 Java_PVFS2JNI_pvfsTruncate64(JNIEnv *env, jobject obj, jstring path, jlong length) 401 { 402 if(JNI_DBG) printf("pvfsTruncate64\n"); 426 403 char cpath[PVFS_PATH_MAX]; 427 404 int cpath_len = (*env)->GetStringLength(env, path); … … 433 410 { 434 411 perror("pvfs_truncate64 error"); 435 fflush(stdout); 436 return -1; 437 } 438 return rc; 439 } 440 441 //pvfs_fallocate 442 JNIEXPORT jint JNICALL 443 Java_PVFS2JNI_pvfsFallocate (JNIEnv *env, jobject obj, int fd, jlong offset, jlong length) 444 { 445 printf("pvfsFallocate\n"); 446 fflush(stdout); 412 rc = -1; 413 } 414 if(JNI_DBG) fflush(stdout); 415 return rc; 416 } 417 418 /* pvfs_fallocate */ 419 JNIEXPORT jint JNICALL 420 Java_PVFS2JNI_pvfsFallocate(JNIEnv *env, jobject obj, int fd, jlong offset, jlong length) 421 { 422 if(JNI_DBG) printf("pvfsFallocate\n"); 447 423 off_t coffset = (off_t) offset; 448 424 off_t clength = (off_t) length; … … 452 428 { 453 429 perror("pvfs_fallocate error"); 454 fflush(stdout); 455 return -1; 456 } 457 return rc; 458 } 459 460 //pvfs_ftruncate 461 JNIEXPORT jint JNICALL 462 Java_PVFS2JNI_pvfsFtruncate (JNIEnv *env, jobject obj, int fd, jlong length) 463 { 464 printf("pvfsFtruncate\n"); 465 fflush(stdout); 430 rc = -1; 431 } 432 if(JNI_DBG) fflush(stdout); 433 return rc; 434 } 435 436 /* pvfs_ftruncate */ 437 JNIEXPORT jint JNICALL 438 Java_PVFS2JNI_pvfsFtruncate(JNIEnv *env, jobject obj, int fd, jlong length) 439 { 440 if(JNI_DBG) printf("pvfsFtruncate\n"); 466 441 off_t clength = (off_t) length; 467 442 int rc = 0; … … 470 445 { 471 446 perror("pvfs_ftruncate error"); 472 fflush(stdout); 473 return -1; 474 } 475 return rc; 476 } 477 478 //pvfs_ftruncate64 479 480 JNIEXPORT jint JNICALL 481 Java_PVFS2JNI_pvfsFtruncate64 (JNIEnv *env, jobject obj, int fd, jlong length) 482 { 483 printf("pvfsFtruncate64\n"); 484 fflush(stdout); 447 rc = -1; 448 } 449 if(JNI_DBG) fflush(stdout); 450 return rc; 451 } 452 453 /* pvfs_ftruncate64 */ 454 JNIEXPORT jint JNICALL 455 Java_PVFS2JNI_pvfsFtruncate64(JNIEnv *env, jobject obj, int fd, jlong length) 456 { 457 if(JNI_DBG) printf("pvfsFtruncate64\n"); 485 458 off64_t clength = (off64_t) length; 486 459 int rc = 0; … … 489 462 { 490 463 perror("pvfs_ftruncate64 error"); 491 fflush(stdout); 492 return -1; 493 } 494 return rc; 495 } 496 497 //pvfs_dup 498 JNIEXPORT jint JNICALL 499 Java_PVFS2JNI_pvfsDup (JNIEnv *env, jobject obj, int oldfd) 500 { 501 printf("pvfsDup\n"); 502 fflush(stdout); 464 rc = -1; 465 } 466 if(JNI_DBG) fflush(stdout); 467 return rc; 468 } 469 470 /* pvfs_dup */ 471 JNIEXPORT jint JNICALL 472 Java_PVFS2JNI_pvfsDup(JNIEnv *env, jobject obj, int oldfd) 473 { 474 if(JNI_DBG) printf("pvfsDup\n"); 503 475 int rc = 0; 504 476 rc = pvfs_dup(oldfd); … … 506 478 { 507 479 perror("pvfs_dup error"); 508 fflush(stdout); 509 return -1; 510 } 511 return rc; 512 } 513 514 //pvfs_dup2 515 JNIEXPORT jint JNICALL 516 Java_PVFS2JNI_pvfsDup2 (JNIEnv *env, jobject obj, int oldfd, int newfd) 517 { 518 printf("pvfsDup2\n"); 519 fflush(stdout); 480 rc = -1; 481 } 482 if(JNI_DBG) fflush(stdout); 483 return rc; 484 } 485 486 /* pvfs_dup2 */ 487 JNIEXPORT jint JNICALL 488 Java_PVFS2JNI_pvfsDup2(JNIEnv *env, jobject obj, int oldfd, int newfd) 489 { 490 if(JNI_DBG) printf("pvfsDup2\n"); 520 491 int rc = 0; 521 492 rc = pvfs_dup_descriptor(oldfd, newfd); … … 523 494 { 524 495 perror("pvfs_dup2 error"); 525 fflush(stdout); 526 return -1; 527 } 528 return rc; 529 } 530 531 //pvfs_chown 532 JNIEXPORT jint JNICALL 533 Java_PVFS2JNI_pvfsChown (JNIEnv *env, jobject obj, jstring path, jlong owner, jlong group) 534 { 535 printf("pvfsChown\n"); 536 fflush(stdout); 496 rc = -1; 497 } 498 if(JNI_DBG) fflush(stdout); 499 return rc; 500 } 501 502 /* pvfs_chown */ 503 JNIEXPORT jint JNICALL 504 Java_PVFS2JNI_pvfsChown(JNIEnv *env, jobject obj, jstring path, jlong owner, jlong group) 505 { 506 if(JNI_DBG) printf("pvfsChown\n"); 537 507 char cpath[PVFS_PATH_MAX]; 538 508 int cpath_len = (*env)->GetStringLength(env, path); … … 544 514 { 545 515 perror("pvfs_chown error"); 546 fflush(stdout); 547 return -1; 548 } 549 return rc; 550 } 551 552 //pvfs_fchown 553 JNIEXPORT jint JNICALL 554 Java_PVFS2JNI_pvfsFchown (JNIEnv *env, jobject obj, int fd, jlong owner, jlong group) 555 { 556 printf("pvfsFchown\n"); 557 fflush(stdout); 516 rc = -1; 517 } 518 if(JNI_DBG) fflush(stdout); 519 return rc; 520 } 521 522 /* pvfs_fchown */ 523 JNIEXPORT jint JNICALL 524 Java_PVFS2JNI_pvfsFchown(JNIEnv *env, jobject obj, int fd, jlong owner, jlong group) 525 { 526 if(JNI_DBG) printf("pvfsFchown\n"); 558 527 uid_t cowner = (uid_t) owner; 559 528 gid_t cgroup = (gid_t) group; … … 562 531 { 563 532 perror("pvfs_fchown error"); 564 fflush(stdout); 565 return -1; 566 } 567 return rc; 568 } 569 570 //pvfs_fchownat 571 JNIEXPORT jint JNICALL 572 Java_PVFS2JNI_pvfsFchownat (JNIEnv *env, jobject obj, int fd, jstring path, jlong owner, jlong group, int flag) 573 { 574 printf("pvfsFchownat\n"); 575 fflush(stdout); 533 rc = -1; 534 } 535 if(JNI_DBG) fflush(stdout); 536 return rc; 537 } 538 539 /* pvfs_fchownat */ 540 JNIEXPORT jint JNICALL 541 Java_PVFS2JNI_pvfsFchownat(JNIEnv *env, jobject obj, int fd, jstring path, jlong owner, jlong group, int flag) 542 { 543 if(JNI_DBG) printf("pvfsFchownat\n"); 576 544 char cpath[PVFS_PATH_MAX]; 577 545 int cpath_len = (*env)->GetStringLength(env, path); … … 583 551 { 584 552 perror("pvfs_fchownat error"); 585 fflush(stdout); 586 return -1; 587 } 588 return rc; 589 } 590 591 //pvfs_chmod 592 JNIEXPORT jint JNICALL 593 Java_PVFS2JNI_pvfsChmod (JNIEnv *env, jobject obj, jstring path, int mode) 594 { 595 printf("pvfsChmod\n"); 596 fflush(stdout); 553 rc = -1; 554 } 555 if(JNI_DBG) fflush(stdout); 556 return rc; 557 } 558 559 /* pvfs_chmod */ 560 JNIEXPORT jint JNICALL 561 Java_PVFS2JNI_pvfsChmod(JNIEnv *env, jobject obj, jstring path, int mode) 562 { 563 if(JNI_DBG) printf("pvfsChmod\n"); 597 564 char cpath[PVFS_PATH_MAX]; 598 565 int cpath_len = (*env)->GetStringLength(env, path); … … 603 570 { 604 571 perror("pvfs_chmod error"); 605 fflush(stdout); 606 return -1; 607 } 608 return rc; 609 } 610 611 //pvfs_fchmod 612 JNIEXPORT jint JNICALL 613 Java_PVFS2JNI_pvfsFchmod (JNIEnv *env, jobject obj, int fd, int mode) 614 { 615 printf("pvfsFchmod\n"); 616 fflush(stdout); 572 rc = -1; 573 } 574 if(JNI_DBG) fflush(stdout); 575 return rc; 576 } 577 578 /* pvfs_fchmod */ 579 JNIEXPORT jint JNICALL 580 Java_PVFS2JNI_pvfsFchmod(JNIEnv *env, jobject obj, int fd, int mode) 581 { 582 if(JNI_DBG) printf("pvfsFchmod\n"); 617 583 mode_t cmode = (mode_t) mode; 618 584 int rc = pvfs_fchmod(fd, cmode); … … 620 586 { 621 587 perror("pvfs_fchmod error"); 622 fflush(stdout);623 return -1;624 }625 return rc; 626 } 627 628 / /pvfs_fchmodat588 rc = -1; 589 } 590 if(JNI_DBG) fflush(stdout); 591 return rc; 592 } 593 594 /* pvfs_fchmodat */ 629 595 JNIEXPORT jint JNICALL 630 596 Java_PVFS2JNI_pvfsFchmodat (JNIEnv *env, jobject obj, int fd, jstring path, int mode, int flag) 631 597 { 632 printf("pvfsFchmodat\n"); 633 fflush(stdout); 598 if(JNI_DBG) printf("pvfsFchmodat\n"); 634 599 char cpath[PVFS_PATH_MAX]; 635 600 int cpath_len = (*env)->GetStringLength(env, path); … … 640 605 { 641 606 perror("pvfs_fchmodat error"); 642 fflush(stdout); 643 return -1; 644 } 645 return rc; 646 } 647 648 649 //pvfs_mkdir 607 rc = -1; 608 } 609 if(JNI_DBG) fflush(stdout); 610 return rc; 611 } 612 613 /* pvfs_mkdir */ 650 614 JNIEXPORT jint JNICALL 651 615 Java_PVFS2JNI_pvfsMkdir (JNIEnv *env, jobject obj, jstring path, jint mode) 652 616 { 653 printf("pvfsMkdir\n"); 654 fflush(stdout); 617 if(JNI_DBG) printf("pvfsMkdir\n"); 655 618 char cpath[PVFS_PATH_MAX]; 656 619 int cpath_len = (*env)->GetStringLength(env, path); … … 662 625 { 663 626 perror("pvfs_mkdir error"); 664 fflush(stdout);665 return -1;666 }667 return rc; 668 } 669 670 / /pvfs_mkdirat627 rc = -1; 628 } 629 if(JNI_DBG) fflush(stdout); 630 return rc; 631 } 632 633 /* pvfs_mkdirat */ 671 634 JNIEXPORT jint JNICALL 672 635 Java_PVFS2JNI_pvfsMkdirat (JNIEnv *env, jobject obj, int dirfd, jstring path, jint mode) 673 636 { 674 printf("pvfsMkdirat\n"); 675 fflush(stdout); 637 if(JNI_DBG) printf("pvfsMkdirat\n"); 676 638 char cpath[PVFS_PATH_MAX]; 677 639 int cpath_len = (*env)->GetStringLength(env, path); … … 683 645 { 684 646 perror("pvfs_mkdirat error"); 685 fflush(stdout);686 return -1;687 }688 return rc; 689 } 690 691 / /pvfs_rmdir647 rc = -1; 648 } 649 if(JNI_DBG) fflush(stdout); 650 return rc; 651 } 652 653 /* pvfs_rmdir */ 692 654 JNIEXPORT jint JNICALL 693 655 Java_PVFS2JNI_pvfsRmdir (JNIEnv *env, jobject obj, jstring path) 694 656 { 695 printf("pvfsRmdir\n"); 696 fflush(stdout); 657 if(JNI_DBG) printf("pvfsRmdir\n"); 697 658 char cpath[PVFS_PATH_MAX]; 698 659 int cpath_len = (*env)->GetStringLength(env, path); … … 703 664 { 704 665 perror("pvfs_rmdir error"); 705 fflush(stdout);706 return -1;707 }708 return rc; 709 } 710 711 / /pvfs_readlink666 rc = -1; 667 } 668 if(JNI_DBG) fflush(stdout); 669 return rc; 670 } 671 672 /* pvfs_readlink */ 712 673 JNIEXPORT jlong JNICALL 713 674 Java_PVFS2JNI_pvfsReadlink (JNIEnv *env, jobject obj, jstring path, jstring buf, jlong bufsiz) 714 675 { 715 printf("pvfsReadlink\n"); 716 fflush(stdout); 676 if(JNI_DBG) printf("pvfsReadlink\n"); 717 677 char cpath[PVFS_PATH_MAX]; 718 678 int cpath_len = (*env)->GetStringLength(env, path); … … 724 684 size_t bufsize = (size_t) bufsiz; 725 685 ssize_t rc = pvfs_readlink(cpath, cbuf, bufsize); 726 if(rc < 0) 686 jlong op = (jlong) rc; 687 if(op < 0) 727 688 { 728 689 perror("pvfs_readlink error"); 729 fflush(stdout); 730 return -1; 731 } 732 jlong op = (jlong) rc; 733 return rc; 734 } 735 736 //pvfs_readlinkat 690 op = -1; 691 } 692 if(JNI_DBG) fflush(stdout); 693 return op; 694 } 695 696 /* pvfs_readlinkat */ 737 697 JNIEXPORT jlong JNICALL 738 698 Java_PVFS2JNI_pvfsReadlinkat (JNIEnv *env, jobject obj, int fd, jstring path, jstring buf, jlong bufsiz) 739 699 { 740 printf("pvfsReadlinkat\n"); 741 fflush(stdout); 700 if(JNI_DBG) printf("pvfsReadlinkat\n"); 742 701 char cpath[PVFS_PATH_MAX]; 743 702 int cpath_len = (*env)->GetStringLength(env, path); … … 749 708 size_t bufsize = (size_t) bufsiz; 750 709 ssize_t rc = pvfs_readlinkat(fd, cpath, cbuf, bufsize); 751 if(rc < 0) 710 jlong op = (jlong) rc; 711 if(op < 0) 752 712 { 753 713 perror("pvfs_readlinkat error"); 754 fflush(stdout); 755 return -1; 756 } 757 jlong op = (jlong) rc; 758 return rc; 759 } 760 761 //pvfs_symlink 714 op = -1; 715 } 716 if(JNI_DBG) fflush(stdout); 717 return op; 718 } 719 720 /* pvfs_symlink */ 762 721 JNIEXPORT int JNICALL 763 722 Java_PVFS2JNI_pvfsSymlink(JNIEnv *env, jobject obj, jstring oldpath, jstring newpath) 764 723 { 765 printf("pvfsSymlink\n"); 766 fflush(stdout); 724 if(JNI_DBG) printf("pvfsSymlink\n"); 767 725 int rc = 0; 768 726 char coldpath[PVFS_PATH_MAX]; … … 776 734 { 777 735 perror("pvfs_symlink error"); 778 fflush(stdout);779 return -1;780 }781 return rc; 782 } 783 784 / /pvfs_symlinkat736 rc = -1; 737 } 738 if(JNI_DBG) fflush(stdout); 739 return rc; 740 } 741 742 /* pvfs_symlinkat */ 785 743 JNIEXPORT int JNICALL 786 744 Java_PVFS2JNI_pvfsSymlinkat(JNIEnv *env, jobject obj, jstring oldpath, int newdirfd, jstring newpath) 787 745 { 788 printf("pvfsSymlinkat\n"); 789 fflush(stdout); 746 if(JNI_DBG) printf("pvfsSymlinkat\n"); 790 747 int rc = 0; 791 748 char coldpath[PVFS_PATH_MAX]; … … 799 756 { 800 757 perror("pvfs_symlinkat error"); 801 fflush(stdout);802 return -1;803 }804 return rc; 805 } 806 807 / /pvfs_link758 rc = -1; 759 } 760 if(JNI_DBG) fflush(stdout); 761 return rc; 762 } 763 764 /* pvfs_link */ 808 765 JNIEXPORT int JNICALL 809 766 Java_PVFS2JNI_pvfsLink(JNIEnv *env, jobject obj, jstring oldpath, jstring newpath) 810 767 { 811 printf("pvfsLink\n"); 812 fflush(stdout); 768 if(JNI_DBG) printf("pvfsLink\n"); 813 769 int rc = 0; 814 770 char coldpath[PVFS_PATH_MAX]; … … 822 778 { 823 779 perror("pvfs_link error"); 824 fflush(stdout);825 return -1;826 }827 return rc; 828 } 829 830 / /pvfs_linkat780 rc = -1; 781 } 782 if(JNI_DBG) fflush(stdout); 783 return rc; 784 } 785 786 /* pvfs_linkat */ 831 787 JNIEXPORT int JNICALL 832 788 Java_PVFS2JNI_pvfsLinkat(JNIEnv *env, jobject obj, int olddirfd, jstring oldpath, int newdirfd, jstring newpath, int flags) 833 789 { 834 printf("pvfsLinkat\n"); 835 fflush(stdout); 790 if(JNI_DBG) printf("pvfsLinkat\n"); 836 791 int rc = 0; 837 792 char coldpath[PVFS_PATH_MAX]; … … 845 800 { 846 801 perror("pvfs_linkat error"); 847 fflush(stdout);848 return -1;849 }850 return rc; 851 } 852 853 / /pvfs_access802 rc = -1; 803 } 804 if(JNI_DBG) fflush(stdout); 805 return rc; 806 } 807 808 /* pvfs_access */ 854 809 JNIEXPORT jint JNICALL 855 810 Java_PVFS2JNI_pvfsAccess (JNIEnv *env, jobject obj, jstring path, int mode) 856 811 { 857 printf("pvfsAccess\n"); 858 fflush(stdout); 812 if(JNI_DBG) printf("pvfsAccess\n"); 859 813 char cpath[PVFS_PATH_MAX]; 860 814 int cpath_len = (*env)->GetStringLength(env, path); … … 864 818 { 865 819 perror("pvfs_access error"); 866 fflush(stdout); 867 return -1; 868 } 869 return rc; 870 } 871 872 873 //pvfs_faccessat 820 rc = -1; 821 } 822 if(JNI_DBG) fflush(stdout); 823 return rc; 824 } 825 826 /* pvfs_faccessat */ 874 827 JNIEXPORT jint JNICALL 875 828 Java_PVFS2JNI_pvfsFaccessat (JNIEnv *env, jobject obj, int fd, jstring path, int mode, int flags) 876 829 { 877 printf("pvfsAccess\n"); 878 fflush(stdout); 830 if(JNI_DBG) printf("pvfsAccess\n"); 879 831 char cpath[PVFS_PATH_MAX]; 880 832 int cpath_len = (*env)->GetStringLength(env, path); … … 884 836 { 885 837 perror("pvfs_faccessat error"); 886 fflush(stdout);887 return -1;888 }889 return rc; 890 } 891 892 / /pvfs_flock838 rc = -1; 839 } 840 if(JNI_DBG) fflush(stdout); 841 return rc; 842 } 843 844 /* pvfs_flock */ 893 845 JNIEXPORT jint JNICALL 894 846 Java_PVFS2JNI_pvfsFlock (JNIEnv *env, jobject obj, int fd, int op) 895 847 { 896 printf("pvfsFlock\n"); 897 fflush(stdout); 848 if(JNI_DBG) printf("pvfsFlock\n"); 898 849 int rc = pvfs_flock(fd, op); 899 850 if(rc < 0) 900 851 { 901 852 perror("pvfs_flock error"); 902 fflush(stdout);903 return -1;904 }905 return rc; 906 } 907 908 / /pvfs_fcntl853 rc = -1; 854 } 855 if(JNI_DBG) fflush(stdout); 856 return rc; 857 } 858 859 /* pvfs_fcntl */ 909 860 JNIEXPORT jint JNICALL 910 861 Java_PVFS2JNI_pvfsFcntl (JNIEnv *env, jobject obj, int fd, int cmd) 911 862 { 912 printf("pvfsFcntl\n"); 913 fflush(stdout); 863 if(JNI_DBG) printf("pvfsFcntl\n"); 914 864 int rc = pvfs_fcntl(fd, cmd); 915 865 if(rc < 0) 916 866 { 917 867 perror("pvfs_fcntl error"); 918 fflush(stdout);919 return -1;920 }921 return rc; 922 } 923 924 / /pvfs_fsync868 rc = -1; 869 } 870 if(JNI_DBG) fflush(stdout); 871 return rc; 872 } 873 874 /* pvfs_fsync */ 925 875 JNIEXPORT jint JNICALL 926 876 Java_PVFS2JNI_pvfsFsync (JNIEnv *env, jobject obj, int fd) 927 877 { 928 printf("pvfsFsync\n"); 929 fflush(stdout); 878 if(JNI_DBG) printf("pvfsFsync\n"); 930 879 int rc = pvfs_fsync(fd); 931 880 if(rc < 0) … … 933 882 perror("pvfs_fsync error"); 934 883 fflush(stdout); 935 return -1; 936 } 937 return rc; 938 } 939 940 //pvfs_fdatasync 884 rc = -1; 885 } 886 if(JNI_DBG) fflush(stdout); 887 return rc; 888 } 889 890 /* pvfs_fdatasync */ 941 891 JNIEXPORT jint JNICALL 942 892 Java_PVFS2JNI_pvfsFdatasync (JNIEnv *env, jobject obj, int fd) 943 893 { 944 printf("pvfsFdatasync\n"); 945 fflush(stdout); 894 if(JNI_DBG) printf("pvfsFdatasync\n"); 946 895 int rc = pvfs_fdatasync(fd); 947 896 if(rc < 0) 948 897 { 949 898 perror("pvfs_fdatasync error"); 950 fflush(stdout);951 return -1;952 }953 return rc; 954 } 955 956 / /pvfs_fadvise899 rc = -1; 900 } 901 if(JNI_DBG) fflush(stdout); 902 return rc; 903 } 904 905 /* pvfs_fadvise */ 957 906 JNIEXPORT jint JNICALL 958 907 Java_PVFS2JNI_pvfsFadvise (JNIEnv *env, jobject obj, int fd, jlong offset, jlong len, int advice) 959 908 { 960 printf("pvfsFadvise\n"); 961 fflush(stdout); 909 if(JNI_DBG) printf("pvfsFadvise\n"); 962 910 off_t coffset = (off_t) offset; 963 911 off_t clen = (off_t) clen; … … 966 914 { 967 915 perror("pvfs_fadvise error"); 968 fflush(stdout);969 return -1;970 }971 return rc; 972 } 973 974 / /pvfs_fadvise64916 rc = -1; 917 } 918 if(JNI_DBG) fflush(stdout); 919 return rc; 920 } 921 922 /* pvfs_fadvise64 */ 975 923 JNIEXPORT jint JNICALL 976 924 Java_PVFS2JNI_pvfsFadvise64 (JNIEnv *env, jobject obj, int fd, jlong offset, jlong len, int advice) 977 925 { 978 printf("pvfsFadvise64\n"); 979 fflush(stdout); 926 if(JNI_DBG) printf("pvfsFadvise64\n"); 980 927 off_t coffset = (off64_t) offset; 981 928 off_t clen = (off64_t) clen; … … 984 931 { 985 932 perror("pvfs_fadvise64 error"); 986 fflush(stdout);987 return -1;988 }989 return rc; 990 } 991 992 / /pvfs_mknod933 rc = -1; 934 } 935 if(JNI_DBG) fflush(stdout); 936 return rc; 937 } 938 939 /* pvfs_mknod */ 993 940 JNIEXPORT jint JNICALL 994 941 Java_PVFS2JNI_pvfsMknod (JNIEnv *env, jobject obj, jstring path, int mode, int dev) 995 942 { 996 printf("pvfsMknod\n"); 997 fflush(stdout); 943 if(JNI_DBG) printf("pvfsMknod\n"); 998 944 char cpath[PVFS_PATH_MAX]; 999 945 int cpath_len = (*env)->GetStringLength(env, path); … … 1005 951 { 1006 952 perror("pvfs_mknod error"); 1007 fflush(stdout);1008 return -1;1009 }1010 return rc; 1011 } 1012 1013 / /pvfs_mknodat953 rc = -1; 954 } 955 if(JNI_DBG) fflush(stdout); 956 return rc; 957 } 958 959 /* pvfs_mknodat */ 1014 960 JNIEXPORT jint JNICALL 1015 961 Java_PVFS2JNI_pvfsMknodat (JNIEnv *env, jobject obj, int dirfd, jstring path, int mode, int dev) 1016 962 { 1017 printf("pvfsMknodat\n"); 1018 fflush(stdout); 963 if(JNI_DBG) printf("pvfsMknodat\n"); 1019 964 char cpath[PVFS_PATH_MAX]; 1020 965 int cpath_len = (*env)->GetStringLength(env, path); … … 1026 971 { 1027 972 perror("pvfs_mknodat error"); 1028 fflush(stdout);1029 return -1;1030 }1031 return rc; 1032 } 1033 1034 / /pvfs_chdir973 rc = -1; 974 } 975 if(JNI_DBG) fflush(stdout); 976 return rc; 977 } 978 979 /* pvfs_chdir */ 1035 980 JNIEXPORT jint JNICALL 1036 981 Java_PVFS2JNI_pvfsChdir (JNIEnv *env, jobject obj, jstring path) 1037 982 { 1038 printf("pvfsChdir\n"); 1039 fflush(stdout); 983 if(JNI_DBG) printf("pvfsChdir\n"); 1040 984 char cpath[PVFS_PATH_MAX]; 1041 985 int cpath_len = (*env)->GetStringLength(env, path); … … 1045 989 { 1046 990 perror("pvfs_chdir error"); 1047 fflush(stdout);1048 return -1;1049 }1050 return rc; 1051 } 1052 1053 / /pvfs_fchdir991 rc = -1; 992 } 993 if(JNI_DBG) fflush(stdout); 994 return rc; 995 } 996 997 /* pvfs_fchdir */ 1054 998 JNIEXPORT jint JNICALL 1055 999 Java_PVFS2JNI_pvfsFchdir (JNIEnv *env, jobject obj, int fd) 1056 1000 { 1057 printf("pvfsFchdir\n"); 1058 fflush(stdout); 1001 if(JNI_DBG) printf("pvfsFchdir\n"); 1059 1002 int rc = pvfs_fchdir(fd); 1060 1003 if(rc < 0) 1061 1004 { 1062 1005 perror("pvfs_fchdir error"); 1063 fflush(stdout);1064 return -1;1065 }1066 return rc; 1067 } 1068 1069 / /pvfs_umask1006 rc = -1; 1007 } 1008 if(JNI_DBG) fflush(stdout); 1009 return rc; 1010 } 1011 1012 /* pvfs_umask */ 1070 1013 JNIEXPORT jint JNICALL 1071 1014 Java_PVFS2JNI_pvfsUmask (JNIEnv *env, jobject obj, int mask) 1072 1015 { 1073 printf("pvfsUmask\n"); 1074 fflush(stdout); 1016 if(JNI_DBG) printf("pvfsUmask\n"); 1075 1017 mode_t cmask = (mode_t) mask; 1076 1018 mode_t rc = pvfs_umask(mask); … … 1078 1020 { 1079 1021 perror("pvfs_umask error"); 1080 fflush(stdout);1081 return -1;1082 }1083 return (int) rc;1022 rc = -1; 1023 } 1024 if(JNI_DBG) fflush(stdout); 1025 return (int) rc; 1084 1026 } 1085 1027 … … 1090 1032 jboolean is_copy; 1091 1033 jbyte * buffer = (*env)->GetByteArrayElements(env, buf, &is_copy); 1092 printf("pvfsRead\n"); 1093 printf("\tfd = %d\n", fd); 1094 printf("\tcount = %lu\n", (uint64_t) count); 1095 is_copy == JNI_TRUE ? printf("\tbuf is_copy\n") : printf("\tbuf !is_copy\n"); 1034 if(JNI_DBG) 1035 { 1036 printf("\tfd = %d\n", fd); 1037 printf("\tcount = %lu\n", (uint64_t) count); 1038 is_copy == JNI_TRUE ? printf("\tbuf is_copy\n") : printf("\tbuf !is_copy\n"); 1039 } 1096 1040 if(!buffer) 1097 1041 { 1098 1042 perror("GetByteArrayElements"); 1099 1043 errno = EFAULT; 1100 return -1; 1044 rc = -1; 1045 goto done; 1101 1046 } 1102 1047 rc = pvfs_read(fd, (void *) buffer, (size_t) count); … … 1104 1049 { 1105 1050 perror("jni pvfs_read"); 1051 rc = -1; 1052 goto done; 1106 1053 } 1107 1054 if(rc > 0) 1108 1055 { 1109 printf("\tread %lld bytes\n", (long long int) rc); 1110 } 1056 if(JNI_DBG) printf("\tread %lld bytes\n", (long long int) rc); 1057 } 1058 done: 1111 1059 /* copy back and free the buffer using 0 */ 1112 1060 (*env)->ReleaseByteArrayElements(env, buf, buffer, 0); 1113 fflush(stdout);1061 if(JNI_DBG) fflush(stdout); 1114 1062 fflush(stderr); 1115 1063 return (jlong) rc; … … 1122 1070 jboolean is_copy; 1123 1071 jbyte * buffer = (*env)->GetByteArrayElements(env, buf, &is_copy); 1124 printf("pvfsPread\n"); 1125 printf("\tfd = %d\n", fd); 1126 printf("\tcount = %lu\n", (uint64_t) count); 1127 printf("\toffset = %lu\n", (uint64_t) offset); 1128 is_copy == JNI_TRUE ? printf("\tbuf is_copy\n") : printf("\tbuf !is_copy\n"); 1072 if(JNI_DBG) 1073 { 1074 printf("pvfsPread\n"); 1075 printf("\tfd = %d\n", fd); 1076 printf("\tcount = %lu\n", (uint64_t) count); 1077 printf("\toffset = %lu\n", (uint64_t) offset); 1078 is_copy == JNI_TRUE ? printf("\tbuf is_copy\n") : printf("\tbuf !is_copy\n"); 1079 } 1129 1080 if(!buffer) 1130 1081 { 1131 1082 perror("GetByteArrayElements"); 1132 1083 errno = EFAULT; 1133 return -1; 1084 rc = -1; 1085 goto done; 1134 1086 } 1135 1087 rc = pvfs_pread(fd, (void *) buffer, (size_t) count, (off_t) offset); … … 1138 1090 perror("jni pvfs_pread"); 1139 1091 } 1140 if(rc > 0) 1141 { 1142 printf("\tread %lld bytes\n", (long long int) rc); 1143 } 1092 else 1093 { 1094 if(JNI_DBG) printf("\tread %lld bytes\n", (long long int) rc); 1095 } 1096 done: 1144 1097 /* copy back and free the buffer using 0 */ 1145 1098 (*env)->ReleaseByteArrayElements(env, buf, buffer, 0); 1146 fflush(stdout);1099 if(JNI_DBG) fflush(stdout); 1147 1100 fflush(stderr); 1148 1101 return (jlong) rc; … … 1155 1108 jboolean is_copy; 1156 1109 jbyte * buffer = (*env)->GetByteArrayElements(env, buf, &is_copy); 1157 printf("pvfsPread64\n"); 1158 printf("\tfd = %d\n", fd); 1159 printf("\tcount = %lu\n", (uint64_t) count); 1160 printf("\toffset = %lu\n", (uint64_t) offset); 1161 is_copy == JNI_TRUE ? printf("\tbuf is_copy\n") : printf("\tbuf !is_copy\n"); 1110 if(JNI_DBG) 1111 { 1112 printf("pvfsPread64\n"); 1113 printf("\tfd = %d\n", fd); 1114 printf("\tcount = %lu\n", (uint64_t) count); 1115 printf("\toffset = %lu\n", (uint64_t) offset); 1116 is_copy == JNI_TRUE ? printf("\tbuf is_copy\n") : printf("\tbuf !is_copy\n"); 1117 } 1162 1118 if(!buffer) 1163 1119 { 1164 1120 perror("GetByteArrayElements"); 1165 1121 errno = EFAULT; 1166 return -1; 1122 rc = -1; 1123 goto done; 1167 1124 } 1168 1125 rc = pvfs_pread64(fd, (void *) buffer, (size_t) count, (off64_t) offset); … … 1171 1128 perror("jni pvfs_pread64"); 1172 1129 } 1173 if(rc > 0)1130 else 1174 1131 { 1175 1132 printf("\tread %lld bytes\n", (long long int) rc); 1176 1133 } 1134 done: 1177 1135 /* copy back and free the buffer using 0 */ 1178 1136 (*env)->ReleaseByteArrayElements(env, buf, buffer, 0); 1179 fflush(stdout);1137 if(JNI_DBG) fflush(stdout); 1180 1138 fflush(stderr); 1181 1139 return (jlong) rc; … … 1188 1146 jboolean is_copy; 1189 1147 jbyte * buffer = (*env)->GetByteArrayElements(env, buf, &is_copy); 1190 printf("pvfsWrite\n"); 1191 printf("\tfd = %d\n", fd); 1192 printf("\tcount = %lu\n", (uint64_t) count); 1193 is_copy == JNI_TRUE ? printf("\tbuf is_copy\n") : printf("\tbuf !is_copy\n"); 1148 if(JNI_DBG) 1149 { 1150 printf("pvfsWrite\n"); 1151 printf("\tfd = %d\n", fd); 1152 printf("\tcount = %lu\n", (uint64_t) count); 1153 is_copy == JNI_TRUE ? printf("\tbuf is_copy\n") : 1154 printf("\tbuf !is_copy\n"); 1155 } 1194 1156 if(!buffer) 1195 1157 { 1196 1158 perror("GetByteArrayElements"); 1197 1159 errno = EFAULT; 1198 return -1; 1160 rc = -1; 1161 goto done; 1199 1162 } 1200 1163 rc = pvfs_write(fd, (void *) buffer, (size_t) count); … … 1207 1170 printf("\twrote %lld bytes\n", (long long int) rc); 1208 1171 } 1209 /* free the buffer without copying back the possible changes in buffer using JNI_ABORT */ 1172 done: 1173 /* free the buffer without copying back the possible changes in buffer 1174 * using JNI_ABORT 1175 */ 1210 1176 (*env)->ReleaseByteArrayElements(env, buf, buffer, JNI_ABORT); 1211 fflush(stdout);1177 if(JNI_DBG) fflush(stdout); 1212 1178 fflush(stderr); 1213 1179 return (jlong) rc; … … 1220 1186 jboolean is_copy; 1221 1187 jbyte * buffer = (*env)->GetByteArrayElements(env, buf, &is_copy); 1222 printf("pvfsPwrite\n"); 1223 printf("\tfd = %d\n", fd); 1224 printf("\tcount = %lu\n", (uint64_t) count); 1225 printf("\toffset = %lu\n", (uint64_t) offset); 1226 is_copy == JNI_TRUE ? printf("\tbuf is_copy\n") : printf("\tbuf !is_copy\n"); 1188 if(JNI_DBG) 1189 { 1190 printf("pvfsPwrite\n"); 1191 printf("\tfd = %d\n", fd); 1192 printf("\tcount = %lu\n", (uint64_t) count); 1193 printf("\toffset = %lu\n", (uint64_t) offset); 1194 is_copy == JNI_TRUE ? printf("\tbuf is_copy\n") : 1195 printf("\tbuf !is_copy\n"); 1196 } 1227 1197 if(!buffer) 1228 1198 { 1229 1199 perror("GetByteArrayElements"); 1230 1200 errno = EFAULT; 1231 r eturn-1;1201 rc = -1; 1232 1202 } 1233 1203 rc = pvfs_pwrite(fd, (void *) buffer, (size_t) count, (off_t) offset); … … 1236 1206 perror("jni pvfs_pwrite"); 1237 1207 } 1238 if(rc > 0) 1239 { 1240 printf("\twrote %lld bytes\n", (long long int) rc); 1241 } 1242 /* free the buffer without copying back the possible changes in buffer using JNI_ABORT */ 1208 else 1209 { 1210 if(JNI_DBG) printf("\twrote %lld bytes\n", (long long int) rc); 1211 } 1212 done: 1213 /** free the buffer without copying back the possible changes in buffer 1214 * using JNI_ABORT 1215 */ 1243 1216 (*env)->ReleaseByteArrayElements(env, buf, buffer, JNI_ABORT); 1244 fflush(std out);1245 fflush(stderr);1217 fflush(stderr); 1218 if(JNI_DBG) fflush(stdout); 1246 1219 return (jlong) rc; 1247 1220 } … … 1253 1226 jboolean is_copy; 1254 1227 jbyte * buffer = (*env)->GetByteArrayElements(env, buf, &is_copy); 1255 printf("pvfsPwrite64\n"); 1256 printf("\tfd = %d\n", fd); 1257 printf("\tcount = %lu\n", (uint64_t) count); 1258 printf("\toffset = %lu\n", (uint64_t) offset); 1259 is_copy == JNI_TRUE ? printf("\tbuf is_copy\n") : printf("\tbuf !is_copy\n"); 1228 if(JNI_DBG) 1229 { 1230 printf("pvfsPwrite64\n"); 1231 printf("\tfd = %d\n", fd); 1232 printf("\tcount = %lu\n", (uint64_t) count); 1233 printf("\toffset = %lu\n", (uint64_t) offset); 1234 is_copy == JNI_TRUE ? printf("\tbuf is_copy\n") : 1235 printf("\tbuf !is_copy\n"); 1236 } 1260 1237 if(!buffer) 1261 1238 { 1262 1239 perror("GetByteArrayElements"); 1263 1240 errno = EFAULT; 1264 return -1; 1241 rc = -1; 1242 goto done; 1265 1243 } 1266 1244 rc = pvfs_pwrite64(fd, (void *) buffer, (size_t) count, (off_t) offset); … … 1269 1247 perror("jni pvfs_pwrite64"); 1270 1248 } 1271 if(rc > 0) 1272 { 1273 printf("\twrote %lld bytes\n", (long long int) rc); 1274 } 1275 /* free the buffer without copying back the possible changes in buffer using JNI_ABORT */ 1249 else 1250 { 1251 if(JNI_DBG) printf("\twrote %lld bytes\n", (long long int) rc); 1252 } 1253 done: 1254 /** Free the buffer without copying back the possible changes in buffer 1255 * using JNI_ABORT 1256 */ 1276 1257 (*env)->ReleaseByteArrayElements(env, buf, buffer, JNI_ABORT); 1277 fflush(std out);1278 fflush(stderr);1258 fflush(stderr); 1259 if(JNI_DBG) fflush(stdout); 1279 1260 return (jlong) rc; 1280 1261 } … … 1294 1275 */ 1295 1276 1296 / /pvfs_stat1277 /* pvfs_stat */ 1297 1278 JNIEXPORT jint JNICALL 1298 1279 Java_PVFS2JNI_pvfsStat (JNIEnv *env, jobject obj, jlong jarg, jstring path) 1299 1280 { 1300 printf("pvfsStat\n");1281 if(JNI_DBG) printf("pvfsStat\n"); 1301 1282 struct stat *arg; 1302 1283 arg = (struct stat *)jarg; … … 1308 1289 { 1309 1290 perror("pvfs_stat error"); 1310 fflush(stdout); 1311 return -1; 1312 } 1313 return rc; 1314 } 1315 1316 //pvfs_stat_mask 1291 rc = -1; 1292 } 1293 fflush(stderr); 1294 if(JNI_DBG) fflush(stdout); 1295 return rc; 1296 } 1297 1298 /* pvfs_stat_mask */ 1317 1299 JNIEXPORT jint JNICALL 1318 1300 Java_PVFS2JNI_pvfsStatMask (JNIEnv *env, jobject obj, jlong jarg, jstring path, jlong mask) 1319 1301 { 1320 printf("pvfsStatMask\n");1302 if(JNI_DBG) printf("pvfsStatMask\n"); 1321 1303 struct stat *arg; 1322 1304 arg = (struct stat *)jarg; … … 1329 1311 { 1330 1312 perror("pvfs_stat_mask error"); 1331 fflush(stdout); 1332 return -1; 1333 } 1334 return rc; 1335 } 1336 1337 //pvfs_fstat 1313 rc = -1; 1314 } 1315 fflush(stderr); 1316 if(JNI_DBG) fflush(stdout); 1317 return rc; 1318 } 1319 1320 /* pvfs_fstat */ 1338 1321 JNIEXPORT jint JNICALL 1339 1322 Java_PVFS2JNI_pvfsFstat (JNIEnv *env, jobject obj, jlong jarg, int fd) 1340 1323 { 1341 printf("pvfsFstat\n");1324 if(JNI_DBG) printf("pvfsFstat\n"); 1342 1325 struct stat *arg; 1343 1326 arg = (struct stat *)jarg; … … 1346 1329 { 1347 1330 perror("pvfs_fstat error"); 1348 fflush(stdout); 1349 return -1; 1350 } 1351 return rc; 1352 } 1353 1354 1355 //pvfs_fstat_mask 1331 rc = -1; 1332 } 1333 fflush(stderr); 1334 if(JNI_DBG) fflush(stdout); 1335 return rc; 1336 } 1337 1338 1339 /* pvfs_fstat_mask */ 1356 1340 JNIEXPORT jint JNICALL 1357 1341 Java_PVFS2JNI_pvfsFstatMask (JNIEnv *env, jobject obj, jlong jarg, int fd, jlong mask) 1358 1342 { 1359 printf("pvfsFstatMask\n");1343 if(JNI_DBG) printf("pvfsFstatMask\n"); 1360 1344 struct stat *arg; 1361 1345 arg = (struct stat *)jarg; … … 1365 1349 { 1366 1350 perror("pvfs_fstat_mask error"); 1367 fflush(stdout); 1368 return -1; 1369 } 1370 return rc; 1371 } 1372 1373 //pvfs_Fstatat 1351 rc = -1; 1352 } 1353 fflush(stderr); 1354 if(JNI_DBG) fflush(stdout); 1355 return rc; 1356 } 1357 1358 /* pvfs_Fstatat */ 1374 1359 JNIEXPORT jint JNICALL 1375 1360 Java_PVFS2JNI_pvfsFstatat (JNIEnv *env, jobject obj, jlong jarg, int fd, jstring path, int flag) 1376 1361 { 1377 printf("pvfFstatat\n");1362 if(JNI_DBG) printf("pvfFstatat\n"); 1378 1363 struct stat *arg; 1379 1364 arg = (struct stat *)jarg; … … 1385 1370 { 1386 1371 perror("pvfs_fstatat error"); 1387 fflush(stdout); 1388 return -1; 1389 } 1390 return rc; 1391 } 1392 1393 //pvfs_lstat 1372 rc = -1; 1373 } 1374 fflush(stderr); 1375 if(JNI_DBG) fflush(stdout); 1376 return rc; 1377 } 1378 1379 /* pvfs_lstat */ 1394 1380 JNIEXPORT jint JNICALL 1395 1381 Java_PVFS2JNI_pvfsLstat (JNIEnv *env, jobject obj, jlong jarg, jstring path) 1396 1382 { 1397 printf("pvfsLstat\n");1383 if(JNI_DBG) printf("pvfsLstat\n"); 1398 1384 struct stat *arg; 1399 1385 arg = (struct stat *)jarg; … … 1405 1391 { 1406 1392 perror("pvfs_lstat error"); 1407 fflush(stdout); 1408 return -1; 1409 } 1410 return rc; 1411 } 1412 1413 1414 //pvfs_lstat_mask 1393 rc = -1; 1394 } 1395 fflush(stderr); 1396 if(JNI_DBG) fflush(stdout); 1397 return rc; 1398 } 1399 1400 1401 /* pvfs_lstat_mask */ 1415 1402 JNIEXPORT jint JNICALL 1416 1403 Java_PVFS2JNI_pvfsLstatMask (JNIEnv *env, jobject obj, jlong jarg, jstring path, jlong mask) 1417 1404 { 1418 printf("pvfsLstatMask\n");1405 if(JNI_DBG) printf("pvfsLstatMask\n"); 1419 1406 struct stat *arg; 1420 1407 arg = (struct stat *)jarg; … … 1427 1414 { 1428 1415 perror("pvfs_lstat_mask error"); 1429 fflush(stdout); 1430 return -1; 1431 } 1432 return rc; 1433 } 1434 1435 //pvfs_stat64 1416 rc = -1; 1417 } 1418 fflush(stderr); 1419 if(JNI_DBG) fflush(stdout); 1420 return rc; 1421 } 1422 1423 /* pvfs_stat64 */ 1436 1424 JNIEXPORT jint JNICALL 1437 1425 Java_PVFS2JNI_pvfsStat64 (JNIEnv *env, jobject obj, jlong jarg, jstring path) 1438 1426 { 1439 printf("pvfsStat64\n");1427 if(JNI_DBG) printf("pvfsStat64\n"); 1440 1428 struct stat64 *arg; 1441 1429 arg = (struct stat64 *)jarg; … … 1447 1435 { 1448 1436 perror("pvfs_stat64 error"); 1449 fflush(stdout);1450 return -1;1451 }1452 return rc;1453 } 1454 1455 1456 / /pvfs_Fstat641437 rc = -1; 1438 } 1439 fflush(stderr); 1440 if(JNI_DBG) fflush(stdout); 1441 return rc; 1442 } 1443 1444 /* pvfs_Fstat64 */ 1457 1445 JNIEXPORT jint JNICALL 1458 1446 Java_PVFS2JNI_pvfsFstat64 (JNIEnv *env, jobject obj, jlong jarg, int fd) 1459 1447 { 1460 printf("pvfsFstat64\n");1448 if(JNI_DBG) printf("pvfsFstat64\n"); 1461 1449 struct stat64 *arg; 1462 1450 arg = (struct stat64 *)jarg; … … 1465 1453 { 1466 1454 perror("pvfs_fstat64 error"); 1467 fflush(stdout);1468 return -1;1469 }1470 return rc;1471 } 1472 1473 1474 / /pvfs_Fstatat641455 rc = -1; 1456 } 1457 fflush(stderr); 1458 if(JNI_DBG) fflush(stdout); 1459 return rc; 1460 } 1461 1462 /* pvfs_Fstatat64 */ 1475 1463 JNIEXPORT jint JNICALL 1476 1464 Java_PVFS2JNI_pvfsFstatat64 (JNIEnv *env, jobject obj, jlong jarg, int fd, jstring path, int flag) 1477 1465 { 1478 printf("pvfsFstatat64\n");1466 if(JNI_DBG) printf("pvfsFstatat64\n"); 1479 1467 struct stat64 *arg; 1480 1468 arg = (struct stat64 *)jarg; … … 1486 1474 { 1487 1475 perror("pvfs_fstatat64 error"); 1488 fflush(stdout);1489 return -1;1490 }1491 return rc;1492 } 1493 1494 1495 / /pvfs_lstat641476 rc = -1; 1477 } 1478 fflush(stderr); 1479 if(JNI_DBG) fflush(stdout); 1480 return rc; 1481 } 1482 1483 /* pvfs_lstat64 */ 1496 1484 JNIEXPORT jint JNICALL 1497 1485 Java_PVFS2JNI_pvfsLstat64 (JNIEnv *env, jobject obj, jlong jarg, jstring path) 1498 1486 { 1499 printf("pvfsLstat64\n");1487 if(JNI_DBG) printf("pvfsLstat64\n"); 1500 1488 struct stat64 *arg; 1501 1489 arg = (struct stat64 *)jarg; … … 1507 1495 { 1508 1496 perror("pvfs_lstat64 error"); 1509 fflush(stdout); 1510 return -1; 1511 } 1512 return rc; 1513 } 1514 //FILLSTAT64 1497 rc = -1; 1498 } 1499 fflush(stderr); 1500 if(JNI_DBG) fflush(stdout); 1501 return rc; 1502 } 1503 1504 /* FILLSTAT64 */ 1515 1505 JNIEXPORT jlong JNICALL 1516 1506 Java_PVFS2JNI_FillStat64 (JNIEnv *env, jobject obj, jobject x) 1517 1507 { 1518 printf("FillStat64\n");1519 fflush(stdout);1508 if(JNI_DBG) printf("FillStat64\n"); 1509 jlong rc = 0; 1520 1510 jfieldID fid1; 1521 1511 jfieldID fid2; … … 1611 1601 } 1612 1602 struct stat64 *cstat64 = (struct stat64 *) malloc(sizeof(struct stat64)); 1603 if(!cstat64) 1604 { 1605 return -1; 1606 } 1613 1607 st_dev = (*env)->GetLongField(env, x, fid1); 1614 1608 dev_t cst_dev = (dev_t) st_dev; … … 1650 1644 time_t cst_ctime = (time_t) st_ctim; 1651 1645 cstat64->st_ctime = cst_ctime; 1646 /* TODO: this looks incorrect */ 1652 1647 long lp = (long)cstat64; 1653 1648 free(cstat64); 1649 if(JNI_DBG) fflush(stdout); 1654 1650 return lp; 1655 1651 } 1656 1652 1657 1658 //FILLSTAT 1653 /* FILLSTAT */ 1659 1654 JNIEXPORT jlong JNICALL 1660 1655 Java_PVFS2JNI_FillStat (JNIEnv *env, jobject obj, jobject x) 1661 1656 { 1662 printf("FillStat\n"); 1663 fflush(stdout); 1657 if(JNI_DBG) printf("FillStat\n"); 1664 1658 jfieldID fid1; 1665 1659 jfieldID fid2; … … 1755 1749 } 1756 1750 struct stat *cstat = (struct stat *)malloc(sizeof(struct stat)); 1751 if(!cstat) 1752 { 1753 perror("malloc failure"); 1754 goto done; 1755 } 1757 1756 st_dev = (*env)->GetLongField(env, x, fid1); 1758 1757 dev_t cst_dev = (dev_t) st_dev; … … 1794 1793 time_t cst_ctime = (time_t) st_ctim; 1795 1794 cstat->st_ctime = cst_ctime; 1795 /* TODO: this looks incorrect */ 1796 1796 long lp = (long)cstat; 1797 free(cstat); 1797 done: 1798 if(cstat) 1799 { 1800 free(cstat); 1801 } 1802 fflush(stderr); 1803 if(JNI_DBG) fflush(stdout); 1798 1804 return lp; 1799 1805 } … … 1805 1811 arg = (struct stat64 *)jarg; 1806 1812 disp64(arg); 1807 //printf("=======DISPLAY========\n"); 1808 //printf("The st_dev is: %ld\n", arg->st_dev); 1813 /* 1814 printf("=======DISPLAY========\n"); 1815 printf("The st_dev is: %ld\n", arg->st_dev); 1816 */ 1809 1817 } 1810 1818 … … 1812 1820 Java_PVFS2JNI_UseStat (JNIEnv *env, jobject obj, jlong jarg) 1813 1821 { 1814 struct stat xyz;1815 1822 struct stat *arg; 1816 1823 arg = (struct stat *)jarg; 1817 1824 disp(arg); 1818 //printf("=======DISPLAY========\n"); 1819 //printf("The st_dev is: %ld\n", arg->st_dev); 1820 } 1821 1825 /* 1826 printf("=======DISPLAY========\n"); 1827 printf("The st_dev is: %ld\n", arg->st_dev); 1828 */ 1829 } 1822 1830 1823 1831 JNIEXPORT jlong JNICALL 1824 1832 Java_PVFS2JNI_FillDirent (JNIEnv *env, jobject obj, jobject x) 1825 1833 { 1826 printf("FillDirent\n"); 1827 fflush(stdout); 1834 if(JNI_DBG) printf("FillDirent\n"); 1835 long lp = 0; 1836 struct dirent *cdirent = 0; 1828 1837 jfieldID fid1; 1829 1838 jfieldID fid2; … … 1840 1849 if (fid1 == NULL) 1841 1850 { 1842 return; 1851 lp = -1; 1852 goto done; 1843 1853 } 1844 1854 fid2 = (*env)->GetFieldID(env, cls1, "d_off", "J"); 1845 1855 if (fid2 == NULL) 1846 1856 { 1847 return; 1857 lp = -1; 1858 goto done; 1848 1859 } 1849 1860 fid3 = (*env)->GetFieldID(env, cls1, "d_reclen", "I"); 1850 1861 if (fid3 == NULL) 1851 1862 { 1852 return; 1863 lp = -1; 1864 goto done; 1853 1865 } 1854 1866 fid4 = (*env)->GetFieldID(env, cls1, "d_type", "Ljava/lang/String;"); 1855 1867 if (fid4 == NULL) 1856 1868 { 1857 return; 1869 lp = -1; 1870 goto done; 1858 1871 } 1859 1872 fid5 = (*env)->GetFieldID(env, cls1, "d_name", "Ljava/lang/String;"); 1860 1873 if (fid5 == NULL) 1861 1874 { 1862 return; 1875 lp = -1; 1876 goto done; 1863 1877 } 1864 1878 const char* strdtype; 1865 1879 const char* strdname; 1866 struct dirent *cdirent = (struct dirent *)malloc(sizeof(struct dirent)); 1880 cdirent = (struct dirent *) malloc(sizeof(struct dirent)); 1881 if(!cdirent) 1882 { 1883 lp = -1; 1884 perror("malloc failed"); 1885 goto done; 1886 } 1867 1887 d_ino = (*env)->GetLongField(env, x, fid1); 1868 1888 __ino_t cd_ino = (__ino_t) d_ino; … … 1876 1896 d_type = (*env)->GetObjectField(env, x, fid4); 1877 1897 strdtype = (*env)->GetStringUTFChars(env, d_type, NULL); 1878 if (strdtype == NULL) 1879 { 1880 return; /* out of memory */ 1881 } 1882 if((strlen(strdtype)) != 1) 1883 { 1898 if (!strdtype) 1899 { 1900 lp = -1; /* out of memory */ 1901 perror("GetStringUTFChars failed"); 1902 goto done; 1903 } 1904 if(strlen(strdtype) != 1) 1905 { 1906 lp = -1; 1884 1907 perror("d_type is of type char, hence length cannot exceed 1\n"); 1885 fflush(stdout); 1886 return; 1908 goto done; 1887 1909 } 1888 1910 else … … 1891 1913 strcpy(dtypearr, strdtype); 1892 1914 char cd_type = dtypearr[0]; 1893 //printf("The d_type is: %c \n", cd_type); 1894 //fflush(stdout); 1915 if(JNI_DBG) printf("The d_type is: %c \n", cd_type); 1895 1916 cdirent->d_type = cd_type; 1896 1917 } 1897 //char cstrdtype = &(strdtype); 1898 //printf("The d_type is: %s \n", chartest); 1918 /* 1919 char cstrdtype = &(strdtype); 1920 printf("The d_type is: %s \n", chartest); 1921 */ 1899 1922 (*env)->ReleaseStringUTFChars(env, d_type, strdtype); 1900 1923 d_name = (*env)->GetObjectField(env, x, fid5); … … 1902 1925 if (strdname == NULL) 1903 1926 { 1904 return; /* out of memory */ 1927 lp = -1; 1928 perror("GetStringUTFChars failed"); 1929 goto done; 1905 1930 } 1906 1931 if((strlen(strdname)) > 256) 1907 1932 { 1933 lp = -1; 1908 1934 perror("Length of strdname cannot exceed 250\n"); 1909 fflush(stdout); 1910 return; 1935 goto done; 1911 1936 } 1912 1937 else … … 1917 1942 } 1918 1943 (*env)->ReleaseStringUTFChars(env, d_name, strdname); 1919 long lp = (long)cdirent; 1920 free(cdirent); 1944 lp = (long)cdirent; 1945 done: 1946 if(cdirent) 1947 { 1948 free(cdirent); 1949 } 1950 fflush(stderr); 1951 if(JNI_DBG) fflush(stdout); 1921 1952 return lp; 1922 1953 } 1954 1923 1955 void dispdirent(struct dirent *abc) 1924 1956 { 1925 printf("=======DISPLAY========\n"); 1926 printf("The d_ino is: %d\n", (int) abc->d_ino); 1927 printf("The d_off is: %d\n", (int) abc->d_off); 1928 printf("The d_reclen is: %d\n", abc->d_reclen); 1929 printf("The d_type is: %c \n", abc->d_type); 1930 printf("The d_name is: %s \n", abc->d_name); 1931 fflush(stdout); 1932 } 1957 if(JNI_DBG) 1958 { 1959 printf("=======DISPLAY========\n"); 1960 printf("The d_ino is: %d\n", (int) abc->d_ino); 1961 printf("The d_off is: %d\n", (int) abc->d_off); 1962 printf("The d_reclen is: %d\n", abc->d_reclen); 1963 printf("The d_type is: %c \n", abc->d_type); 1964 printf("The d_name is: %s \n", abc->d_name); 1965 fflush(stdout); 1966 } 1967 } 1968 1933 1969 JNIEXPORT jlong JNICALL 1934 1970 Java_PVFS2JNI_UseDirent (JNIEnv *env, jobject obj, jlong jarg) 1935 1971 { 1936 struct dirent xyz;1937 1972 struct dirent *arg; 1938 1973 arg = (struct dirent *)jarg; 1939 1974 dispdirent(arg); 1940 //printf("=======DISPLAY========\n"); 1941 //printf("The st_dev is: %ld\n", arg->st_dev); 1942 } 1943 1944 //FILL DIRENT 1975 /* 1976 printf("=======DISPLAY========\n"); 1977 printf("The st_dev is: %ld\n", arg->st_dev); 1978 */ 1979 } 1980 1981 /* FILL DIRENT */ 1945 1982 JNIEXPORT jlong JNICALL 1946 1983 Java_PVFS2JNI_FillDirent64(JNIEnv *env, jobject obj, jobject x) 1947 1984 { 1948 printf("FillDirent64\n"); 1949 fflush(stdout); 1985 if(JNI_DBG) printf("FillDirent64\n"); 1986 long lp = 0; 1987 struct dirent64 *cdirent64 = NULL; 1988 const char* strdtype = NULL; 1989 const char* strdname = NULL; 1950 1990 jfieldID fid1; 1951 1991 jfieldID fid2; … … 1962 2002 if (fid1 == NULL) 1963 2003 { 1964 return; 2004 lp = -1; 2005 goto done; 1965 2006 } 1966 2007 fid2 = (*env)->GetFieldID(env, cls1, "d_off", "J"); 1967 2008 if (fid2 == NULL) 1968 2009 { 1969 return; 2010 lp = -1; 2011 goto done; 1970 2012 } 1971 2013 fid3 = (*env)->GetFieldID(env, cls1, "d_reclen", "I"); 1972 2014 if (fid3 == NULL) 1973 2015 { 1974 return; 2016 lp = -1; 2017 goto done; 1975 2018 } 1976 2019 fid4 = (*env)->GetFieldID(env, cls1, "d_type", "Ljava/lang/String;"); 1977 2020 if (fid4 == NULL) 1978 2021 { 1979 return; 2022 lp = -1; 2023 goto done; 1980 2024 } 1981 2025 fid5 = (*env)->GetFieldID(env, cls1, "d_name", "Ljava/lang/String;"); 1982 2026 if (fid5 == NULL) 1983 2027 { 1984 return; 1985 } 1986 const char* strdtype; 1987 const char* strdname; 1988 struct dirent64 *cdirent64 = (struct dirent64 *)malloc(sizeof(struct dirent64)); 2028 lp = -1; 2029 goto done; 2030 } 2031 cdirent64 = (struct dirent64 *) malloc(sizeof(struct dirent64)); 1989 2032 d_ino = (*env)->GetLongField(env, x, fid1); 1990 2033 __ino64_t cd_ino = (__ino64_t) d_ino; … … 2000 2043 if (strdtype == NULL) 2001 2044 { 2002 return; /* out of memory */ 2003 } 2004 if((strlen(strdtype)) != 1) 2005 { 2045 lp = -1; 2046 perror("GetStringUTFChars failed"); 2047 goto done; 2048 } 2049 if(strlen(strdtype) != 1) 2050 { 2051 lp = -1; 2006 2052 perror("d_type is of type char, hence length cannot exceed 1\n"); 2007 fflush(stdout); 2008 return; 2053 goto done; 2009 2054 } 2010 2055 else … … 2013 2058 strcpy(dtypearr, strdtype); 2014 2059 char cd_type = dtypearr[0]; 2015 //printf("The d_type is: %c \n", cd_type); 2016 //fflush(stdout); 2060 /* 2061 printf("The d_type is: %c \n", cd_type); 2062 fflush(stdout); 2063 */ 2017 2064 cdirent64->d_type = cd_type; 2018 2065 } 2019 //char cstrdtype = &(strdtype); 2020 //printf("The d_type is: %s \n", chartest); 2066 /* 2067 char cstrdtype = &(strdtype); 2068 printf("The d_type is: %s \n", chartest); 2069 */ 2021 2070 (*env)->ReleaseStringUTFChars(env, d_type, strdtype); 2022 2071 d_name = (*env)->GetObjectField(env, x, fid5); … … 2024 2073 if (strdname == NULL) 2025 2074 { 2026 return; /* out of memory */ 2027 } 2028 if((strlen(strdname)) > 257) 2029 { 2075 lp = -1; 2076 perror("GetStringUTFChars failed"); 2077 goto done; 2078 } 2079 if(strlen(strdname) > 257) 2080 { 2081 lp = -1; 2030 2082 perror("Length of strdname cannot exceed 250\n"); 2031 fflush(stdout); 2032 return; 2083 goto done; 2033 2084 } 2034 2085 else … … 2039 2090 } 2040 2091 (*env)->ReleaseStringUTFChars(env, d_name, strdname); 2041 long lp = (long)cdirent64; 2042 free(cdirent64); 2092 lp = (long)cdirent64; 2093 done: 2094 if(cdirent64) 2095 { 2096 free(cdirent64); 2097 } 2098 if(JNI_DBG) fflush(stdout); 2043 2099 return lp; 2044 2100 } … … 2046 2102 void dispdirent64(struct dirent64 *abc) 2047 2103 { 2048 printf("=======DISPLAY========\n"); 2049 printf("The d_ino is: %d\n", (int) abc->d_ino); 2050 printf("The d_off is: %d\n", (int) abc->d_off); 2051 printf("The d_reclen is: %d\n", abc->d_reclen); 2052 printf("The d_type is: %c \n", abc->d_type); 2053 printf("The d_name is: %s \n", abc->d_name); 2054 fflush(stdout); 2055 } 2104 if(JNI_DBG) 2105 { 2106 printf("=======DISPLAY========\n"); 2107 printf("The d_ino is: %d\n", (int) abc->d_ino); 2108 printf("The d_off is: %d\n", (int) abc->d_off); 2109 printf("The d_reclen is: %d\n", abc->d_reclen); 2110 printf("The d_type is: %c \n", abc->d_type); 2111 printf("The d_name is: %s \n", abc->d_name); 2112 fflush(stdout); 2113 } 2114 } 2115 2056 2116 JNIEXPORT jlong JNICALL 2057 2117 Java_PVFS2JNI_UseDirent64 (JNIEnv *env, jobject obj, jlong jarg) 2058 2118 { 2059 struct dirent64 xyz;2060 2119 struct dirent64 *arg; 2061 2120 arg = (struct dirent64 *)jarg; 2062 2121 dispdirent64(arg); 2063 //printf("=======DISPLAY========\n"); 2064 //printf("The st_dev is: %ld\n", arg->st_dev); 2065 } 2066 2067 2068 //FILL STATFS 2122 /* 2123 printf("=======DISPLAY========\n"); 2124 printf("The st_dev is: %ld\n", arg->st_dev); 2125 */ 2126 } 2127 2128 /* FILL STATFS */ 2069 2129 JNIEXPORT jlong JNICALL 2070 2130 Java_PVFS2JNI_FillStatfs (JNIEnv *env, jobject obj, jobject x, jlong jarg) 2071 2131 { 2072 printf("FillStatfs\n"); 2073 fflush(stdout); 2132 if(JNI_DBG) printf("FillStatfs\n"); 2133 long lp = 0; 2134 struct statfs *cstatfs = NULL; 2074 2135 jfieldID fid1; 2075 2136 jfieldID fid2; … … 2099 2160 if (fid1 == NULL) 2100 2161 { 2101 return; 2162 lp = -1; 2163 goto done; 2102 2164 } 2103 2165 fid2 = (*env)->GetFieldID(env, cls1, "f_bsize", "J"); 2104 2166 if (fid2 == NULL) 2105 2167 { 2106 return; 2168 lp = -1; 2169 goto done; 2107 2170 } 2108 2171 fid3 = (*env)->GetFieldID(env, cls1, "f_blocks", "J"); 2109 2172 if (fid3 == NULL) 2110 2173 { 2111 return; 2174 lp = -1; 2175 goto done; 2112 2176 } 2113 2177 fid4 = (*env)->GetFieldID(env, cls1, "f_bfree", "J"); 2114 2178 if (fid4 == NULL) 2115 2179 { 2116 return; 2180 lp = -1; 2181 goto done; 2117 2182 } 2118 2183 fid5 = (*env)->GetFieldID(env, cls1, "f_bavail", "J"); 2119 2184 if (fid5 == NULL) 2120 2185 { 2121 return; 2186 lp = -1; 2187 goto done; 2122 2188 } 2123 2189 fid6 = (*env)->GetFieldID(env, cls1, "f_files", "J"); 2124 2190 if (fid6 == NULL) 2125 2191 { 2126 return; 2192 lp = -1; 2193 goto done; 2127 2194 } 2128 2195 fid7 = (*env)->GetFieldID(env, cls1, "f_ffree", "J"); 2129 2196 if (fid7 == NULL) 2130 2197 { 2131 return; 2198 lp = -1; 2199 goto done; 2132 2200 } 2133 2201 fid9 = (*env)->GetFieldID(env, cls1, "f_namelen", "J"); 2134 2202 if (fid9 == NULL) 2135 2203 { 2136 return; 2204 lp = -1; 2205 goto done; 2137 2206 } 2138 2207 fid10 = (*env)->GetFieldID(env, cls1, "f_frsize", "J"); 2139 2208 if (fid10 == NULL) 2140 2209 { 2141 return; 2210 lp = -1; 2211 goto done; 2142 2212 } 2143 2213 fid11 = (*env)->GetFieldID(env, cls1, "f_spare", "[J"); 2144 2214 if (fid11 == NULL) 2145 2215 { 2146 return; 2216 lp = -1; 2217 goto done; 2147 2218 } 2148 2219 fid12 = (*env)->GetFieldID(env, cls1, "f_flags", "J"); 2149 2220 if (fid12 == NULL) 2150 2221 { 2151 return; 2152 } 2153 /* __SWORD_TYPE* tmp; 2222 lp = -1; 2223 goto done; 2224 } 2225 /* 2226 __SWORD_TYPE* tmp; 2154 2227 tmp = (__SWORD_TYPE *) malloc( 5 * sizeof(__SWORD_TYPE) ); 2155 2228 tmp[0]=10; 2156 2229 tmp[1]=20; 2157 printf("tmp=%ld\n",tmp[0]);*/ 2158 struct statfs *cstatfs = (struct statfs *)malloc(sizeof(struct statfs) + 1); 2159 //long int *(cstatfs->f_spare[0]) = tmp[0]; 2160 /*long int i= 10; 2230 printf("tmp=%ld\n",tmp[0]); 2231 */ 2232 cstatfs = (struct statfs *)malloc(sizeof(struct statfs) + 1); 2233 /* 2234 long int i= 10; 2235 long int *(cstatfs->f_spare[0]) = tmp[0]; 2161 2236 cstatfs->f_spare[4]=10; 2162 2237 printf("f_spare[4]=%d\n",cstatfs->f_spare[4]); … … 2192 2267 __SWORD_TYPE cf_flags = (__SWORD_TYPE) f_flags; 2193 2268 cstatfs->f_flags = cf_flags; 2194 //buf=(*env)->GetLongArrayElements(env,x,fid11); 2195 //printf("ARRAY:%ld",buf[0]; 2269 /* 2270 buf=(*env)->GetLongArrayElements(env,x,fid11); 2271 printf("ARRAY:%ld",buf[0]; 2272 */ 2196 2273 jlong buf[5]; 2197 2274 jlongArray ar; … … 2205 2282 cbuf[ival] = buf[ival]; 2206 2283 } 2207 / /printf("cbuf=%ld",cbuf[4]);2284 /* printf("cbuf=%ld",cbuf[4]); */ 2208 2285 for(jval = 0; jval <= 4; jval++) 2209 2286 { 2210 2287 cstatfs->f_spare[jval] = cbuf[jval]; 2211 2288 } 2212 / /cstatfs->f_spare[4] = 10;2289 /* cstatfs->f_spare[4] = 10; */ 2213 2290 fsid_t *arg; 2214 2291 arg = (fsid_t *)jarg; 2215 2292 cstatfs->f_fsid.__val[0] = arg->__val[0]; 2216 2293 cstatfs->f_fsid.__val[1] = arg->__val[1]; 2217 //printf("cstatfs.fsid1=%d\n",cstatfs->f_fsid.__val[0]); 2218 //printf("cstatfs.fsid2=%d\n",cstatfs->f_fsid.__val[1]); 2294 /* 2295 printf("cstatfs.fsid1=%d\n",cstatfs->f_fsid.__val[0]); 2296 printf("cstatfs.fsid2=%d\n",cstatfs->f_fsid.__val[1]); 2297 */ 2298 /* TODO: this looks incorrect */ 2299 lp = (long)cstatfs; 2300 done: 2301 free(cstatfs); 2219 2302 fflush(stdout); 2220 long lp = (long)cstatfs;2221 2303 return lp; 2304 2222 2305 } 2223 2306 2224 2307 void dispstatfs(struct statfs *abc) 2225 2308 { 2226 printf("=======DISPLAY========\n"); 2227 printf("The f_type is: %ld\n", abc->f_type); 2228 printf("The f_bsize is: %ld\n", abc->f_bsize); 2229 printf("The f_blocks is: %lu\n", (long unsigned int) abc->f_blocks); 2230 printf("The f_bfree is: %lu \n", (long unsigned int) abc->f_bfree); 2231 printf("The f_bavail is: %lu \n", (long unsigned int) abc->f_bavail); 2232 printf("The f_files is: %lu \n", (long unsigned int) abc->f_files); 2233 printf("The f_ffree is: %lu \n", (long unsigned int) abc->f_ffree); 2234 //printf("The f_fsid is: %d \n", abc->f_fsid); 2235 printf("The f_namelen is: %ld \n", abc->f_namelen); 2236 printf("The f_frsize is: %ld \n", abc->f_frsize); 2237 printf("The f_flags is: %ld \n", abc->f_flags); 2238 int i; 2239 for(i = 0; i <= 4; i++) 2240 { 2241 printf("F_SPARE %d = %ld\n", i, abc->f_spare[i]); 2242 } 2243 for(i = 0; i <= 1; i++) 2244 { 2245 printf("F_FSID %d = %d\n", i, abc->f_fsid.__val[i]); 2246 } 2247 printf("=======DISPLAY========\n"); 2248 fflush(stdout); 2249 free(abc); 2309 if(JNI_DBG) 2310 { 2311 printf("=======DISPLAY========\n"); 2312 printf("The f_type is: %ld\n", abc->f_type); 2313 printf("The f_bsize is: %ld\n", abc->f_bsize); 2314 printf("The f_blocks is: %lu\n", (long unsigned int) abc->f_blocks); 2315 printf("The f_bfree is: %lu \n", (long unsigned int) abc->f_bfree); 2316 printf("The f_bavail is: %lu \n", (long unsigned int) abc->f_bavail); 2317 printf("The f_files is: %lu \n", (long unsigned int) abc->f_files); 2318 printf("The f_ffree is: %lu \n", (long unsigned int) abc->f_ffree); 2319 /* printf("The f_fsid is: %d \n", abc->f_fsid); */ 2320 printf("The f_namelen is: %ld \n", abc->f_namelen); 2321 printf("The f_frsize is: %ld \n", abc->f_frsize); 2322 printf("The f_flags is: %ld \n", abc->f_flags); 2323 int i; 2324 for(i = 0; i <= 4; i++) 2325 { 2326 printf("F_SPARE %d = %ld\n", i, abc->f_spare[i]); 2327 } 2328 for(i = 0; i <= 1; i++) 2329 { 2330 printf("F_FSID %d = %d\n", i, abc->f_fsid.__val[i]); 2331 } 2332 printf("=======DISPLAY========\n"); 2333 fflush(stdout); 2334 } 2250 2335 } 2251 2336 … … 2253 2338 Java_PVFS2JNI_UseStatfs (JNIEnv *env, jobject obj, jlong jarg) 2254 2339 { 2255 struct statfs xyz;2256 2340 struct statfs *arg; 2257 2341 arg = (struct statfs *)jarg; … … 2262 2346 Java_PVFS2JNI_FillFsid (JNIEnv *env, jobject obj, jobject x) 2263 2347 { 2264 printf("FillFsid\n"); 2265 fflush(stdout); 2348 if(JNI_DBG) printf("FillFsid\n"); 2349 long lp = 0; 2350 fsid_t *cfsid_t = 0; 2266 2351 jfieldID fid1; 2267 2352 jclass cls1 = (*env)->FindClass(env, "PVFS2JNI$Fsid"); … … 2269 2354 if (fid1 == NULL) 2270 2355 { 2271 return; 2272 } 2273 fsid_t *cfsid_t = (fsid_t *)malloc(sizeof(fsid_t)); 2356 lp = -1; 2357 goto done; 2358 } 2359 cfsid_t = (fsid_t *) malloc(sizeof(fsid_t)); 2360 if(!cfsid_t) 2361 { 2362 perror("malloc failed"); 2363 lp = -1; 2364 goto done; 2365 } 2274 2366 jint buf[2]; 2275 2367 jintArray ar; … … 2283 2375 cbuf[ival] = buf[ival]; 2284 2376 } 2285 / /printf("cbuf=%ld",cbuf[4]);2377 /* printf("cbuf=%ld",cbuf[4]); */ 2286 2378 for(jval = 0; jval <= 1; jval++) 2287 2379 { … … 2290 2382 for(jval = 0; jval <= 1; jval++) 2291 2383 { 2292 printf("arr[%d]=%d\n", jval, cfsid_t->__val[jval]); 2293 } 2294 long lp = (long)cfsid_t; 2384 if(JNI_DBG) printf("arr[%d]=%d\n", jval, cfsid_t->__val[jval]); 2385 } 2386 lp = (long)cfsid_t; 2387 done: 2388 if(cfsid_t) 2389 { 2390 free(cfsid_t); 2391 } 2392 fflush(stderr); 2393 if(JNI_DBG) fflush(stdout); 2295 2394 return lp; 2296 2395 } … … 2298 2397 void dispfsid(fsid_t *abc) 2299 2398 { 2300 printf("=======DISPLAY========\n"); 2301 int i; 2302 for(i = 0; i <= 1; i++) 2303 { 2304 printf("Array element %d = %d\n", i, abc->__val[i]); 2305 } 2306 printf("=======DISPLAY========\n"); 2307 fflush(stdout); 2308 } 2399 if(JNI_DBG) 2400 { 2401 printf("=======DISPLAY========\n"); 2402 int i; 2403 for(i = 0; i <= 1; i++) 2404 { 2405 printf("Array element %d = %d\n", i, abc->__val[i]); 2406 } 2407 printf("=======DISPLAY========\n"); 2408 fflush(stdout); 2409 } 2410 } 2411 2309 2412 JNIEXPORT jlong JNICALL 2310 2413 Java_PVFS2JNI_UseFsid (JNIEnv *env, jobject obj, jlong jarg) 2311 2414 { 2312 fsid_t xyz;2313 2415 fsid_t *arg; 2314 2416 arg = (fsid_t *)jarg; … … 2319 2421 Java_PVFS2JNI_FillUtimbuf (JNIEnv *env, jobject obj, jobject x) 2320 2422 { 2321 printf("FillUtimbuf\n"); 2322 fflush(stdout); 2423 if(JNI_DBG) printf("FillUtimbuf\n"); 2424 struct utimbuf *cutimbuf = 0; 2425 long lp = 0; 2323 2426 jfieldID fid1; 2324 2427 jfieldID fid2; … … 2329 2432 if (fid1 == NULL) 2330 2433 { 2331 return; 2434 lp = -1; 2435 goto done; 2332 2436 } 2333 2437 fid2 = (*env)->GetFieldID(env, cls1, "modtime", "J"); 2334 2438 if (fid2 == NULL) 2335 2439 { 2336 return; 2337 } 2338 struct utimbuf *cutimbuf = (struct utimbuf *)malloc(sizeof(struct utimbuf)); 2440 lp = -1; 2441 goto done; 2442 } 2443 cutimbuf = (struct utimbuf *)malloc(sizeof(struct utimbuf)); 2444 if(!cutimbuf) 2445 { 2446 perror("malloc failed"); 2447 lp = -1; 2448 goto done; 2449 } 2339 2450 actime = (*env)->GetLongField(env, x, fid1); 2340 2451 long cactime = (long) actime; … … 2343 2454 long cmodtime = (long) modtime; 2344 2455 cutimbuf->modtime = cmodtime; 2345 printf("ACTIME=:%ld\n", cutimbuf->actime); 2346 printf("MODTIME=:%ld\n", cutimbuf->modtime); 2347 fflush(stdout); 2348 long lp = (long)cutimbuf; 2456 if(JNI_DBG) 2457 { 2458 printf("ACTIME=:%ld\n", cutimbuf->actime); 2459 printf("MODTIME=:%ld\n", cutimbuf->modtime); 2460 } 2461 lp = (long)cutimbuf; 2462 done: 2463 if(cutimbuf) 2464 { 2465 free(cutimbuf); 2466 } 2467 fflush(stderr); 2468 if(JNI_DBG) fflush(stdout); 2349 2469 return lp; 2350 2470 } … … 2352 2472 void disputimbuf(struct utimbuf *abc) 2353 2473 { 2354 printf("=======DISPLAY========\n"); 2355 printf("ACTIME=:%ld\n", abc->actime); 2356 printf("MODTIME=:%ld\n", abc->modtime); 2357 printf("=======DISPLAY========\n"); 2358 fflush(stdout); 2359 free(abc); 2474 if(JNI_DBG) 2475 { 2476 printf("=======DISPLAY========\n"); 2477 printf("ACTIME=:%ld\n", abc->actime); 2478 printf("MODTIME=:%ld\n", abc->modtime); 2479 printf("=======DISPLAY========\n"); 2480 fflush(stdout); 2481 } 2360 2482 } 2361 2483 … … 2363 2485 Java_PVFS2JNI_UseUtimbuf (JNIEnv *env, jobject obj, jlong jarg) 2364 2486 { 2365 struct utimbuf xyz;2366 2487 struct utimbuf *arg; 2367 2488 arg = (struct utimbuf *)jarg; … … 2372 2493 Java_PVFS2JNI_FillTimeval (JNIEnv *env, jobject obj, jobject x) 2373 2494 { 2374 printf("FillTimeval\n"); 2375 fflush(stdout); 2495 if(JNI_DBG) printf("FillTimeval\n"); 2496 struct timeval *ctimeval = NULL; 2497 long lp = 0; 2376 2498 jfieldID fid1; 2377 2499 jfieldID fid2; … … 2382 2504 if (fid1 == NULL) 2383 2505 { 2384 return; 2506 lp = -1; 2507 goto done; 2385 2508 } 2386 2509 fid2 = (*env)->GetFieldID(env, cls1, "tv_usec", "J"); 2387 2510 if (fid2 == NULL) 2388 2511 { 2389 return; 2390 } 2391 struct timeval *ctimeval = (struct timeval *)malloc(sizeof(struct timeval)); 2512 lp = -1; 2513 goto done; 2514 } 2515 ctimeval = (struct timeval *)malloc(sizeof(struct timeval)); 2516 if(!ctimeval) 2517 { 2518 perror("malloc failed"); 2519 lp = -1; 2520 goto done; 2521 } 2392 2522 tv_sec = (*env)->GetLongField(env, x, fid1); 2393 2523 __time_t ctv_sec = (__time_t) tv_sec; … … 2396 2526 __suseconds_t ctv_usec = (__suseconds_t) tv_usec; 2397 2527 ctimeval->tv_usec = ctv_usec; 2398 printf("TV_SEC=:%ld\n", ctimeval->tv_sec); 2399 printf("TV_USEC=:%ld\n", ctimeval->tv_usec); 2400 fflush(stdout); 2401 long lp = (long)ctimeval; 2528 if(JNI_DBG) 2529 { 2530 printf("TV_SEC=:%ld\n", ctimeval->tv_sec); 2531 printf("TV_USEC=:%ld\n", ctimeval->tv_usec); 2532 } 2533 lp = (long) ctimeval; 2534 done: 2535 if(ctimeval) 2536 { 2537 free(ctimeval); 2538 } 2539 fflush(stderr); 2540 if(JNI_DBG) fflush(stdout); 2402 2541 return lp; 2403 2542 } … … 2405 2544 void disptimeval(struct timeval abc[2]) 2406 2545 { 2407 printf("=======DISPLAY========\n"); 2408 printf("++STRUCT 1++\n"); 2409 printf("ACTIME=:%ld\n", abc[0].tv_sec); 2410 printf("MODTIME=:%ld\n", abc[0].tv_usec); 2411 printf("++STRUCT 2++\n"); 2412 printf("ACTIME=:%ld\n", abc[1].tv_sec); 2413 printf("MODTIME=:%ld\n", abc[1].tv_usec); 2414 printf("=======DISPLAY========\n"); 2415 fflush(stdout); 2416 //free(abc); 2546 if(JNI_DBG) 2547 { 2548 printf("=======DISPLAY========\n"); 2549 printf("++STRUCT 1++\n"); 2550 printf("ACTIME=:%ld\n", abc[0].tv_sec); 2551 printf("MODTIME=:%ld\n", abc[0].tv_usec); 2552 printf("++STRUCT 2++\n"); 2553 printf("ACTIME=:%ld\n", abc[1].tv_sec); 2554 printf("MODTIME=:%ld\n", abc[1].tv_usec); 2555 printf("=======DISPLAY========\n"); 2556 fflush(stdout); 2557 } 2417 2558 } 2418 2559 … … 2430 2571 abc[1].tv_usec = arg2->tv_usec; 2431 2572 disptimeval(abc); 2432 /*printf("++STRUCT 1++\n"); 2573 /* 2574 printf("++STRUCT 1++\n"); 2433 2575 printf("ACTIME=:%ld\n", abc[0].tv_sec); 2434 2576 printf("MODTIME=:%ld\n", abc[0].tv_usec); 2435 2577 printf("++STRUCT 2++\n"); 2436 2578 printf("ACTIME=:%ld\n", abc[1].tv_sec); 2437 printf("MODTIME=:%ld\n", abc[1].tv_usec);*/ 2438 } 2439 2440 //pvfs_readdir 2579 printf("MODTIME=:%ld\n", abc[1].tv_usec); 2580 */ 2581 } 2582 2583 /* pvfs_readdir */ 2441 2584 JNIEXPORT jint JNICALL 2442 2585 Java_PVFS2JNI_pvfsReaddir (JNIEnv *env, jobject obj, jlong jarg, int fd, int count) 2443 2586 { 2444 printf("pvfsReaddir\n"); 2587 if(JNI_DBG) printf("pvfsReaddir\n"); 2588 int rc = 0; 2445 2589 struct dirent *arg; 2446 2590 arg = (struct dirent *)jarg; 2447 2591 unsigned int cfd = (unsigned int) fd; 2448 2592 unsigned int ccount = (unsigned int) count; 2449 intrc = pvfs_readdir(cfd, arg, ccount);2593 rc = pvfs_readdir(cfd, arg, ccount); 2450 2594 if(rc < 0) 2451 2595 { 2452 2596 perror("pvfs_readdir error"); 2453 fflush(stdout); 2454 return -1; 2455 } 2456 return rc; 2457 } 2458 2459 2460 //pvfs_getdents 2597 rc = -1; 2598 } 2599 fflush(stderr); 2600 if(JNI_DBG) fflush(stdout); 2601 return rc; 2602 } 2603 2604 2605 /* pvfs_getdents */ 2461 2606 JNIEXPORT jint JNICALL 2462 2607 Java_PVFS2JNI_pvfsGetdents (JNIEnv *env, jobject obj, jlong jarg, int fd, int size) 2463 2608 { 2464 printf("pvfsGetdents\n"); 2609 if(JNI_DBG) printf("pvfsGetdents\n"); 2610 int rc = 0; 2465 2611 struct dirent *arg; 2466 2612 arg = (struct dirent *)jarg; 2467 2613 unsigned int cfd = (unsigned int) fd; 2468 2614 unsigned int csize = (unsigned int) size; 2469 intrc = pvfs_getdents(cfd, arg, csize);2615 rc = pvfs_getdents(cfd, arg, csize); 2470 2616 if(rc < 0) 2471 2617 { 2472 2618 perror("pvfs_getdents error"); 2473 fflush(stdout); 2474 return -1; 2475 } 2476 return rc; 2477 } 2478 2479 //pvfs_getdents64 2619 rc = -1; 2620 } 2621 fflush(stderr); 2622 if(JNI_DBG) fflush(stdout); 2623 return rc; 2624 } 2625 2626 /* pvfs_getdents64 */ 2480 2627 JNIEXPORT jint JNICALL 2481 2628 Java_PVFS2JNI_pvfsGetdents64 (JNIEnv *env, jobject obj, jlong jarg, int fd, int size) 2482 2629 { 2483 printf("pvfsGetdents64\n"); 2630 if(JNI_DBG) printf("pvfsGetdents64\n"); 2631 int rc = 0; 2484 2632 struct dirent64 *arg; 2485 2633 arg = (struct dirent64 *)jarg; 2486 2634 unsigned int cfd = (unsigned int) fd; 2487 2635 unsigned int csize = (unsigned int) size; 2488 intrc = pvfs_getdents64(cfd, arg, csize);2636 rc = pvfs_getdents64(cfd, arg, csize); 2489 2637 if(rc < 0) 2490 2638 { 2491 2639 perror("pvfs_getdents64 error"); 2492 fflush(stdout); 2493 return -1; 2494 } 2495 return rc; 2496 } 2497 2498 //pvfs_futimesat 2640 rc = -1; 2641 } 2642 fflush(stderr); 2643 if(JNI_DBG) fflush(stdout); 2644 return rc; 2645 } 2646 2647 /* pvfs_futimesat */ 2499 2648 JNIEXPORT jint JNICALL 2500 2649 Java_PVFS2JNI_Futimesat (JNIEnv *env, jobject obj, jlong jarg1, jlong jarg2, int dirfd, jstring path) 2501 2650 { 2651 if(JNI_DBG) printf("pvfsFutimesat\n"); 2652 int rc = 0; 2502 2653 struct timeval *arg1; 2503 2654 struct timeval *arg2; … … 2512 2663 int cpath_len = (*env)->GetStringLength(env, path); 2513 2664 (*env)->GetStringUTFRegion(env, path, 0, cpath_len, cpath); 2514 intrc = pvfs_futimesat(dirfd, cpath, abc);2665 rc = pvfs_futimesat(dirfd, cpath, abc); 2515 2666 if(rc < 0) 2516 2667 { 2517 2668 perror("pvfs_futimesat error"); 2518 fflush(stdout); 2519 return -1; 2520 } 2521 return rc; 2522 } 2523 2524 //pvfs_utimes 2669 rc = -1; 2670 } 2671 fflush(stderr); 2672 if(JNI_DBG) fflush(stdout); 2673 return rc; 2674 } 2675 2676 /* pvfs_utimes */ 2525 2677 JNIEXPORT jint JNICALL 2526 2678 Java_PVFS2JNI_Utimes (JNIEnv *env, jobject obj, jlong jarg1, jlong jarg2, jstring path) 2527 2679 { 2680 if(JNI_DBG) printf("pvfs_Utimes\n"); 2681 int rc = 0; 2528 2682 struct timeval *arg1; 2529 2683 struct timeval *arg2; … … 2538 2692 int cpath_len = (*env)->GetStringLength(env, path); 2539 2693 (*env)->GetStringUTFRegion(env, path, 0, cpath_len, cpath); 2540 intrc = pvfs_utimes(cpath, abc);2694 rc = pvfs_utimes(cpath, abc); 2541 2695 if(rc < 0) 2542 2696 { 2543 2697 perror("pvfs_utimes error"); 2544 fflush(stdout); 2545 return -1; 2546 } 2547 return rc; 2548 } 2549 2550 //pvfs_futimes 2698 rc = -1; 2699 } 2700 fflush(stderr); 2701 if(JNI_DBG) fflush(stdout); 2702 return rc; 2703 } 2704 2705 /* pvfs_futimes */ 2551 2706 JNIEXPORT jint JNICALL 2552 2707 Java_PVFS2JNI_Futimes (JNIEnv *env, jobject obj, jlong jarg1, jlong jarg2, int fd) 2553 2708 { 2709 if(JNI_DBG) printf("pvfs_futimes\n"); 2710 int rc = 0; 2554 2711 struct timeval *arg1; 2555 2712 struct timeval *arg2; … … 2561 2718 abc[1].tv_sec = arg2->tv_sec; 2562 2719 abc[1].tv_usec = arg2->tv_usec; 2563 intrc = pvfs_futimes(fd, abc);2720 rc = pvfs_futimes(fd, abc); 2564 2721 if(rc < 0) 2565 2722 { 2566 2723 perror("pvfs_futimes error"); 2567 fflush(stdout);2568 return -1;2569 }2570 return rc;2571 } 2572 2573 2574 / /pvfs_utime2724 rc = -1; 2725 } 2726 fflush(stderr); 2727 if(JNI_DBG) fflush(stdout); 2728 return rc; 2729 } 2730 2731 /* pvfs_utime */ 2575 2732 JNIEXPORT jint JNICALL 2576 2733 Java_PVFS2JNI_pvfsUtime (JNIEnv *env, jobject obj, jlong jarg, jstring path) 2577 2734 { 2578 printf("pvfsUtime\n"); 2735 if(JNI_DBG) printf("pvfsUtime\n"); 2736 int rc = 0; 2579 2737 struct utimbuf *arg; 2580 2738 arg = (struct utimbuf *)jarg; … … 2582 2740 int cpath_len = (*env)->GetStringLength(env, path); 2583 2741 (*env)->GetStringUTFRegion(env, path, 0, cpath_len, cpath); 2584 intrc = pvfs_utime(cpath, arg);2742 rc = pvfs_utime(cpath, arg); 2585 2743 if(rc < 0) 2586 2744 { 2587 2745 perror("pvfs_utime error"); 2588 fflush(stdout); 2589 return -1; 2590 } 2591 return rc; 2592 } 2593 2594 //pvfs_listxattr 2746 rc = -1; 2747 } 2748 fflush(stderr); 2749 if(JNI_DBG) fflush(stdout); 2750 return rc; 2751 } 2752 2753 /* pvfs_listxattr */ 2595 2754 JNIEXPORT jlong JNICALL 2596 2755 Java_PVFS2JNI_pvfsListxattr (JNIEnv *env, jobject obj, jstring path, jstring list, jlong size) 2597 2756 { 2598 printf("pvfsListxattr\n"); 2757 if(JNI_DBG) printf("pvfsListxattr\n"); 2758 long rc = 0; 2599 2759 char cpath[PVFS_PATH_MAX]; 2600 2760 int cpath_len = (*env)->GetStringLength(env, path); … … 2604 2764 (*env)->GetStringUTFRegion(env, list, 0, clist_len, clist); 2605 2765 size_t csize = (size_t) size; 2606 longrc = pvfs_listxattr(cpath, clist, csize);2766 rc = pvfs_listxattr(cpath, clist, csize); 2607 2767 if(rc < 0) 2608 2768 { 2609 2769 perror("pvfs_listxattr error"); 2610 fflush(stdout); 2611 return rc; 2612 } 2613 return rc; 2614 } 2615 2616 //pvfs_llistxattr 2770 rc = -1; 2771 } 2772 fflush(stderr); 2773 if(JNI_DBG) fflush(stdout); 2774 return rc; 2775 } 2776 2777 /* pvfs_llistxattr */ 2617 2778 JNIEXPORT jlong JNICALL 2618 2779 Java_PVFS2JNI_pvfsLlistxattr (JNIEnv *env, jobject obj, jstring path, jstring list, jlong size) 2619 2780 { 2620 printf("pvfsLlistxattr\n"); 2781 if(JNI_DBG) printf("pvfsLlistxattr\n"); 2782 long rc = 0; 2621 2783 char cpath[PVFS_PATH_MAX]; 2622 2784 int cpath_len = (*env)->GetStringLength(env, path); … … 2626 2788 (*env)->GetStringUTFRegion(env, list, 0, clist_len, clist); 2627 2789 size_t csize = (size_t) size; 2628 longrc = pvfs_llistxattr(cpath, clist, csize);2790 rc = pvfs_llistxattr(cpath, clist, csize); 2629 2791 if(rc < 0) 2630 2792 { 2631 2793 perror("pvfs_llistxattr error"); 2632 fflush(stdout); 2633 return rc; 2634 } 2635 return rc; 2636 } 2637 2638 //pvfs_flistxattr 2794 rc = -1; 2795 } 2796 fflush(stderr); 2797 if(JNI_DBG) fflush(stdout); 2798 return rc; 2799 } 2800 2801 /* pvfs_flistxattr */ 2639 2802 JNIEXPORT jlong JNICALL 2640 2803 Java_PVFS2JNI_pvfsFlistxattr (JNIEnv *env, jobject obj, int fd, jstring list, jlong size) 2641 2804 { 2642 printf("pvfsFlistxattr\n"); 2805 if(JNI_DBG) printf("pvfsFlistxattr\n"); 2806 long rc = 0; 2643 2807 char clist[PVFS_MAX_XATTR_LISTLEN]; 2644 2808 int clist_len = (*env)->GetStringLength(env, list); 2645 2809 (*env)->GetStringUTFRegion(env, list, 0, clist_len, clist); 2646 2810 size_t csize = (size_t) size; 2647 longrc = pvfs_flistxattr(fd, clist, csize);2811 rc = pvfs_flistxattr(fd, clist, csize); 2648 2812 if(rc < 0) 2649 2813 { 2650 2814 perror("pvfs_flistxattr error"); 2651 fflush(stdout); 2652 return rc; 2653 } 2654 return rc; 2655 } 2656 2657 //pvfs_removexattr 2815 rc = -1; 2816 } 2817 fflush(stderr); 2818 if(JNI_DBG) fflush(stdout); 2819 return rc; 2820 } 2821 2822 /* pvfs_removexattr */ 2658 2823 JNIEXPORT jint JNICALL 2659 2824 Java_PVFS2JNI_pvfsRemovexattr(JNIEnv *env, jobject obj, jstring path, jstring name) 2660 2825 { 2661 printf("pvfsRemovexattr\n"); 2826 if(JNI_DBG) printf("pvfsRemovexattr\n"); 2827 int rc = 0; 2662 2828 char cpath[PVFS_PATH_MAX]; 2663 2829 int cpath_len = (*env)->GetStringLength(env, path); … … 2666 2832 int cname_len = (*env)->GetStringLength(env, name); 2667 2833 (*env)->GetStringUTFRegion(env, name, 0, cname_len, cname); 2668 intrc = pvfs_removexattr(cpath, cname);2834 rc = pvfs_removexattr(cpath, cname); 2669 2835 if(rc < 0) 2670 2836 { 2671 2837 perror("pvfs_removexattr error"); 2672 fflush(stdout); 2673 return rc; 2674 } 2675 return rc; 2676 } 2677 2678 //pvfs_lremovexattr 2838 rc = -1; 2839 } 2840 fflush(stderr); 2841 if(JNI_DBG) fflush(stderr); 2842 return rc; 2843 } 2844 2845 /* pvfs_lremovexattr */ 2679 2846 JNIEXPORT jint JNICALL 2680 2847 Java_PVFS2JNI_pvfsLremovexattr(JNIEnv *env, jobject obj, jstring path, jstring name) 2681 2848 { 2682 printf("pvfsLremovexattr\n"); 2849 if(JNI_DBG) printf("pvfsLremovexattr\n"); 2850 int rc = 0; 2683 2851 char cpath[PVFS_PATH_MAX]; 2684 2852 int cpath_len = (*env)->GetStringLength(env, path); … … 2687 2855 int cname_len = (*env)->GetStringLength(env, name); 2688 2856 (*env)->GetStringUTFRegion(env, name, 0, cname_len, cname); 2689 intrc = pvfs_lremovexattr(cpath, cname);2857 rc = pvfs_lremovexattr(cpath, cname); 2690 2858 if(rc < 0) 2691 2859 { 2692 2860 perror("pvfs_Lremovexattr error"); 2693 fflush(stdout); 2694 return rc; 2695 } 2696 return rc; 2697 } 2698 2699 //pvfs_fremovexattr 2861 rc = -1; 2862 } 2863 fflush(stderr); 2864 if(JNI_DBG) fflush(stdout); 2865 return rc; 2866 } 2867 2868 /* pvfs_fremovexattr */ 2700 2869 JNIEXPORT jint JNICALL 2701 2870 Java_PVFS2JNI_pvfsFremovexattr(JNIEnv *env, jobject obj, int fd, jstring name) 2702 2871 { 2703 printf("pvfsFremovexattr\n"); 2872 if(JNI_DBG) printf("pvfsFremovexattr\n"); 2873 int rc = 0; 2704 2874 char cname[PVFS_NAME_MAX]; 2705 2875 int cname_len = (*env)->GetStringLength(env, name); 2706 2876 (*env)->GetStringUTFRegion(env, name, 0, cname_len, cname); 2707 intrc = pvfs_fremovexattr(fd, cname);2877 rc = pvfs_fremovexattr(fd, cname); 2708 2878 if(rc < 0) 2709 2879 { 2710 2880 perror("pvfs_fremovexattr error"); 2711 fflush(stdout); 2712 return rc; 2713 } 2714 return rc; 2715 } 2716 2717 //pvfs_getumask 2881 rc = -1; 2882 } 2883 fflush(stderr); 2884 if(JNI_DBG) fflush(stdout); 2885 return rc; 2886 } 2887 2888 /* pvfs_getumask */ 2718 2889 JNIEXPORT jlong JNICALL 2719 2890 Java_PVFS2JNI_pvfsGetumask(JNIEnv *env, jobject obj) 2720 2891 { 2721 printf("pvfsGetumask\n"); 2892 if(JNI_DBG) 2893 { 2894 printf("pvfsGetumask\n"); 2895 fflush(stdout); 2896 } 2722 2897 mode_t rc = pvfs_getumask(); 2723 2898 long ret = (long) rc; … … 2725 2900 } 2726 2901 2727 / /pvfs_getdtablesize2902 /* pvfs_getdtablesize */ 2728 2903 JNIEXPORT jint JNICALL 2729 2904 Java_PVFS2JNI_pvfsGetdtablesize(JNIEnv *env, jobject obj) 2730 2905 { 2731 printf("pvfsGetdtablesize\n"); 2906 if(JNI_DBG) 2907 { 2908 printf("pvfsGetdtablesize\n"); 2909 fflush(stdout); 2910 } 2732 2911 int rc = pvfs_getdtablesize(); 2733 2912 return rc; 2734 2913 } 2735 2914 2736 / /pvfs_sync2915 /* pvfs_sync */ 2737 2916 JNIEXPORT void JNICALL 2738 2917 Java_PVFS2JNI_pvfsSync(JNIEnv *env, jobject obj) 2739 2918 { 2740 printf("pvfsSync\n"); 2919 if(JNI_DBG) 2920 { 2921 printf("pvfsSync\n"); 2922 fflush(stdout); 2923 } 2741 2924 pvfs_sync(); 2742 2925 return; 2743 2926 } 2744 2927 2745 / /FILL STATFS642928 /* FILL STATFS64 */ 2746 2929 JNIEXPORT jlong JNICALL 2747 2930 Java_PVFS2JNI_FillStatfs64 (JNIEnv *env, jobject obj, jobject x, jlong jarg) 2748 2931 { 2749 printf("FillStatfs64\n"); 2750 fflush(stdout); 2932 if(JNI_DBG) printf("FillStatfs64\n"); 2933 long lp = 0; 2934 struct statfs64 *cstatfs64 = 0; 2751 2935 jfieldID fid1; 2752 2936 jfieldID fid2; … … 2776 2960 if (fid1 == NULL) 2777 2961 { 2778 return; 2962 lp = -1; 2963 goto done; 2779 2964 } 2780 2965 fid2 = (*env)->GetFieldID(env, cls1, "f_bsize", "J"); 2781 2966 if (fid2 == NULL) 2782 2967 { 2783 return; 2968 lp = -1; 2969 goto done; 2784 2970 } 2785 2971 fid3 = (*env)->GetFieldID(env, cls1, "f_blocks", "J"); 2786 2972 if (fid3 == NULL) 2787 2973 { 2788 return; 2974 lp = -1; 2975 goto done; 2789 2976 } 2790 2977 fid4 = (*env)->GetFieldID(env, cls1, "f_bfree", "J"); 2791 2978 if (fid4 == NULL) 2792 2979 { 2793 return; 2980 lp = -1; 2981 goto done; 2794 2982 } 2795 2983 fid5 = (*env)->GetFieldID(env, cls1, "f_bavail", "J"); 2796 2984 if (fid5 == NULL) 2797 2985 { 2798 return; 2986 lp = -1; 2987 goto done; 2799 2988 } 2800 2989 fid6 = (*env)->GetFieldID(env, cls1, "f_files", "J"); 2801 2990 if (fid6 == NULL) 2802 2991 { 2803 return; 2992 lp = -1; 2993 goto done; 2804 2994 } 2805 2995 fid7 = (*env)->GetFieldID(env, cls1, "f_ffree", "J"); 2806 2996 if (fid7 == NULL) 2807 2997 { 2808 return; 2998 lp = -1; 2999 goto done; 2809 3000 } 2810 3001 fid9 = (*env)->GetFieldID(env, cls1, "f_namelen", "J"); 2811 3002 if (fid9 == NULL) 2812 3003 { 2813 return; 3004 lp = -1; 3005 goto done; 2814 3006 } 2815 3007 fid10 = (*env)->GetFieldID(env, cls1, "f_frsize", "J"); 2816 3008 if (fid10 == NULL) 2817 3009 { 2818 return; 3010 lp = -1; 3011 goto done; 2819 3012 } 2820 3013 fid11 = (*env)->GetFieldID(env, cls1, "f_spare", "[J"); 2821 3014 if (fid11 == NULL) 2822 3015 { 2823 return; 3016 lp = -1; 3017 goto done; 2824 3018 } 2825 3019 fid12 = (*env)->GetFieldID(env, cls1, "f_flags", "J"); 2826 3020 if (fid12 == NULL) 2827 3021 { 2828 return; 2829 } 2830 /* __SWORD_TYPE* tmp; 3022 lp = -1; 3023 goto done; 3024 } 3025 /* 3026 __SWORD_TYPE* tmp; 2831 3027 tmp = (__SWORD_TYPE *) malloc( 5 * sizeof(__SWORD_TYPE) ); 2832 3028 tmp[0]=10; 2833 3029 tmp[1]=20; 2834 printf("tmp=%ld\n",tmp[0]);*/ 2835 struct statfs64 *cstatfs64 = (struct statfs64 *) malloc( 2836 sizeof(struct statfs64) + 1); 2837 //long int *(cstatfs->f_spare[0]) = tmp[0]; 2838 /*long int i= 10; 3030 printf("tmp=%ld\n",tmp[0]); 3031 */ 3032 cstatfs64 = (struct statfs64 *) malloc(sizeof(struct statfs64) + 1); 3033 if(!cstatfs64) 3034 { 3035 perror("malloc failed"); 3036 lp = -1; 3037 goto done; 3038 } 3039 /* 3040 long int *(cstatfs->f_spare[0]) = tmp[0]; 3041 long int i= 10; 2839 3042 cstatfs->f_spare[4]=10; 2840 3043 printf("f_spare[4]=%d\n",cstatfs->f_spare[4]); … … 2870 3073 __SWORD_TYPE cf_flags = (__SWORD_TYPE) f_flags; 2871 3074 cstatfs64->f_flags = cf_flags; 2872 //buf=(*env)->GetLongArrayElements(env,x,fid11); 2873 //printf("ARRAY:%ld",buf[0]; 3075 /* 3076 buf=(*env)->GetLongArrayElements(env,x,fid11); 3077 printf("ARRAY:%ld",buf[0]; 3078 */ 2874 3079 jlong buf[5]; 2875 3080 jlongArray ar; … … 2883 3088 cbuf[ival] = buf[ival]; 2884 3089 } 2885 / /printf("cbuf=%ld",cbuf[4]);3090 /*i printf("cbuf=%ld",cbuf[4]); */ 2886 3091 for(jval = 0; jval <= 4; jval++) 2887 3092 { 2888 3093 cstatfs64->f_spare[jval] = cbuf[jval]; 2889 3094 } 2890 / /cstatfs->f_spare[4] = 10;3095 /* cstatfs->f_spare[4] = 10; */ 2891 3096 fsid_t *arg; 2892 3097 arg = (fsid_t *)jarg; 2893 3098 cstatfs64->f_fsid.__val[0] = arg->__val[0]; 2894 3099 cstatfs64->f_fsid.__val[1] = arg->__val[1]; 2895 //printf("cstatfs.fsid1=%d\n",cstatfs->f_fsid.__val[0]); 2896 //printf("cstatfs.fsid2=%d\n",cstatfs->f_fsid.__val[1]); 2897 fflush(stdout); 2898 long lp = (long)cstatfs64; 3100 /* 3101 printf("cstatfs.fsid1=%d\n",cstatfs->f_fsid.__val[0]); 3102 printf("cstatfs.fsid2=%d\n",cstatfs->f_fsid.__val[1]); 3103 */ 3104 lp = (long)cstatfs64; 3105 done: 3106 if(cstatfs64) 3107 { 3108 free(cstatfs64); 3109 } 3110 fflush(stderr); 3111 if(JNI_DBG) fflush(stdout); 2899 3112 return lp; 2900 3113 } 2901 3114 2902 / /DISPSTATFS643115 /* DISPSTATFS64 */ 2903 3116 void dispstatfs64(struct statfs64 *abc) 2904 3117 { 2905 printf("=======DISPLAY========\n"); 2906 printf("The f_type is: %ld\n", (long int) abc->f_type); 2907 printf("The f_bsize is: %ld\n", (long int) abc->f_bsize); 2908 printf("The f_blocks is: %lu\n", abc->f_blocks); 2909 printf("The f_bfree is: %lu\n", abc->f_bfree); 2910 printf("The f_bavail is: %lu\n", abc->f_bavail); 2911 printf("The f_files is: %lu\n", abc->f_files); 2912 printf("The f_ffree is: %lu\n", abc->f_ffree); 2913 //printf("The f_fsid is: %lu\n", abc->f_fsid); 2914 printf("The f_namelen is: %lu\n", abc->f_namelen); 2915 printf("The f_frsize is: %lu\n", abc->f_frsize); 2916 printf("The f_flags is: %ld \n", abc->f_flags); 2917 int i; 2918 for(i = 0; i <= 4; i++) 2919 { 2920 printf("F_SPARE %d = %ld\n", i, abc->f_spare[i]); 2921 } 2922 for(i = 0; i <= 1; i++) 2923 { 2924 printf("F_FSID %d = %d\n", i, abc->f_fsid.__val[i]); 2925 } 2926 printf("=======DISPLAY========\n"); 2927 fflush(stdout); 2928 free(abc); 2929 } 2930 2931 //UseStatfs64 3118 if(JNI_DBG) 3119 { 3120 printf("=======DISPLAY========\n"); 3121 printf("The f_type is: %ld\n", (long int) abc->f_type); 3122 printf("The f_bsize is: %ld\n", (long int) abc->f_bsize); 3123 printf("The f_blocks is: %lu\n", abc->f_blocks); 3124 printf("The f_bfree is: %lu\n", abc->f_bfree); 3125 printf("The f_bavail is: %lu\n", abc->f_bavail); 3126 printf("The f_files is: %lu\n", abc->f_files); 3127 printf("The f_ffree is: %lu\n", abc->f_ffree); 3128 /* printf("The f_fsid is: %lu\n", abc->f_fsid); */ 3129 printf("The f_namelen is: %lu\n", abc->f_namelen); 3130 printf("The f_frsize is: %lu\n", abc->f_frsize); 3131 printf("The f_flags is: %ld \n", abc->f_flags); 3132 int i; 3133 for(i = 0; i <= 4; i++) 3134 { 3135 printf("F_SPARE %d = %ld\n", i, abc->f_spare[i]); 3136 } 3137 for(i = 0; i <= 1; i++) 3138 { 3139 printf("F_FSID %d = %d\n", i, abc->f_fsid.__val[i]); 3140 } 3141 printf("=======DISPLAY========\n"); 3142 fflush(stdout); 3143 } 3144 } 3145 3146 /* UseStatfs64 */ 2932 3147 JNIEXPORT jlong JNICALL 2933 3148 Java_PVFS2JNI_UseStatfs64 (JNIEnv *env, jobject obj, jlong jarg) 2934 3149 { 2935 struct statfs64 xyz;2936 3150 struct statfs64 *arg; 2937 3151 arg = (struct statfs64 *)jarg; … … 2939 3153 } 2940 3154 2941 / /FILL STATVFS3155 /* FILL STATVFS */ 2942 3156 JNIEXPORT jlong JNICALL 2943 3157 Java_PVFS2JNI_FillStatvfs (JNIEnv *env, jobject obj, jobject x) 2944 3158 { 2945 printf("FillStatvfs\n"); 2946 fflush(stdout); 3159 if(JNI_DBG) printf("FillStatvfs\n"); 3160 long lp = 0; 3161 struct statvfs *cstatvfs = 0; 2947 3162 jfieldID fid2; 2948 3163 jfieldID fid3; … … 2971 3186 if (fid2 == NULL) 2972 3187 { 2973 return; 3188 lp = -1; 3189 goto done; 2974 3190 } 2975 3191 fid3 = (*env)->GetFieldID(env, cls1, "f_blocks", "J"); 2976 3192 if (fid3 == NULL) 2977 3193 { 2978 return; 3194 lp = -1; 3195 goto done; 2979 3196 } 2980 3197 fid4 = (*env)->GetFieldID(env, cls1, "f_bfree", "J"); 2981 3198 if (fid4 == NULL) 2982 3199 { 2983 return; 3200 lp = -1; 3201 goto done; 2984 3202 } 2985 3203 fid5 = (*env)->GetFieldID(env, cls1, "f_bavail", "J"); 2986 3204 if (fid5 == NULL) 2987 3205 { 2988 return; 3206 lp = -1; 3207 goto done; 2989 3208 } 2990 3209 fid6 = (*env)->GetFieldID(env, cls1, "f_files", "J"); 2991 3210 if (fid6 == NULL) 2992 3211 { 2993 return; 3212 lp = -1; 3213 goto done; 2994 3214 } 2995 3215 fid7 = (*env)->GetFieldID(env, cls1, "f_ffree", "J"); 2996 3216 if (fid7 == NULL) 2997 3217 { 2998 return; 3218 lp = -1; 3219 goto done; 2999 3220 } 3000 3221 fid9 = (*env)->GetFieldID(env, cls1, "f_namemax", "J"); 3001 3222 if (fid9 == NULL) 3002 3223 { 3003 return; 3224 lp = -1; 3225 goto done; 3004 3226 } 3005 3227 fid10 = (*env)->GetFieldID(env, cls1, "f_frsize", "J"); 3006 3228 if (fid10 == NULL) 3007 3229 { 3008 return; 3230 lp = -1; 3231 goto done; 3009 3232 } 3010 3233 fid12 = (*env)->GetFieldID(env, cls1, "f_flag", "J"); 3011 3234 if (fid12 == NULL) 3012 3235 { 3013 return; 3236 lp = -1; 3237 goto done; 3014 3238 } 3015 3239 fid13 = (*env)->GetFieldID(env, cls1, "f_favail", "J"); 3016 3240 if (fid13 == NULL) 3017 3241 { 3018 return; 3242 lp = -1; 3243 goto done; 3019 3244 } 3020 3245 fid14 = (*env)->GetFieldID(env, cls1, "f_fsid", "J"); 3021 3246 if (fid14 == NULL) 3022 3247 { 3023 return; 3024 } 3025 /* __SWORD_TYPE* tmp; 3248 lp = -1; 3249 goto done; 3250 } 3251 /* 3252 __SWORD_TYPE* tmp; 3026 3253 tmp = (__SWORD_TYPE *) malloc( 5 * sizeof(__SWORD_TYPE) ); 3027 3254 tmp[0]=10; 3028 3255 tmp[1]=20; 3029 printf("tmp=%ld\n",tmp[0]);*/ 3030 struct statvfs *cstatvfs = (struct statvfs *)malloc(sizeof(struct statvfs)); 3031 //long int *(cstatfs->f_spare[0]) = tmp[0]; 3032 /*long int i= 10; 3256 printf("tmp=%ld\n",tmp[0]); 3257 */ 3258 cstatvfs = (struct statvfs *)malloc(sizeof(struct statvfs)); 3259 if(!cstatvfs) 3260 { 3261 perror("malloc failed"); 3262 lp = -1; 3263 goto done; 3264 } 3265 /* 3266 long int i= 10; 3267 long int *(cstatfs->f_spare[0]) = tmp[0]; 3033 3268 cstatfs->f_spare[4]=10; 3034 3269 printf("f_spare[4]=%d\n",cstatfs->f_spare[4]); … … 3067 3302 unsigned long cf_fsid = (unsigned long) f_fsid; 3068 3303 cstatvfs->f_fsid = cf_fsid; 3069 fflush(stdout); 3070 long lp = (long)cstatvfs; 3304 lp = (long)cstatvfs; 3305 done: 3306 if(cstatvfs) 3307 { 3308 free(cstatvfs); 3309 } 3310 fflush(stderr); 3311 if(JNI_DBG) fflush(stdout); 3071 3312 return lp; 3072 3313 } … … 3074 3315 void dispstatvfs(struct statvfs *abc) 3075 3316 { 3076 printf("=======DISPLAY========\n"); 3077 printf("The f_bsize is: %lu\n", abc->f_bsize); 3078 printf("The f_blocks is: %lu\n", abc->f_blocks); 3079 printf("The f_bfree is: %lu\n", abc->f_bfree); 3080 printf("The f_bavail is: %lu\n", abc->f_bavail); 3081 printf("The f_files is: %lu\n", abc->f_files); 3082 printf("The f_ffree is: %lu\n", abc->f_ffree); 3083 printf("The f_fsid is: %lu\n", abc->f_fsid); 3084 printf("The f_namemax is: %lu\n", abc->f_namemax); 3085 printf("The f_frsize is: %lu\n", abc->f_frsize); 3086 printf("The f_flag is: %lu\n", abc->f_flag); 3087 printf("The f_favail is: %lu\n", abc->f_favail); 3088 printf("=======DISPLAY========\n"); 3089 fflush(stdout); 3090 free(abc); 3317 if(JNI_DBG) 3318 { 3319 printf("=======DISPLAY========\n"); 3320 printf("The f_bsize is: %lu\n", abc->f_bsize); 3321 printf("The f_blocks is: %lu\n", abc->f_blocks); 3322 printf("The f_bfree is: %lu\n", abc->f_bfree); 3323 printf("The f_bavail is: %lu\n", abc->f_bavail); 3324 printf("The f_files is: %lu\n", abc->f_files); 3325 printf("The f_ffree is: %lu\n", abc->f_ffree); 3326 printf("The f_fsid is: %lu\n", abc->f_fsid); 3327 printf("The f_namemax is: %lu\n", abc->f_namemax); 3328 printf("The f_frsize is: %lu\n", abc->f_frsize); 3329 printf("The f_flag is: %lu\n", abc->f_flag); 3330 printf("The f_favail is: %lu\n", abc->f_favail); 3331 printf("=======DISPLAY========\n"); 3332 fflush(stdout); 3333 } 3091 3334 } 3092 3335 … … 3099 3342 } 3100 3343 3101 / /pvfs_statfs3344 /* pvfs_statfs */ 3102 3345 JNIEXPORT jint JNICALL 3103 3346 Java_PVFS2JNI_pvfsStatfs (JNIEnv *env, jobject obj, jlong jarg, jstring path) 3104 3347 { 3105 printf("pvfsStatfs\n"); 3348 if(JNI_DBG) printf("pvfsStatfs\n"); 3349 int rc = 0; 3106 3350 struct statfs *arg; 3107 3351 arg = (struct statfs *)jarg; … … 3109 3353 int cpath_len = (*env)->GetStringLength(env, path); 3110 3354 (*env)->GetStringUTFRegion(env, path, 0, cpath_len, cpath); 3111 intrc = pvfs_statfs(cpath, arg);3355 rc = pvfs_statfs(cpath, arg); 3112 3356 if(rc < 0) 3113 3357 { 3114 3358 perror("pvfs_statfs error"); 3115 fflush(stdout); 3116 return -1; 3117 } 3118 return rc; 3119 } 3120 3121 //pvfs_fstatfs 3359 rc = -1; 3360 } 3361 fflush(stderr); 3362 if(JNI_DBG) fflush(stdout); 3363 return rc; 3364 } 3365 3366 /* pvfs_fstatfs */ 3122 3367 JNIEXPORT jint JNICALL 3123 3368 Java_PVFS2JNI_pvfsFstatfs(JNIEnv *env, jobject obj, jlong jarg, int fd) 3124 3369 { 3125 printf("pvfsFstatfs\n"); 3370 if(JNI_DBG) printf("pvfsFstatfs\n"); 3371 int rc = 0; 3126 3372 struct statfs *arg; 3127 3373 arg = (struct statfs *)jarg; 3128 intrc = pvfs_fstatfs(fd, arg);3374 rc = pvfs_fstatfs(fd, arg); 3129 3375 if(rc < 0) 3130 3376 { 3131 3377 perror("pvfs_fstatfs error"); 3132 fflush(stdout); 3133 return -1; 3134 } 3135 return rc; 3136 } 3137 3138 //pvfs_statfs64 3378 rc = -1; 3379 } 3380 fflush(stderr); 3381 if(JNI_DBG) fflush(stdout); 3382 return rc; 3383 } 3384 3385 /* pvfs_statfs64 */ 3139 3386 JNIEXPORT jint JNICALL 3140 3387 Java_PVFS2JNI_pvfsStatfs64 (JNIEnv *env, jobject obj, jlong jarg, jstring path) 3141 3388 { 3142 printf("pvfsStatfs64\n"); 3389 if(JNI_DBG) printf("pvfsStatfs64\n"); 3390 int rc = 0; 3143 3391 struct statfs64 *arg; 3144 3392 arg = (struct statfs64 *)jarg; … … 3146 3394 int cpath_len = (*env)->GetStringLength(env, path); 3147 3395 (*env)->GetStringUTFRegion(env, path, 0, cpath_len, cpath); 3148 intrc = pvfs_statfs64(cpath, arg);3396 rc = pvfs_statfs64(cpath, arg); 3149 3397 if(rc < 0) 3150 3398 { 3151 3399 perror("pvfs_statfs64 error"); 3152 fflush(stdout); 3153 return -1; 3154 } 3155 return rc; 3156 } 3157 3158 //pvfs_fstatfs64 3400 rc = -1; 3401 } 3402 fflush(stderr); 3403 if(JNI_DBG) fflush(stdout); 3404 return rc; 3405 } 3406 3407 /* pvfs_fstatfs64 */ 3159 3408 JNIEXPORT jint JNICALL 3160 3409 Java_PVFS2JNI_pvfsFstatfs64(JNIEnv *env, jobject obj, jlong jarg, int fd) 3161 3410 { 3162 printf("pvfsFstatfs64\n"); 3411 if(JNI_DBG) printf("pvfsFstatfs64\n"); 3412 int rc = 0; 3163 3413 struct statfs64 *arg; 3164 3414 arg = (struct statfs64 *)jarg; 3165 intrc = pvfs_fstatfs64(fd, arg);3415 rc = pvfs_fstatfs64(fd, arg); 3166 3416 if(rc < 0) 3167 3417 { 3168 3418 perror("pvfs_fstatfs64 error"); 3169 fflush(stdout); 3170 return -1; 3171 } 3172 return rc; 3173 } 3174 3175 //pvfs_statvfs 3419 rc = -1; 3420 } 3421 fflush(stderr); 3422 if(JNI_DBG) fflush(stdout); 3423 return rc; 3424 } 3425 3426 /* pvfs_statvfs */ 3176 3427 JNIEXPORT jint JNICALL 3177 3428 Java_PVFS2JNI_pvfsStatvfs (JNIEnv *env, jobject obj, jlong jarg, jstring path) 3178 3429 { 3179 printf("pvfsStatvfs\n"); 3430 if(JNI_DBG) printf("pvfsStatvfs\n"); 3431 int rc = 0; 3180 3432 struct statvfs *arg; 3181 3433 arg = (struct statvfs *)jarg; … … 3183 3435 int cpath_len = (*env)->GetStringLength(env, path); 3184 3436 (*env)->GetStringUTFRegion(env, path, 0, cpath_len, cpath); 3185 intrc = pvfs_statvfs(cpath, arg);3437 rc = pvfs_statvfs(cpath, arg); 3186 3438 if(rc < 0) 3187 3439 { 3188 3440 perror("pvfs_statvfs error"); 3189 fflush(stdout); 3190 return -1; 3191 } 3192 return rc; 3193 } 3194 3195 //pvfs_fstatvfs 3441 rc = -1; 3442 } 3443 fflush(stderr); 3444 if(JNI_DBG) fflush(stdout); 3445 return rc; 3446 } 3447 3448 /* pvfs_fstatvfs */ 3196 3449 JNIEXPORT jint JNICALL 3197 3450 Java_PVFS2JNI_pvfsFstatvfs(JNIEnv *env, jobject obj, jlong jarg, int fd) 3198 3451 { 3199 printf("pvfsFstatvfs\n"); 3452 if(JNI_DBG) printf("pvfsFstatvfs\n"); 3453 int rc = 0; 3200 3454 struct statvfs *arg; 3201 3455 arg = (struct statvfs *)jarg; 3202 intrc = pvfs_fstatvfs(fd, arg);3456 rc = pvfs_fstatvfs(fd, arg); 3203 3457 if(rc < 0) 3204 3458 { 3205 3459 perror("pvfs_fstatvfs error"); 3206 fflush(stdout); 3207 return -1; 3208 } 3209 return rc; 3210 } 3460 rc = -1; 3461 } 3462 fflush(stderr); 3463 if(JNI_DBG) fflush(stdout); 3464 return rc; 3465 }
