1165725Sscottl#!/bin/sh
2165725Sscottl
3165725Sscottl# $FreeBSD$
4165725Sscottl# This is a simple wrapper for running the MegaCLI tool for Linux.  It assumes
5165725Sscottl# that the MegaCLI binary has been installed in /compat/linux/usr/sbin/MegaCli.
6165725Sscottl# The binary must also have been branded appropriately, and the COMPAT_LINUX,
7165725Sscottl# LINPROCFS, and LINSYSFS options must be enabled.  It is best to enable the
8165729Sscottl# COMPAT_LINUX option and compile the mfi driver into the kernel, instead of
9165729Sscottl# loading it as a module, to ensure that all of the required driver bits are
10165729Sscottl# enabled.
11165725Sscottl#
12165725Sscottl
13165725Sscottlmegacli=/usr/sbin/MegaCli
14165725Sscottllinuxdir=/compat/linux
15165725Sscottlosrelease=2.6.12
16165725Sscottl
17165725Sscottldevfsmount=`mount |grep $linuxdir/dev | awk '{print $3}'`
18165725Sscottlif [ "X$devfsmount" = "X" ]; then
19165725Sscottl	mount -t devfs devfs $linuxdir/dev
20165725Sscottlfi
21165725Sscottl
22165725Sscottlprocfsmount=`mount |grep $linuxdir/proc | awk '{print $3}'`
23165725Sscottlif [ "X$procfsmount" = "X" ]; then
24165725Sscottl	mount -t linprocfs linprocfs $linuxdir/proc
25165725Sscottlfi
26165725Sscottl
27165725Sscottlsysfsmount=`mount |grep $linuxdir/sys | awk '{print $3}'`
28165725Sscottlif [ "X$sysfsmount" = "X" ]; then
29165725Sscottl	mount -t linsysfs linsysfs $linuxdir/sys
30165725Sscottlfi
31165725Sscottl
32165725Sscottllinuxver=`sysctl -n compat.linux.osrelease | cut -d . -f 1,2`
33165725Sscottlif [ "X$linuxver" != "X2.6" ]; then
34165725Sscottl	sysctl compat.linux.osrelease=$osrelease
35165725Sscottlfi
36165725Sscottl
37165729Sscottlchroot $linuxdir $megacli $@
38