# $Header: usm/src/cmds/acfslib/aix/osds_acfslib.pm /st_usm_11.2/6 2011/07/20 18:54:10 certan Exp $ # # Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. # # # NAME # osds_acfslib.pm - AIX OSD library components. # # DESCRIPTION # Purpose # AIX OSD library functions for the install/runtime scripts. # # NOTES # All user visible output should be done in the common code. # this will ensure a consistent look and feel across all platforms. # # MODIFIED (MM/DD/YY) # certan 07/20/11 - Backport certan_acfsroot_odmdir_check from main # gsanders 06/30/11 - Backport gsanders_bug-12692110 from main # plancian 05/03/11 - 12377780 use # osds_unix_linux_acfslib::get_dev_mntpt_from_mount_line # rwerme 05/02/11 - Change lib_osds_get_os_type to report V7x for any # AIX V7 release. # rwerme 04/20/11 - XbranchMerge rwerme_aix71-110413 from main # rwerme 04/18/11 - Allow us to run on AIX 7.1, all TLs. # gsanders 04/06/11 - Backport gsanders_bug_11839415-main from main # gsanders 04/04/11 - Move lib_osds_is_mounted to this library. # mcarrell 11/01/10 - Change lib_osds_check_driver_loaded to work in # non-English environments. # certan 08/31/10 - Call slibclean in lib_osds_load_driver() # certan 08/20/10 - Throw away standard output from 'define' driver # methods # jinjche 07/06/10 - Fix a bug that ora.drivers.acfs resource does not # start after being stopped by rewriting lib_osds_check_driver_loaded # certan 06/14/10 - Modify lib_osds_check_driver_loaded to no longer # use genkex to determine driver load state # gsanders 05/05/10 - Print 9459 error msg from lib_osds_get_os_type() # certan 04/26/10 - Modify lib_osds_get_os_type to return whether AIX # version is supported. If version is supported, # return version string that is used within install # path. # averhuls 04/01/10 - Add lib_osds*exports. # abakst 01/20/10 - Only slibclean on unload # abakst 09/08/09 - Creation # use strict; use acfslib; use osds_unix_linux_acfslib; use Errno; require Exporter; package osds_acfslib; our @ISA = qw(Exporter); our @EXPORT = qw( lib_osds_check_driver_inuse lib_osds_check_driver_installed lib_osds_check_driver_loaded lib_osds_check_loaded_drivers_mismatch lib_osds_exportfs lib_osds_get_os_type lib_osds_load_driver lib_osds_remove_exports lib_osds_restore_exports lib_osds_unload_driver lib_osds_is_mounted @DRIVER_COMPONENTS ); our (@DRIVER_COMPONENTS) = ( "oracleadvm.ext", "oracleoks.ext", "oracleacfs.ext", ); # $ENV{PATH} = $ENV{PATH} . ":/sbin"; # lib_osds_check_driver_inuse sub lib_osds_check_driver_inuse { #TODO: Not currently possible return 0; } # end lib_osds_check_driver_inuse use File::Basename; # lib_osds_check_driver_installed sub lib_osds_check_driver_installed { my ($driver) = @_; return (-e "/usr/lib/drivers/$driver"); } # end lib_osds_check_driver_installed # lib_osds_check_driver_loaded sub lib_osds_check_driver_loaded { my ($driver) = @_; my ($loaded); # In AIX, return success if OKS driver because it's loaded by # the other driver. The below grep commands work on NLS systems. if ($driver eq $DRIVER_COMPONENTS[osds_unix_linux_acfslib::OKS_IDX]) { $loaded = 0; } elsif ($driver eq $DRIVER_COMPONENTS[osds_unix_linux_acfslib::OFS_IDX]) { $loaded = system("/usr/sbin/lsdev -C -t acfsctl -S a | grep -q ofsctl ") >> 8; } elsif ($driver eq $DRIVER_COMPONENTS[osds_unix_linux_acfslib::AVD_IDX]) { $loaded = system("/usr/sbin/lsdev -C -t advmctl -S a | grep -q advmctl ") >> 8; } return ($loaded == 0); } # end lib_osds_check_drivers_loaded # lib_osds_check_loaded_drivers_mismatch # # Determine whether or not the installed drivers match the drivers that # are loaded in the kernel. # Solaris only for now. sub lib_osds_check_loaded_drivers_mismatch { return 0; } # lib_osds_exportfs # sub lib_osds_exportfs { my ($mountpoint) = @_; # stub: not required on AIX } # end lib_osds_exportfs # lib_osds_get_os_type # # Returns AIX version string used in install path # Also used by lib_osds_usm_supported to determine if AIX version is # supported # sub lib_osds_get_os_type { my ($vers) = " "; my ($supported) = 0; # Check that OS level is greater than 6.1 TL4 SP2, or any 7.x release. # Although current code (compiled on 6.1) runs fine on 7.1, we'll # support a major version level directory hierarchy so if IBM releases # AIX 7.2, we'll still install from directory V7x. my ($oslevel) = `oslevel -s`; chomp ($oslevel); if ($oslevel =~ /^(\d+)-(\d+)-(\d+)-(\d+)$/) { my $baselevel = $1; my $techlevel = $2; my $servicepack = $3; if (($baselevel < 8000) && (($baselevel > 6100) || ($baselevel == 6100 && $techlevel > 4) || ($baselevel == 6100 && $techlevel == 4 && $servicepack >= 2))) { # OS level is supported # Must return a sub-directory in the install path # e.g. install/AIX/V61/powerpc/bin # ^^^ # There's little point in automating this now since we have to change the # test above for AIX 8.1 anyway. if ($baselevel < 7000) { return "V61"; } else { return "V7x"; } } else { acfslib::lib_error_print(9459, "ADVM/ACFS is not supported on this OS version: '%s'", "AIX " . $oslevel); return "ADVM/ACFS is not supported on AIX $oslevel"; } } else { acfslib::lib_error_print(9459, "ADVM/ACFS is not supported on this OS version: '%s'", "AIX " . $oslevel); return "ADVM/ACFS is not supported on this AIX version"; } } # end get_os_type # lib_osds_load_driver() sub lib_osds_load_driver { my ($driver) = @_; my $retval; if (!defined($ENV{ODMDIR})) { acfslib::lib_error_print(9395, "Environment variable ODMDIR is not set, unable to proceed with " . "system configuration."); return osds_unix_linux_acfslib::USM_FAIL; } elsif(! -e $ENV{ODMDIR}) { acfslib::lib_error_print(9396, "Environment variable ODMDIR specifies a nonexistent path, unable " . "to proceed with system configuration."); return osds_unix_linux_acfslib::USM_FAIL; } system("/usr/sbin/slibclean"); $retval = run_driver_method($driver, "def"); if ($retval == 0) { $retval = run_driver_method($driver, "cfg"); } return $retval; } # end lib_osds_load_driver # lib_osds_remove_exports # sub lib_osds_remove_exports { my ($mountpoint) = @_; # mount point to remove export. my (@export_list) = 0; # returned list of items we unexported. # stub: not required on AIX return @export_list; } # end lib_osds_remove_exports # lib_osds_restore_exports # sub lib_osds_restore_exports { my (@export_list) = @_; # stub: not required on AIX } #end lib_osds_restore_exports # lib_osds_unload_driver() sub lib_osds_unload_driver { my ($driver) = @_; my ($retval); if (!defined($ENV{ODMDIR})) { acfslib::lib_error_print(9395, "Environment variable ODMDIR is not set, unable to proceed with " . "system configuration."); return osds_unix_linux_acfslib::USM_FAIL; } elsif(! -e $ENV{ODMDIR}) { acfslib::lib_error_print(9396, "Environment variable ODMDIR specifies a nonexistent path, unable " . "to proceed with system configuration."); return osds_unix_linux_acfslib::USM_FAIL; } $retval = run_driver_method($driver, "ucfg"); if ($retval == osds_unix_linux_acfslib::USM_SUCCESS) { system("/usr/sbin/slibclean"); return $retval; } return osds_unix_linux_acfslib::USM_FAIL; } # end lib_osds_unload_driver # lib_osds_is_mounted # # check to see if the specified mount point is active # # Note this function is the same as asmlib/sol/osds_acfslib.pm. The two # should be kept in sync. # sub lib_osds_is_mounted { my ($mount_point) = @_; # mount point to test my ($mounted) = 0; # assume not mounted my ($line); # Remove trailing slash, if any, so that grep will work. $mount_point =~ s/\/$//; # Bug 9589426 - ACFS DBHOME resource fails to start in Linux # Print an error if relative pathname is provided for a mountpoint # to reflect review comments instead of making it work. my $slash = '/'; my $idx = index($mount_point, $slash); if ( ! acfslib::lib_is_abs_path ( $mount_point ) ) { acfslib::lib_error_print(9366, "Relative path for mount point '%s' is not supported.", $mount_point); return $mounted; } open (CHK_MOUNT, "mount | grep $mount_point |"); while ($line = ) { my ($dev, $mntpt) = osds_unix_linux_acfslib::get_dev_mntpt_from_mount_line($line); if ($mntpt eq $mount_point) { # the mountpoint is found. $mounted = 1; last; } } close (CHK_MOUNT); return $mounted; } # end lib_osds_is_mounted ############################### # internal #static" functions # ############################### sub run_driver_method { my ($driver, $prefix) = @_; my ($driver_base) = $driver; my ($cmd); if (!(($prefix eq "def") || ($prefix eq "cfg") || ($prefix eq "ucfg"))) { return osds_unix_linux_acfslib::USM_FAIL; } # Strip out Oracle and the extension from the driver name $driver_base =~ s/.ext//; $driver_base =~ s/oracle//; ($cmd) = "/usr/lib/methods/${prefix}${driver_base}ctl -l "; if ($driver eq $DRIVER_COMPONENTS[osds_unix_linux_acfslib::OKS_IDX]) { # OKS loading/unloading is performed automatically # when ADVM/ACFS are loaded/unloaded return osds_unix_linux_acfslib::USM_SUCCESS; } # Determine the correct argument to the driver loader/unload if ($driver eq $DRIVER_COMPONENTS[osds_unix_linux_acfslib::OFS_IDX]) { $cmd .= "ofsctl"; } elsif ($driver eq $DRIVER_COMPONENTS[osds_unix_linux_acfslib::AVD_IDX]) { $cmd .= "advmctl"; } else { return osds_unix_linux_acfslib::USM_FAIL; } # Upon successful completion, 'define' driver methods print device names to # standard output. We do not want these device names to show up on the # screen, so here we throw away standard output. We do not throw away # standard error as we do want errors to show up on the screen if ($prefix eq "def") { $cmd .= " >/dev/null"; } system($cmd); if ($? != 0) { return osds_unix_linux_acfslib::USM_FAIL; } return osds_unix_linux_acfslib::USM_SUCCESS; } 1;