1 /*
   2  * This file and its contents are supplied under the terms of the
   3  * Common Development and Distribution License ("CDDL"), version 1.0.
   4  * You may only use this file in accordance with the terms of version
   5  * 1.0 of the CDDL.
   6  *
   7  * A full copy of the text of the CDDL should have accompanied this
   8  * source.  A copy of the CDDL is also available via the Internet at
   9  * http://www.illumos.org/license/CDDL.
  10  */
  11 
  12 /*
  13  * Copyright 2013 Damian Bogel. All rights reserved.
  14  */
  15 
  16 /*
  17  * TODO:
  18  * fsd_open: return opaque handle (INVALID_FSD_HANDLE)
  19  */
  20 
  21 #include <fcntl.h>
  22 #include <string.h>
  23 #include <stropts.h>
  24 #include <sys/fsd.h>
  25 #include <sys/stat.h>
  26 #include <sys/types.h>
  27 #include <unistd.h>
  28 
  29 int
  30 fsd_open()
  31 {
  32         return (open(FSD_DEVICE_PATH, O_RDWR));
  33 }
  34 
  35 void
  36 fsd_close(int fd)
  37 {
  38         (void) close(fd);
  39 }
  40 
  41 /* TODO: what about strlcpy and const char vs int8_t? */
  42 void
  43 fsd_print_msg(const char *msg, int fd)
  44 {
  45         struct fsd_msg m;
  46         m.len = strlen(msg);
  47         m.len = strlcpy(m.s, msg, FSD_MAX_MSG_LEN);
  48         (void) ioctl(fd, FSD_PRINT_MSG, (intptr_t)&m);
  49 
  50 }