1 /*
2 * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
574
575 // don't follow symbolic links for the file
576 RESTARTABLE(::lstat(filename, &statbuf), result);
577 if (result == OS_ERR) {
578 FREE_C_HEAP_ARRAY(char, filename);
579 continue;
580 }
581
582 // skip over files that are not regular files.
583 if (!S_ISREG(statbuf.st_mode)) {
584 FREE_C_HEAP_ARRAY(char, filename);
585 continue;
586 }
587
588 // compare and save filename with latest creation time
589 if (statbuf.st_size > 0 && statbuf.st_ctime > oldest_ctime) {
590
591 if (statbuf.st_ctime > oldest_ctime) {
592 char* user = strchr(dentry->d_name, '_') + 1;
593
594 if (oldest_user != NULL) FREE_C_HEAP_ARRAY(char, oldest_user);
595 oldest_user = NEW_C_HEAP_ARRAY(char, strlen(user)+1, mtInternal);
596
597 strcpy(oldest_user, user);
598 oldest_ctime = statbuf.st_ctime;
599 }
600 }
601
602 FREE_C_HEAP_ARRAY(char, filename);
603 }
604 }
605 os::closedir(subdirp);
606 FREE_C_HEAP_ARRAY(char, usrdir_name);
607 }
608 os::closedir(tmpdirp);
609
610 return(oldest_user);
611 }
612
613 // return the name of the user that owns the JVM indicated by the given vmid.
614 //
|
1 /*
2 * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
574
575 // don't follow symbolic links for the file
576 RESTARTABLE(::lstat(filename, &statbuf), result);
577 if (result == OS_ERR) {
578 FREE_C_HEAP_ARRAY(char, filename);
579 continue;
580 }
581
582 // skip over files that are not regular files.
583 if (!S_ISREG(statbuf.st_mode)) {
584 FREE_C_HEAP_ARRAY(char, filename);
585 continue;
586 }
587
588 // compare and save filename with latest creation time
589 if (statbuf.st_size > 0 && statbuf.st_ctime > oldest_ctime) {
590
591 if (statbuf.st_ctime > oldest_ctime) {
592 char* user = strchr(dentry->d_name, '_') + 1;
593
594 FREE_C_HEAP_ARRAY(char, oldest_user);
595 oldest_user = NEW_C_HEAP_ARRAY(char, strlen(user)+1, mtInternal);
596
597 strcpy(oldest_user, user);
598 oldest_ctime = statbuf.st_ctime;
599 }
600 }
601
602 FREE_C_HEAP_ARRAY(char, filename);
603 }
604 }
605 os::closedir(subdirp);
606 FREE_C_HEAP_ARRAY(char, usrdir_name);
607 }
608 os::closedir(tmpdirp);
609
610 return(oldest_user);
611 }
612
613 // return the name of the user that owns the JVM indicated by the given vmid.
614 //
|