1*7419d6e4SChuck Tuffli /* 2*7419d6e4SChuck Tuffli * Copyright (c) 2017-2021 Chuck Tuffli <chuck@tuffli.net> 3*7419d6e4SChuck Tuffli * 4*7419d6e4SChuck Tuffli * Permission to use, copy, modify, and distribute this software for any 5*7419d6e4SChuck Tuffli * purpose with or without fee is hereby granted, provided that the above 6*7419d6e4SChuck Tuffli * copyright notice and this permission notice appear in all copies. 7*7419d6e4SChuck Tuffli * 8*7419d6e4SChuck Tuffli * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9*7419d6e4SChuck Tuffli * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10*7419d6e4SChuck Tuffli * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11*7419d6e4SChuck Tuffli * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12*7419d6e4SChuck Tuffli * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13*7419d6e4SChuck Tuffli * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14*7419d6e4SChuck Tuffli * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15*7419d6e4SChuck Tuffli */ 16*7419d6e4SChuck Tuffli #ifndef _LIBSMART_DEV_H 17*7419d6e4SChuck Tuffli #define _LIBSMART_DEV_H 18*7419d6e4SChuck Tuffli 19*7419d6e4SChuck Tuffli /** 20*7419d6e4SChuck Tuffli * Open a device to gather SMART information 21*7419d6e4SChuck Tuffli * 22*7419d6e4SChuck Tuffli * The call performs OS specific functions necessary to prepare the device 23*7419d6e4SChuck Tuffli * to receive read log requests. 24*7419d6e4SChuck Tuffli * 25*7419d6e4SChuck Tuffli * Although opaque to the user, the handle must be a pointer to a structure 26*7419d6e4SChuck Tuffli * with the first member being struct smart_s. The remaining members are OS 27*7419d6e4SChuck Tuffli * specific and are not used by the library. 28*7419d6e4SChuck Tuffli * 29*7419d6e4SChuck Tuffli * @param protocol The desired protocol or "auto" to automatically detect it 30*7419d6e4SChuck Tuffli * @param devname The device name to open 31*7419d6e4SChuck Tuffli * 32*7419d6e4SChuck Tuffli * @return An opaque handle to the device or NULL on failure 33*7419d6e4SChuck Tuffli */ 34*7419d6e4SChuck Tuffli extern smart_h device_open(smart_protocol_e, char *); 35*7419d6e4SChuck Tuffli 36*7419d6e4SChuck Tuffli /** 37*7419d6e4SChuck Tuffli * Close a device and release the associated resources 38*7419d6e4SChuck Tuffli * 39*7419d6e4SChuck Tuffli * @param handle The handle returned from device_open() 40*7419d6e4SChuck Tuffli * 41*7419d6e4SChuck Tuffli * @return None 42*7419d6e4SChuck Tuffli */ 43*7419d6e4SChuck Tuffli extern void device_close(smart_h); 44*7419d6e4SChuck Tuffli 45*7419d6e4SChuck Tuffli /** 46*7419d6e4SChuck Tuffli * Read the log page 47*7419d6e4SChuck Tuffli * 48*7419d6e4SChuck Tuffli * This call reads the specified log page in the protocol specific manner 49*7419d6e4SChuck Tuffli * needed by the device. The results are placed in the provided buffer. 50*7419d6e4SChuck Tuffli * 51*7419d6e4SChuck Tuffli * @param h SMART handle returned from device_open() 52*7419d6e4SChuck Tuffli * @param page The log page ID 53*7419d6e4SChuck Tuffli * @param buf Pointer to buffer containing the results of the read 54*7419d6e4SChuck Tuffli * @param bsize Size of the buffer in bytes 55*7419d6e4SChuck Tuffli * 56*7419d6e4SChuck Tuffli * @return Zero on success, errno on failure 57*7419d6e4SChuck Tuffli */ 58*7419d6e4SChuck Tuffli extern int32_t device_read_log(smart_h, uint32_t, void *, size_t); 59*7419d6e4SChuck Tuffli 60*7419d6e4SChuck Tuffli #endif /* !_LIBSMART_DEV_H */ 61