1a627ac61SEd Schouten /*- 2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 3d915a14eSPedro F. Giffuni * 4a627ac61SEd Schouten * Copyright (c) 2010 Ed Schouten <ed@FreeBSD.org> 5a627ac61SEd Schouten * All rights reserved. 6a627ac61SEd Schouten * 7a627ac61SEd Schouten * Redistribution and use in source and binary forms, with or without 8a627ac61SEd Schouten * modification, are permitted provided that the following conditions 9a627ac61SEd Schouten * are met: 10a627ac61SEd Schouten * 1. Redistributions of source code must retain the above copyright 11a627ac61SEd Schouten * notice, this list of conditions and the following disclaimer. 12a627ac61SEd Schouten * 2. Redistributions in binary form must reproduce the above copyright 13a627ac61SEd Schouten * notice, this list of conditions and the following disclaimer in the 14a627ac61SEd Schouten * documentation and/or other materials provided with the distribution. 15a627ac61SEd Schouten * 16a627ac61SEd Schouten * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17a627ac61SEd Schouten * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18a627ac61SEd Schouten * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19a627ac61SEd Schouten * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20a627ac61SEd Schouten * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21a627ac61SEd Schouten * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22a627ac61SEd Schouten * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23a627ac61SEd Schouten * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24a627ac61SEd Schouten * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25a627ac61SEd Schouten * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26a627ac61SEd Schouten * SUCH DAMAGE. 27a627ac61SEd Schouten */ 28a627ac61SEd Schouten 29a627ac61SEd Schouten #ifndef _UTXDB_H_ 30a627ac61SEd Schouten #define _UTXDB_H_ 31a627ac61SEd Schouten 32a627ac61SEd Schouten #include <stdint.h> 33a627ac61SEd Schouten 34a627ac61SEd Schouten #define _PATH_UTX_ACTIVE "/var/run/utx.active" 35a627ac61SEd Schouten #define _PATH_UTX_LASTLOGIN "/var/log/utx.lastlogin" 36a627ac61SEd Schouten #define _PATH_UTX_LOG "/var/log/utx.log" 37a627ac61SEd Schouten 38a627ac61SEd Schouten /* 39a627ac61SEd Schouten * Entries in struct futx are ordered by how often they are used. In 40a627ac61SEd Schouten * utx.log only entries will be written until the last non-zero byte, 41a627ac61SEd Schouten * which means we want to put the hostname at the end. Most primitive 42a627ac61SEd Schouten * records only store a ut_type and ut_tv, which means we want to store 43a627ac61SEd Schouten * those at the front. 44a627ac61SEd Schouten */ 45a627ac61SEd Schouten 46a627ac61SEd Schouten struct utmpx; 47a627ac61SEd Schouten 48a627ac61SEd Schouten struct futx { 49a627ac61SEd Schouten uint8_t fu_type; 50a627ac61SEd Schouten uint64_t fu_tv; 51a627ac61SEd Schouten char fu_id[8]; 52a627ac61SEd Schouten uint32_t fu_pid; 53a627ac61SEd Schouten char fu_user[32]; 54a627ac61SEd Schouten char fu_line[16]; 55a627ac61SEd Schouten char fu_host[128]; 56a627ac61SEd Schouten } __packed; 57a627ac61SEd Schouten 58a627ac61SEd Schouten void utx_to_futx(const struct utmpx *, struct futx *); 5998c63a48SEd Schouten struct utmpx *futx_to_utx(const struct futx *); 60a627ac61SEd Schouten 61a627ac61SEd Schouten #endif /* !_UTXDB_H_ */ 62