rangelock.h revision 204076
160484Sobrien/*-
2218822Sdim * Copyright (c) 2010 The FreeBSD Foundation
3218822Sdim * All rights reserved.
460484Sobrien *
560484Sobrien * This software was developed by Pawel Jakub Dawidek under sponsorship from
660484Sobrien * the FreeBSD Foundation.
760484Sobrien *
860484Sobrien * Redistribution and use in source and binary forms, with or without
960484Sobrien * modification, are permitted provided that the following conditions
1060484Sobrien * are met:
1160484Sobrien * 1. Redistributions of source code must retain the above copyright
1260484Sobrien *    notice, this list of conditions and the following disclaimer.
1360484Sobrien * 2. Redistributions in binary form must reproduce the above copyright
1460484Sobrien *    notice, this list of conditions and the following disclaimer in the
1560484Sobrien *    documentation and/or other materials provided with the distribution.
1660484Sobrien *
1760484Sobrien * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
1860484Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1960484Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20218822Sdim * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
21218822Sdim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2260484Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2360484Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24218822Sdim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2560484Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2660484Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27218822Sdim * SUCH DAMAGE.
28218822Sdim *
29218822Sdim * $FreeBSD: head/sbin/hastd/rangelock.h 204076 2010-02-18 23:16:19Z pjd $
3060484Sobrien */
3177298Sobrien
32218822Sdim#ifndef	_RANGELOCK_H_
3360484Sobrien#define	_RANGELOCK_H_
3477298Sobrien
3577298Sobrien#include <stdbool.h>
3677298Sobrien#include <unistd.h>
3777298Sobrien
3877298Sobrienstruct rangelocks;
3977298Sobrien
4077298Sobrienint rangelock_init(struct rangelocks **rlsp);
4177298Sobrienvoid rangelock_free(struct rangelocks *rls);
4277298Sobrienint rangelock_add(struct rangelocks *rls, off_t offset, off_t length);
4377298Sobrienvoid rangelock_del(struct rangelocks *rls, off_t offset, off_t length);
4477298Sobrienbool rangelock_islocked(struct rangelocks *rls, off_t offset, off_t length);
45130561Sobrien
46130561Sobrien#endif	/* !_RANGELOCK_H_ */
47130561Sobrien