src/java.base/linux/native/libnio/fs/LinuxNativeDispatcher.c
changeset 58397 2d40e6a7ce8e
parent 47216 71c04702a3d5
equal deleted inserted replaced
58394:b1c3d24553e0 58397:2d40e6a7ce8e
     1 /*
     1 /*
     2  * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   167     }
   167     }
   168     return ptr_to_jlong(fp);
   168     return ptr_to_jlong(fp);
   169 }
   169 }
   170 
   170 
   171 JNIEXPORT jint JNICALL
   171 JNIEXPORT jint JNICALL
   172 Java_sun_nio_fs_LinuxNativeDispatcher_getmntent(JNIEnv* env, jclass this,
   172 Java_sun_nio_fs_LinuxNativeDispatcher_getmntent0(JNIEnv* env, jclass this,
   173     jlong value, jobject entry)
   173     jlong value, jobject entry, jlong buffer, jint bufLen)
   174 {
   174 {
   175     struct mntent ent;
   175     struct mntent ent;
   176     char buf[1024];
   176     char * buf = (char*)jlong_to_ptr(buffer);
   177     int buflen = sizeof(buf);
       
   178     struct mntent* m;
   177     struct mntent* m;
   179     FILE* fp = jlong_to_ptr(value);
   178     FILE* fp = jlong_to_ptr(value);
   180     jsize len;
   179     jsize len;
   181     jbyteArray bytes;
   180     jbyteArray bytes;
   182     char* name;
   181     char* name;
   183     char* dir;
   182     char* dir;
   184     char* fstype;
   183     char* fstype;
   185     char* options;
   184     char* options;
   186 
   185 
   187     m = getmntent_r(fp, &ent, (char*)&buf, buflen);
   186     m = getmntent_r(fp, &ent, buf, (int)bufLen);
   188     if (m == NULL)
   187     if (m == NULL)
   189         return -1;
   188         return -1;
   190     name = m->mnt_fsname;
   189     name = m->mnt_fsname;
   191     dir = m->mnt_dir;
   190     dir = m->mnt_dir;
   192     fstype = m->mnt_type;
   191     fstype = m->mnt_type;