9959c512ac3ba36f7a0db7614f0357ce0bae748fJakub Hrozek/*
9959c512ac3ba36f7a0db7614f0357ce0bae748fJakub Hrozek Authors:
9959c512ac3ba36f7a0db7614f0357ce0bae748fJakub Hrozek Jan Cholasta <jcholast@redhat.com>
9959c512ac3ba36f7a0db7614f0357ce0bae748fJakub Hrozek
9959c512ac3ba36f7a0db7614f0357ce0bae748fJakub Hrozek Copyright (C) 2012 Red Hat
9959c512ac3ba36f7a0db7614f0357ce0bae748fJakub Hrozek
9959c512ac3ba36f7a0db7614f0357ce0bae748fJakub Hrozek This program is free software; you can redistribute it and/or modify
9959c512ac3ba36f7a0db7614f0357ce0bae748fJakub Hrozek it under the terms of the GNU General Public License as published by
9959c512ac3ba36f7a0db7614f0357ce0bae748fJakub Hrozek the Free Software Foundation; either version 3 of the License, or
9959c512ac3ba36f7a0db7614f0357ce0bae748fJakub Hrozek (at your option) any later version.
9959c512ac3ba36f7a0db7614f0357ce0bae748fJakub Hrozek
9959c512ac3ba36f7a0db7614f0357ce0bae748fJakub Hrozek This program is distributed in the hope that it will be useful,
9959c512ac3ba36f7a0db7614f0357ce0bae748fJakub Hrozek but WITHOUT ANY WARRANTY; without even the implied warranty of
9959c512ac3ba36f7a0db7614f0357ce0bae748fJakub Hrozek MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9959c512ac3ba36f7a0db7614f0357ce0bae748fJakub Hrozek GNU General Public License for more details.
9959c512ac3ba36f7a0db7614f0357ce0bae748fJakub Hrozek
9959c512ac3ba36f7a0db7614f0357ce0bae748fJakub Hrozek You should have received a copy of the GNU General Public License
9959c512ac3ba36f7a0db7614f0357ce0bae748fJakub Hrozek along with this program. If not, see <http://www.gnu.org/licenses/>.
9959c512ac3ba36f7a0db7614f0357ce0bae748fJakub Hrozek*/
9959c512ac3ba36f7a0db7614f0357ce0bae748fJakub Hrozek
9959c512ac3ba36f7a0db7614f0357ce0bae748fJakub Hrozek#ifndef __SSSD_ATOMIC_IO_H__
9959c512ac3ba36f7a0db7614f0357ce0bae748fJakub Hrozek#define __SSSD_ATOMIC_IO_H__
9959c512ac3ba36f7a0db7614f0357ce0bae748fJakub Hrozek
9959c512ac3ba36f7a0db7614f0357ce0bae748fJakub Hrozek#include <unistd.h>
9959c512ac3ba36f7a0db7614f0357ce0bae748fJakub Hrozek#include <stdbool.h>
9959c512ac3ba36f7a0db7614f0357ce0bae748fJakub Hrozek#include <poll.h>
9959c512ac3ba36f7a0db7614f0357ce0bae748fJakub Hrozek#include <errno.h>
9959c512ac3ba36f7a0db7614f0357ce0bae748fJakub Hrozek
9959c512ac3ba36f7a0db7614f0357ce0bae748fJakub Hrozek/* Performs a read or write operation in an manner that is seemingly atomic
9959c512ac3ba36f7a0db7614f0357ce0bae748fJakub Hrozek * to the caller.
9959c512ac3ba36f7a0db7614f0357ce0bae748fJakub Hrozek *
9959c512ac3ba36f7a0db7614f0357ce0bae748fJakub Hrozek * Please note that the function does not perform any asynchronous operation
9959c512ac3ba36f7a0db7614f0357ce0bae748fJakub Hrozek * so the operation might potentially block
9959c512ac3ba36f7a0db7614f0357ce0bae748fJakub Hrozek */
9959c512ac3ba36f7a0db7614f0357ce0bae748fJakub Hrozekssize_t sss_atomic_io_s(int fd, void *buf, size_t n, bool do_read);
9959c512ac3ba36f7a0db7614f0357ce0bae748fJakub Hrozek
9959c512ac3ba36f7a0db7614f0357ce0bae748fJakub Hrozek#define sss_atomic_read_s(fd, buf, n) sss_atomic_io_s(fd, buf, n, true)
9959c512ac3ba36f7a0db7614f0357ce0bae748fJakub Hrozek#define sss_atomic_write_s(fd, buf, n) sss_atomic_io_s(fd, buf, n, false)
9959c512ac3ba36f7a0db7614f0357ce0bae748fJakub Hrozek
9959c512ac3ba36f7a0db7614f0357ce0bae748fJakub Hrozek#endif /* __SSSD_ATOMIC_IO_H__ */