J
Jerry Orr
I'm writing a simple JNI C++ function on a z/OS 1.4 system. I am
attempting to rename a dataset; however, when I use the rename()
function, I get a return code of -1. All of the return codes listed in
the "C/C++ Runtime Library Reference" (EACCES, EINVAL, etc) are
positive integers, and all of them can be successfully input into
strerror() to get a valid error message. Passing -1 to strerror(),
though, just returns a null string.
Has anyone experienced anything similar to this? I'm not sure why I'd
be getting -1 as a return code, and I've been unable to find anything
about it in the manuals or on the web.
Here's an example of my method:
/* This is the signature for a JNI method */
JNIEXPORT jint JNICALL
Java_DatasetUtilities_nativeRenameDataset
(JNIEnv *env, jclass obj, jstring jfrom, jstring jto)
{
int rc;
/* This is JNI code to convert the ASCII Java strings into EBCDIC */
const char *from = (*env)->GetStringUTFChars(env, jfrom, 0);
const char *to = (*env)->GetStringUTFChars(env, jto, 0);
__atoe(from);
__atoe(to);
/* Here, rename() is returning -1 */
rc = rename(from, to);
/* This is just printing out -1 and an empty string */
printf("rename() error (error code: %i, error message: %s)\n",
rc, strerror(rc));
/* More JNI code */
(*env)->ReleaseStringUTFChars(env, jfrom, from);
(*env)->ReleaseStringUTFChars(env, jto, to);
return rc;
}
attempting to rename a dataset; however, when I use the rename()
function, I get a return code of -1. All of the return codes listed in
the "C/C++ Runtime Library Reference" (EACCES, EINVAL, etc) are
positive integers, and all of them can be successfully input into
strerror() to get a valid error message. Passing -1 to strerror(),
though, just returns a null string.
Has anyone experienced anything similar to this? I'm not sure why I'd
be getting -1 as a return code, and I've been unable to find anything
about it in the manuals or on the web.
Here's an example of my method:
/* This is the signature for a JNI method */
JNIEXPORT jint JNICALL
Java_DatasetUtilities_nativeRenameDataset
(JNIEnv *env, jclass obj, jstring jfrom, jstring jto)
{
int rc;
/* This is JNI code to convert the ASCII Java strings into EBCDIC */
const char *from = (*env)->GetStringUTFChars(env, jfrom, 0);
const char *to = (*env)->GetStringUTFChars(env, jto, 0);
__atoe(from);
__atoe(to);
/* Here, rename() is returning -1 */
rc = rename(from, to);
/* This is just printing out -1 and an empty string */
printf("rename() error (error code: %i, error message: %s)\n",
rc, strerror(rc));
/* More JNI code */
(*env)->ReleaseStringUTFChars(env, jfrom, from);
(*env)->ReleaseStringUTFChars(env, jto, to);
return rc;
}