xref: /netbsd-src/sys/sys/fileassoc.h (revision ce2c90c7c172d95d2402a5b3d96d8f8e6d138a21)
1 /* $NetBSD: fileassoc.h,v 1.5 2006/09/06 13:37:49 blymn Exp $ */
2 
3 /*-
4  * Copyright (c) 2006 Elad Efrat <elad@NetBSD.org>
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. All advertising materials mentioning features or use of this software
16  *    must display the following acknowledgement:
17  *      This product includes software developed by Elad Efrat.
18  * 4. The name of the author may not be used to endorse or promote products
19  *    derived from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef _SYS_FILEASSOC_H_
34 #define _SYS_FILEASSOC_H_
35 
36 #include "opt_fileassoc.h"
37 
38 #include <sys/cdefs.h>
39 #include <sys/param.h>
40 
41 /* Max. number of hooks. */
42 #ifndef FILEASSOC_NHOOKS
43 #define	FILEASSOC_NHOOKS	4
44 #endif /* !FILEASSOC_NHOOKS */
45 
46 #define	FILEASSOC_INVAL		-1
47 
48 typedef int fileassoc_t;
49 typedef void (*fileassoc_cleanup_cb_t)(void *, int);
50 typedef void (*fileassoc_cb_t)(void *);
51 
52 #define	FILEASSOC_CLEANUP_TABLE	0
53 #define	FILEASSOC_CLEANUP_FILE	1
54 
55 void fileassoc_init(void);
56 fileassoc_t fileassoc_register(const char *, fileassoc_cleanup_cb_t);
57 int fileassoc_deregister(fileassoc_t);
58 void *fileassoc_tabledata_lookup(struct mount *, fileassoc_t);
59 void *fileassoc_lookup(struct vnode *, fileassoc_t);
60 int fileassoc_table_add(struct mount *, size_t);
61 int fileassoc_table_delete(struct mount *);
62 int fileassoc_table_clear(struct mount *, fileassoc_t);
63 int fileassoc_tabledata_add(struct mount *, fileassoc_t, void *);
64 int fileassoc_tabledata_clear(struct mount *, fileassoc_t);
65 int fileassoc_file_delete(struct vnode *);
66 int fileassoc_add(struct vnode *, fileassoc_t, void *);
67 int fileassoc_clear(struct vnode *, fileassoc_t);
68 int fileassoc_table_run(struct mount *, fileassoc_t, fileassoc_cb_t);
69 
70 #endif /* !_SYS_FILEASSOC_H_ */
71