19b8b748fSMatthew Dillon /*
2*68b321c1SMatthew Dillon * Copyright (c) 2012-2018 The DragonFly Project. All rights reserved.
39b8b748fSMatthew Dillon *
49b8b748fSMatthew Dillon * This code is derived from software contributed to The DragonFly Project
59b8b748fSMatthew Dillon * by Matthew Dillon <dillon@dragonflybsd.org>
69b8b748fSMatthew Dillon *
79b8b748fSMatthew Dillon * Redistribution and use in source and binary forms, with or without
89b8b748fSMatthew Dillon * modification, are permitted provided that the following conditions
99b8b748fSMatthew Dillon * are met:
109b8b748fSMatthew Dillon *
119b8b748fSMatthew Dillon * 1. Redistributions of source code must retain the above copyright
129b8b748fSMatthew Dillon * notice, this list of conditions and the following disclaimer.
139b8b748fSMatthew Dillon * 2. Redistributions in binary form must reproduce the above copyright
149b8b748fSMatthew Dillon * notice, this list of conditions and the following disclaimer in
159b8b748fSMatthew Dillon * the documentation and/or other materials provided with the
169b8b748fSMatthew Dillon * distribution.
179b8b748fSMatthew Dillon * 3. Neither the name of The DragonFly Project nor the names of its
189b8b748fSMatthew Dillon * contributors may be used to endorse or promote products derived
199b8b748fSMatthew Dillon * from this software without specific, prior written permission.
209b8b748fSMatthew Dillon *
219b8b748fSMatthew Dillon * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
229b8b748fSMatthew Dillon * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
239b8b748fSMatthew Dillon * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
249b8b748fSMatthew Dillon * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
259b8b748fSMatthew Dillon * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
269b8b748fSMatthew Dillon * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
279b8b748fSMatthew Dillon * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
289b8b748fSMatthew Dillon * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
299b8b748fSMatthew Dillon * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
309b8b748fSMatthew Dillon * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
319b8b748fSMatthew Dillon * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
329b8b748fSMatthew Dillon * SUCH DAMAGE.
339b8b748fSMatthew Dillon */
349b8b748fSMatthew Dillon #include <sys/param.h>
359b8b748fSMatthew Dillon #include <sys/systm.h>
369b8b748fSMatthew Dillon #include <sys/kernel.h>
379b8b748fSMatthew Dillon #include <sys/proc.h>
389b8b748fSMatthew Dillon #include <sys/mount.h>
399b8b748fSMatthew Dillon
409b8b748fSMatthew Dillon #include "hammer2.h"
419b8b748fSMatthew Dillon
429b8b748fSMatthew Dillon int
hammer2_msg_adhoc_input(kdmsg_msg_t * msg)433a5aa68fSMatthew Dillon hammer2_msg_adhoc_input(kdmsg_msg_t *msg)
449b8b748fSMatthew Dillon {
459b8b748fSMatthew Dillon kprintf("ADHOC INPUT MSG %08x\n", msg->any.head.cmd);
469b8b748fSMatthew Dillon return(0);
479b8b748fSMatthew Dillon }
488c280d5dSMatthew Dillon
498c280d5dSMatthew Dillon int
hammer2_msg_dbg_rcvmsg(kdmsg_msg_t * msg)503a5aa68fSMatthew Dillon hammer2_msg_dbg_rcvmsg(kdmsg_msg_t *msg)
518c280d5dSMatthew Dillon {
525bc5bca2SMatthew Dillon switch(msg->any.head.cmd & DMSGF_CMDSWMASK) {
535bc5bca2SMatthew Dillon case DMSG_DBG_SHELL:
548c280d5dSMatthew Dillon /*
558c280d5dSMatthew Dillon * Execute shell command (not supported atm)
563b76886bSMatthew Dillon *
573b76886bSMatthew Dillon * This is a one-way packet but if not (e.g. if part of
583b76886bSMatthew Dillon * a streaming transaction), we will have already closed
593b76886bSMatthew Dillon * our end.
608c280d5dSMatthew Dillon */
613a5aa68fSMatthew Dillon kdmsg_msg_reply(msg, DMSG_ERR_NOSUPP);
628c280d5dSMatthew Dillon break;
635bc5bca2SMatthew Dillon case DMSG_DBG_SHELL | DMSGF_REPLY:
643b76886bSMatthew Dillon /*
653b76886bSMatthew Dillon * Receive one or more replies to a shell command that we
663b76886bSMatthew Dillon * sent.
673b76886bSMatthew Dillon *
683b76886bSMatthew Dillon * This is a one-way packet but if not (e.g. if part of
693b76886bSMatthew Dillon * a streaming transaction), we will have already closed
703b76886bSMatthew Dillon * our end.
713b76886bSMatthew Dillon */
728c280d5dSMatthew Dillon if (msg->aux_data) {
738c280d5dSMatthew Dillon msg->aux_data[msg->aux_size - 1] = 0;
748c280d5dSMatthew Dillon kprintf("DEBUGMSG: %s\n", msg->aux_data);
758c280d5dSMatthew Dillon }
768c280d5dSMatthew Dillon break;
778c280d5dSMatthew Dillon default:
783b76886bSMatthew Dillon /*
793b76886bSMatthew Dillon * We don't understand what is going on, issue a reply.
803b76886bSMatthew Dillon * This will take care of all left-over cases whether it
813b76886bSMatthew Dillon * is a transaction or one-way.
823b76886bSMatthew Dillon */
833a5aa68fSMatthew Dillon kdmsg_msg_reply(msg, DMSG_ERR_NOSUPP);
848c280d5dSMatthew Dillon break;
858c280d5dSMatthew Dillon }
868c280d5dSMatthew Dillon return(0);
878c280d5dSMatthew Dillon }
88