8341666: FileInputStream doesn't support readAllBytes() or readNBytes(int) on pseudo devices

Reviewed-by: alanb
This commit is contained in:
Brian Burkhalter 2024-10-28 16:38:36 +00:00
parent 52382e285f
commit 1341b81321
7 changed files with 267 additions and 5 deletions

View file

@ -264,3 +264,13 @@ handleGetLength(FD fd)
#endif
return sb.st_size;
}
jboolean
handleIsRegularFile(JNIEnv* env, FD fd)
{
struct stat fbuf;
if (fstat(fd, &fbuf) == -1)
JNU_ThrowIOExceptionWithLastError(env, "fstat failed");
return S_ISREG(fbuf.st_mode) ? JNI_TRUE : JNI_FALSE;
}

View file

@ -41,6 +41,7 @@ jint handleAvailable(FD fd, jlong *pbytes);
jint handleSetLength(FD fd, jlong length);
jlong handleGetLength(FD fd);
FD handleOpen(const char *path, int oflag, int mode);
jboolean handleIsRegularFile(JNIEnv* env, FD fd);
/*
* Functions to get fd from the java.io.FileDescriptor field
@ -66,6 +67,7 @@ FD getFD(JNIEnv *env, jobject cur, jfieldID fid);
#define IO_Available handleAvailable
#define IO_SetLength handleSetLength
#define IO_GetLength handleGetLength
#define IO_IsRegularFile handleIsRegularFile
/*
* On Solaris, the handle field is unused