diff --git a/sys/amd64/linux32/linux.h b/sys/amd64/linux32/linux.h index 94372d63c175..bdbe2135a68a 100644 --- a/sys/amd64/linux32/linux.h +++ b/sys/amd64/linux32/linux.h @@ -79,7 +79,7 @@ typedef l_ulong l_ino_t; typedef l_int l_key_t; typedef l_longlong l_loff_t; typedef l_ushort l_mode_t; -typedef l_long l_off_t; +typedef l_ulong l_off_t; typedef l_int l_pid_t; typedef l_uint l_size_t; typedef l_long l_suseconds_t; diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c index 5cc1f7d841ee..52f6e946f492 100644 --- a/sys/compat/linprocfs/linprocfs.c +++ b/sys/compat/linprocfs/linprocfs.c @@ -75,6 +75,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -90,6 +91,9 @@ __FBSDID("$FreeBSD$"); #include +#include +#include + #if defined(__i386__) || defined(__amd64__) #include #include @@ -359,6 +363,9 @@ linprocfs_domtab(PFS_FILL_ARGS) sbuf_printf(sb, "/sys %s sysfs %s", mntto, mp->mnt_stat.f_flags & MNT_RDONLY ? "ro" : "rw"); } else { + /* For Linux msdosfs is called vfat */ + if (strcmp(fstype, "msdosfs") == 0) + fstype = "vfat"; sbuf_printf(sb, "%s %s %s %s", mntfrom, mntto, fstype, mp->mnt_stat.f_flags & MNT_RDONLY ? "ro" : "rw"); } @@ -382,6 +389,69 @@ linprocfs_domtab(PFS_FILL_ARGS) return (error); } +/* + * Filler function for proc/partitions + * + */ +static int +linprocfs_dopartitions(PFS_FILL_ARGS) +{ + struct g_class *cp; + struct g_geom *gp; + struct g_provider *pp; + struct nameidata nd; + const char *lep; + char *dlep, *flep; + size_t lep_len; + int error; + int major, minor; + + /* resolve symlinks etc. in the emulation tree prefix */ + NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE, UIO_SYSSPACE, linux_emul_path, td); + flep = NULL; + error = namei(&nd); + lep = linux_emul_path; + if (error == 0) { + if (vn_fullpath(td, nd.ni_vp, &dlep, &flep) == 0) + lep = dlep; + vrele(nd.ni_vp); + VFS_UNLOCK_GIANT(NDHASGIANT(&nd)); + } + lep_len = strlen(lep); + + g_topology_lock(); + error = 0; + sbuf_printf(sb, "major minor #blocks name rio rmerge rsect " + "ruse wio wmerge wsect wuse running use aveq\n"); + + LIST_FOREACH(cp, &g_classes, class) { + if (strcmp(cp->name, "DISK") == 0 || + strcmp(cp->name, "PART") == 0) + LIST_FOREACH(gp, &cp->geom, geom) { + LIST_FOREACH(pp, &gp->provider, provider) { + if (linux_driver_get_major_minor( + pp->name, &major, &minor) != 0) { + major = 0; + minor = 0; + } + sbuf_printf(sb, "%d %d %lld %s " + "%d %d %d %d %d " + "%d %d %d %d %d %d\n", + major, minor, + (long long)pp->mediasize, pp->name, + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0); + } + } + } + g_topology_unlock(); + + if (flep != NULL) + free(flep, M_TEMP); + return (error); +} + + /* * Filler function for proc/stat */ @@ -1206,6 +1276,8 @@ linprocfs_init(PFS_INIT_ARGS) NULL, NULL, NULL, PFS_RD); pfs_create_file(root, "mtab", &linprocfs_domtab, NULL, NULL, NULL, PFS_RD); + pfs_create_file(root, "partitions", &linprocfs_dopartitions, + NULL, NULL, NULL, PFS_RD); pfs_create_link(root, "self", &procfs_docurproc, NULL, NULL, NULL, 0); pfs_create_file(root, "stat", &linprocfs_dostat, diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c index b36842954752..54ab6a251e9f 100644 --- a/sys/compat/linux/linux_file.c +++ b/sys/compat/linux/linux_file.c @@ -1109,6 +1109,9 @@ linux_mount(struct thread *td, struct linux_mount_args *args) } else if (strcmp(fstypename, "proc") == 0) { strcpy(fstypename, "linprocfs"); fsdata = NULL; + } else if (strcmp(fstypename, "vfat") == 0) { + strcpy(fstypename, "msdosfs"); + fsdata = NULL; } else { return (ENODEV); } @@ -1135,6 +1138,12 @@ linux_mount(struct thread *td, struct linux_mount_args *args) "fstype", fstypename, "fspath", mntonname, NULL); + } else if (strcmp(fstypename, "msdosfs") == 0) { + error = kernel_vmount(fsflags, + "fstype", fstypename, + "fspath", mntonname, + "from", mntfromname, + NULL); } else error = EOPNOTSUPP; return (error); diff --git a/sys/conf/files.amd64 b/sys/conf/files.amd64 index 2f17a01f0a92..7a7abf2c3640 100644 --- a/sys/conf/files.amd64 +++ b/sys/conf/files.amd64 @@ -183,6 +183,7 @@ dev/ipmi/ipmi_smbus.c optional ipmi smbus dev/ipmi/ipmi_smbios.c optional ipmi dev/ipmi/ipmi_ssif.c optional ipmi smbus dev/ipmi/ipmi_pci.c optional ipmi pci +dev/ipmi/ipmi_linux.c optional ipmi linux_compat32 dev/fdc/fdc.c optional fdc dev/fdc/fdc_acpi.c optional fdc dev/fdc/fdc_isa.c optional fdc isa diff --git a/sys/conf/files.i386 b/sys/conf/files.i386 index 16a7078614df..37f6b27fc72a 100644 --- a/sys/conf/files.i386 +++ b/sys/conf/files.i386 @@ -196,6 +196,7 @@ dev/ipmi/ipmi_smbus.c optional ipmi smbus dev/ipmi/ipmi_smbios.c optional ipmi dev/ipmi/ipmi_ssif.c optional ipmi smbus dev/ipmi/ipmi_pci.c optional ipmi pci +dev/ipmi/ipmi_linux.c optional ipmi linux_compat dev/kbd/kbd.c optional atkbd | sc | ukbd | usb2_input_kbd dev/le/if_le_isa.c optional le isa dev/mem/memutil.c optional mem diff --git a/sys/dev/ipmi/ipmi_linux.c b/sys/dev/ipmi/ipmi_linux.c new file mode 100644 index 000000000000..fcf2bd50322d --- /dev/null +++ b/sys/dev/ipmi/ipmi_linux.c @@ -0,0 +1,113 @@ +/*- + * Copyright (c) 2009 IronPort Systems Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +/* + * Linux ioctl handler for the ipmi device driver + */ + +#include +#include +#include +#include +#include +#include +#include +#ifdef __amd64__ +#include +#include +#else +#include +#include +#endif +#include +#include +#include + +/* There are multiple ioctl number ranges that need to be handled */ +#define IPMI_LINUX_IOCTL_MIN 0x690b +#define IPMI_LINUX_IOCTL_MAX 0x6915 + +/* Linux versions of ioctl's */ +#define L_IPMICTL_RECEIVE_MSG_TRUNC _IOWR(IPMI_IOC_MAGIC, 11, struct ipmi_recv) +#define L_IPMICTL_RECEIVE_MSG _IOWR(IPMI_IOC_MAGIC, 12, struct ipmi_recv) +#define L_IPMICTL_SEND_COMMAND _IOW(IPMI_IOC_MAGIC, 13, struct ipmi_req) +#define L_IPMICTL_REGISTER_FOR_CMD _IOW(IPMI_IOC_MAGIC, 14, struct ipmi_cmdspec) +#define L_IPMICTL_UNREGISTER_FOR_CMD _IOW(IPMI_IOC_MAGIC, 15, struct ipmi_cmdspec) +#define L_IPMICTL_SET_GETS_EVENTS_CMD _IOW(IPMI_IOC_MAGIC, 16, int) +#define L_IPMICTL_SET_MY_ADDRESS_CMD _IOW(IPMI_IOC_MAGIC, 17, unsigned int) +#define L_IPMICTL_GET_MY_ADDRESS_CMD _IOW(IPMI_IOC_MAGIC, 18, unsigned int) +#define L_IPMICTL_SET_MY_LUN_CMD _IOW(IPMI_IOC_MAGIC, 19, unsigned int) +#define L_IPMICTL_GET_MY_LUN_CMD _IOW(IPMI_IOC_MAGIC, 20, unsigned int) + +static linux_ioctl_function_t ipmi_linux_ioctl; +static struct linux_ioctl_handler ipmi_linux_handler = {ipmi_linux_ioctl, + IPMI_LINUX_IOCTL_MIN, + IPMI_LINUX_IOCTL_MAX}; + +SYSINIT (ipmi_linux_register, SI_SUB_KLD, SI_ORDER_MIDDLE, + linux_ioctl_register_handler, &ipmi_linux_handler); +SYSUNINIT(ipmi_linux_unregister, SI_SUB_KLD, SI_ORDER_MIDDLE, + linux_ioctl_unregister_handler, &ipmi_linux_handler); + +static int +ipmi_linux_modevent(module_t mod, int type, void *data) +{ + /* Do we care about any specific load/unload actions? */ + return (0); +} + +DEV_MODULE(ipmi_linux, ipmi_linux_modevent, NULL); +MODULE_DEPEND(ipmi_linux, linux, 1, 1, 1); + +static int +ipmi_linux_ioctl(struct thread *td, struct linux_ioctl_args *args) +{ + struct file *fp; + u_long cmd; + int error; + + if ((error = fget(td, args->fd, &fp)) != 0) + return (error); + cmd = args->cmd; + + switch(cmd) { + case L_IPMICTL_GET_MY_ADDRESS_CMD: + cmd = IPMICTL_GET_MY_ADDRESS_CMD; + break; + case L_IPMICTL_GET_MY_LUN_CMD: + cmd = IPMICTL_GET_MY_LUN_CMD; + break; + } + /* + * Pass the ioctl off to our standard handler. + */ + error = (fo_ioctl(fp, cmd, (caddr_t)args->arg, td->td_ucred, td)); + fdrop(fp, td); + return (error); +} diff --git a/sys/modules/ipmi/Makefile b/sys/modules/ipmi/Makefile index 3f45c73361ef..7493b234c158 100644 --- a/sys/modules/ipmi/Makefile +++ b/sys/modules/ipmi/Makefile @@ -1,5 +1,7 @@ # $FreeBSD$ +SUBDIR+= ipmi_linux + .PATH: ${.CURDIR}/../../dev/ipmi # XXX - ipmi_smbus and ipmi_ssif depend on smbus diff --git a/sys/modules/linprocfs/Makefile b/sys/modules/linprocfs/Makefile index a7cb129defa5..62af13ebea31 100644 --- a/sys/modules/linprocfs/Makefile +++ b/sys/modules/linprocfs/Makefile @@ -4,6 +4,7 @@ KMOD= linprocfs SRCS= vnode_if.h \ + device_if.h bus_if.h \ linprocfs.c \ opt_compat.h \ opt_route.h