1 /*
2 * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2012, 2018 SAP SE. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
668
669 // don't follow symbolic links for the file
670 RESTARTABLE(::lstat(filename, &statbuf), result);
671 if (result == OS_ERR) {
672 FREE_C_HEAP_ARRAY(char, filename);
673 continue;
674 }
675
676 // skip over files that are not regular files.
677 if (!S_ISREG(statbuf.st_mode)) {
678 FREE_C_HEAP_ARRAY(char, filename);
679 continue;
680 }
681
682 // compare and save filename with latest creation time
683 if (statbuf.st_size > 0 && statbuf.st_ctime > oldest_ctime) {
684
685 if (statbuf.st_ctime > oldest_ctime) {
686 char* user = strchr(dentry->d_name, '_') + 1;
687
688 if (oldest_user != NULL) FREE_C_HEAP_ARRAY(char, oldest_user);
689 oldest_user = NEW_C_HEAP_ARRAY(char, strlen(user)+1, mtInternal);
690
691 strcpy(oldest_user, user);
692 oldest_ctime = statbuf.st_ctime;
693 }
694 }
695
696 FREE_C_HEAP_ARRAY(char, filename);
697 }
698 }
699 os::closedir(subdirp);
700 FREE_C_HEAP_ARRAY(char, usrdir_name);
701 }
702 os::closedir(tmpdirp);
703
704 return(oldest_user);
705 }
706
707 // return the name of the user that owns the JVM indicated by the given vmid.
708 //
|
1 /*
2 * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2012, 2018 SAP SE. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
668
669 // don't follow symbolic links for the file
670 RESTARTABLE(::lstat(filename, &statbuf), result);
671 if (result == OS_ERR) {
672 FREE_C_HEAP_ARRAY(char, filename);
673 continue;
674 }
675
676 // skip over files that are not regular files.
677 if (!S_ISREG(statbuf.st_mode)) {
678 FREE_C_HEAP_ARRAY(char, filename);
679 continue;
680 }
681
682 // compare and save filename with latest creation time
683 if (statbuf.st_size > 0 && statbuf.st_ctime > oldest_ctime) {
684
685 if (statbuf.st_ctime > oldest_ctime) {
686 char* user = strchr(dentry->d_name, '_') + 1;
687
688 FREE_C_HEAP_ARRAY(char, oldest_user);
689 oldest_user = NEW_C_HEAP_ARRAY(char, strlen(user)+1, mtInternal);
690
691 strcpy(oldest_user, user);
692 oldest_ctime = statbuf.st_ctime;
693 }
694 }
695
696 FREE_C_HEAP_ARRAY(char, filename);
697 }
698 }
699 os::closedir(subdirp);
700 FREE_C_HEAP_ARRAY(char, usrdir_name);
701 }
702 os::closedir(tmpdirp);
703
704 return(oldest_user);
705 }
706
707 // return the name of the user that owns the JVM indicated by the given vmid.
708 //
|