⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unixware-lib.pl

📁 Unix下基于Web的管理工具
💻 PL
📖 第 1 页 / 共 4 页
字号:
			       "'$in{cfs_backfstype}'");			}		}	else {		# Need to automatically mount the back filesystem.. check		# it for sanity first.		# But HOW?		$in{cfs_src} =~ /^\S+$/ ||			&error("'$in{cfs_src}' is not a valid cache source");		}	return $in{cfs_src};	}elsif ($_[0] eq "autofs") {	# An autofs filesystem can be either mounted from the special	# -hosts and -xfn maps, or from a normal map. The map can be a file	# name (if it starts with /), or an NIS map (if it doesn't)	if ($in{autofs_type} == 0) {		# Normal map		$in{autofs_map} =~ /\S/ ||			&error("You did not enter an automount map name");		if ($in{autofs_map} =~ /^\// && !(-r $in{autofs_map})) {			&error("The map file '$in{autofs_map}' does not exist");			}		return $in{autofs_map};		}	elsif ($in{autofs_type} == 1) {		# Special hosts map (automount all shares from some host)		return "-hosts";		}	else {		# Special FNS map (not sure what this does)		return "-xfn";		}	}elsif ($_[0] eq "rumba") {	# Cannot check much here..	return "\\\\$in{rumba_server}\\$in{rumba_share}";	}}# fstyp_check(device, type)# Check if some device exists, and contains a filesystem of the given type,# using the fstyp command.sub fstyp_check{local($out, $part, $found);# Check if the device/partition actually existsif ($_[0] =~ /^\/dev\/dsk\/c(.)t(.)d(.)s(.)$/) {	# mounting a normal scsi device..	$out = `prtvtoc -h $_[0] 2>&1`;	if ($out =~ /No such file or directory|No such device or address/) {		&error("The SCSI target for '$_[0]' does not exist");		}	$part = $4;	foreach (split(/\n/, $out)) {		/^\s+([0-9]+)\s+([0-9]+)/;		if ($1 == $part) {			$found = 1; last;			}		}	if (!$found) {		&error("The SCSI partition for '$_[0]' does not exist");		}	}elsif ($_[0] =~ /^\/dev\/md\/dsk\/d(.)$/) {	# mounting a multi-disk (raid) device..	$out = `prtvtoc -h $_[0] 2>&1`;	if ($out =~ /No such file or directory|No such device or address/) {		&error("The RAID device for '$_[0]' does not exist");		}	if ($out !~ /\S/) {		&error("No partitions on '$_[0]' ??");		}	}else {	# Some other device	if (!open(DEV, $_[0])) {		if ($! =~ /No such file or directory/) {			&error("The device file '$_[0]' does not exist");			}		elsif ($! =~ /No such device or address/) {			&error("The device for '$_[0]' does not exist");			}		}	close(DEV);	}# Check the filesystem type$out = `fstyp $_[0] 2>&1`;if ($out =~ /^([A-z0-9]+)\n$/) {	if ($1 eq $_[1]) { return; }	else {		# Wrong filesystem type		&error("The device '$_[0]' is formatted as a ".		       &fstype_name($1));		}	}else {	&error("Failed to check filesystem type : $out");	}}# check_options(type)# Read options for some filesystem from %in, and use them to update the# %options array. Options handled by the user interface will be set or# removed, while unknown options will be left untouched.sub check_options{local($k, @rv);if ($_[0] eq "nfs") {	# NFS has lots of options to parse	if ($in{'nfs_ro'}) {		# Read-only		$options{"ro"} = ""; delete($options{"rw"});		}	else {		# Read-write		$options{"rw"} = ""; delete($options{"ro"});		}	delete($options{'quota'}); delete($options{'noquota'});	if ($in{'nfs_quota'}) { $options{'quota'} = ""; }	delete($options{"nosuid"}); delete($options{"suid"});	if ($in{nfs_nosuid}) { $options{"nosuid"} = ""; }	delete($options{"grpid"});	if ($in{nfs_grpid}) { $options{"grpid"} = ""; }	delete($options{"soft"}); delete($options{"hard"});	if ($in{nfs_soft}) { $options{"soft"} = ""; }	delete($options{"bg"}); delete($options{"fg"});	if ($in{nfs_bg}) { $options{"bg"} = ""; }	delete($options{"intr"}); delete($options{"nointr"});	if ($in{nfs_nointr}) { $options{"nointr"} = ""; }	delete($options{"vers"});	if (!$in{nfs_vers_def}) { $options{"vers"} = $in{nfs_vers}; }	delete($options{"proto"});	if ($in{nfs_proto} ne "") { $options{"proto"} = $in{nfs_proto}; }	delete($options{"port"});	if (!$in{nfs_port_def}) { $options{"port"} = $in{nfs_port}; }	delete($options{"timeo"});	if (!$in{nfs_timeo_def}) { $options{"timeo"} = $in{nfs_timeo}; }	delete($options{"secure"}); delete($options{"kerberos"});	delete($options{"sec"});	if ($gconfig{'os_version'} >= 2.6) {		if ($in{'nfs_auth'}) { $options{'sec'} = $in{'nfs_auth'}; }		}	else {		if ($in{'nfs_auth'} eq "dh") { $options{"secure"} = ""; }		elsif ($in{'nfs_auth'} eq "krb") { $options{"kerberos"} = ""; }		}	if ($gconfig{'os_version'} >= 7) {		delete($options{'public'});		$options{'public'} = "" if ($in{'nfs_public'});		}	}elsif ($_[0] eq "ufs") {	# UFS also has lots of options..	if ($in{ufs_ro}) {		# read-only (and thus no quota)		$options{"ro"} = ""; delete($options{"rw"});		delete($options{"rq"}); delete($options{"quota"});		}	elsif ($in{ufs_quota}) {		# read-write, with quota		delete($options{"ro"}); $options{"rw"} = "";		$options{"quota"} = "";		}	else {		# read-write, without quota		delete($options{"ro"}); $options{"rw"} = "";		delete($options{"quota"});		}	delete($options{"nosuid"});	if ($in{ufs_nosuid}) { $options{"nosuid"} = ""; }	delete($options{"intr"}); delete($options{"nointr"});	if ($in{ufs_nointr}) { $options{"nointr"} = ""; }	delete($options{"onerror"});	if ($in{ufs_onerror} ne "panic") {		$options{"onerror"} = $in{ufs_onerror};		}	delete($options{"toosoon"});	if ($in{ufs_toosoon_time}) {		$options{"toosoon"} = $in{ufs_toosoon_time}.				      $in{ufs_toosoon_units};		}	if ($gconfig{'os_version'} >= 7) {		delete($options{'noatime'});		$options{'noatime'} = "" if ($in{'ufs_noatime'});		delete($options{'forcedirectio'});		delete($options{'noforcedirectio'});		$options{'forcedirectio'} = "" if ($in{'ufs_force'});		delete($options{'nolargefiles'});delete($options{'largefiles'});		$options{'nolargefiles'} = "" if ($in{'ufs_nolarge'});		delete($options{'logging'}); delete($options{'nologging'});		$options{'logging'} = "" if ($in{'ufs_logging'});		}	}elsif ($_[0] eq "vxfs") {	if ($in{jfs_ro}) {		# read-only		$options{"ro"} = ""; delete($options{"rw"});		}	else {		# read-write		$options{"rw"} = ""; delete($options{"ro"});		}	if ($in{jfs_nosuid}) {		# nosuid		$options{"nosuid"} = ""; delete($options{"suid"});		}	else {		# suid		$options{"suid"} = ""; delete($options{"nosuid"});		}	if ($in{jfs_log}) {		# log		$options{"log"} = ""; delete($options{"delaylog"});		}	else {		# delaylog		$options{"delaylog"} = ""; delete($options{"log"});		}	if ($in{jfs_syncw}) {		# datainlog		$options{"datainlog"} = ""; delete($options{"nodatainlog"});		}	else {		# nodatainlog		$options{"nodatainlog"} = ""; delete($options{"datainlog"});		}	if ($in{jfs_quota}) {		# quota		$options{"quota"} = "";		}	else {		# noquota		delete($options{"quota"});		}	}elsif ($_[0] eq "lofs") {	# Loopback has no options to parse	}elsif ($_[0] eq "swap") {	# Swap has no options to parse	}elsif ($_[0] eq "pcfs") {	# PCFS has only 2 options	delete($options{'ro'}); delete($options{'rw'});	$options{'ro'} = "" if ($in{'pcfs_rp'});	delete($options{'foldcase'}); delete($options{'nofoldcase'});	$options{'foldcase'} = "" if ($in{'pcfs_foldcase'});	}elsif ($_[0] eq "tmpfs") {	# Ram-disk filesystems have only two options	delete($options{"size"});	if (!$in{"tmpfs_size_def"}) {		$options{"size"} = "$in{tmpfs_size}$in{tmpfs_unit}";		}	delete($options{"nosuid"});	if ($in{'tmpfs_nosuid'}) { $options{"nosuid"} = ""; }	}elsif ($_[0] eq "cachefs") {	# The caching filesystem has lots of options	$options{"backfstype"} = $in{"cfs_backfstype"};	delete($options{"backpath"});	if (!$in{"cfs_noback"}) {		# A back filesystem was given..  (alreadys checked)		$options{"backpath"} = $in{"cfs_backpath"};		}	if ($in{"cfs_cachedir"} !~ /^\/\S+/) {		&error("'$in{cfs_cachedir}' is not a valid cache directory");		}	$options{"cachedir"} = $in{"cfs_cachedir"};	delete($options{"write-around"}); delete($options{"non-shared"});	if ($in{"cfs_wmode"}) {		$options{"non-shared"} = "";		}	delete($options{"noconst"}); delete($options{"demandconst"});	if ($in{"cfs_con"} == 0) { $options{"noconst"} = ""; }	elsif ($in{"cfs_con"} == 2) { $options{"demandconst"} = ""; }	delete($options{"ro"}); delete($options{"rw"});	if ($in{"cfs_ro"}) { $options{"ro"} = ""; }	delete($options{"suid"}); delete($options{"nosuid"});	if ($in{"cfs_nosuid"}) { $options{"nosuid"} = ""; }	}elsif ($_[0] eq "autofs") {	# The options for autofs depend on the type of the automounted	# filesystem.. 	$options{"fstype"} = $in{"autofs_fstype"};	if ($gconfig{'os_version'} >= 2.6) {		delete($options{'nobrowse'}); delete($options{'browse'});		$options{'nobrowse'} = "" if ($in{'auto_nobrowse'});		}	return &check_options($options{"fstype"});	}elsif ($_[0] eq "rumba") {	# Options for smb filesystems..	delete($options{machinename});	if (!$in{rumba_mname_def}) { $options{machinename} = $in{rumba_mname}; }	delete($options{clientname});	if (!$in{rumba_cname_def}) { $options{clientname} = $in{rumba_cname}; }	delete($options{username});	if ($in{rumba_username}) { $options{username} = $in{rumba_username}; }	delete($options{password});	if ($in{rumba_password}) { $options{password} = $in{rumba_password}; }	delete($options{uid});	if ($in{rumba_uid} ne "") { $options{uid} = getpwnam($in{rumba_uid}); }	delete($options{gid});	if ($in{rumba_gid} ne "") { $options{gid} = getgrnam($in{rumba_gid}); }	delete($options{fmode});	if ($in{rumba_fmode} !~ /^[0-7]{3}$/) {		&error("'$in{rumba_fmode}' is not a valid octal file mode");		}	elsif ($in{rumba_fmode} ne "755") { $options{fmode} = $in{rumba_fmode}; }	delete($options{dmode});	if ($in{rumba_dmode} !~ /^[0-7]{3}$/) {		&error("'$in{rumba_dmode}' is not a valid octal directory mode");		}	elsif ($in{rumba_dmode} ne "755") { $options{dmode} = $in{rumba_dmode}; }	delete($options{'readwrite'});	if ($in{'rumba_readwrite'}) { $options{'readwrite'} = ""; }	delete($options{'readonly'});	if ($in{'rumba_readonly'}) { $options{'readonly'} = ""; }	delete($options{'attr'});	if ($in{'rumba_attr'}) { $options{'attr'} = ""; }	delete($options{'noupper'});	if ($in{'rumba_noupper'}) { $options{'noupper'} = ""; }	}# Return options stringforeach $k (keys %options) {	if ($options{$k} eq "") { push(@rv, $k); }	else { push(@rv, "$k=$options{$k}"); }	}return @rv ? join(',' , @rv) : "-";}# create_swap(path, size, units)# Attempt to create a swap file sub create_swap{local($out);$out = `mkfile $_[1]$_[2] $_[0] 2>&1`;if ($?) {	unlink($_[0]);	return "mkfile failed : $out";	}return 0;}# exports_list(host, dirarray, clientarray)# Fills the directory and client array references with exports from some# host. Returns an error string if something went wrongsub exports_list{local($dref, $cref, $out, $_);$dref = $_[1]; $cref = $_[2];$out = `showmount -e $_[0] 2>&1`;if ($?) { return $out; }foreach (split(/\n/, $out)) {	if (/^(\/\S*)\s+(.*)$/) {		push(@$dref, $1); push(@$cref, $2);		}	}return undef;}# broadcast_addr()# Returns a useable broadcast address for finding NFS serverssub broadcast_addr{local($out);$out = `ifconfig -a 2>&1`;if ($out =~ /broadcast\s+(\S+)/) { return $1; }return "255.255.255.255";}1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -