Debian Codegraph @

tmpfs/tmpfs.h

raw
1 /* Private data structures for tmpfs.
2 Copyright (C) 2000 Free Software Foundation, Inc.
3
4 This file is part of the GNU Hurd.
5
6 The GNU Hurd is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 The GNU Hurd is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with the GNU Hurd; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20 #ifndef _tmpfs_h
21 #define _tmpfs_h 1
22
23 #include <hurd/diskfs.h>
24 #include <sys/types.h>
25 #include <dirent.h>
26 #include <stdint.h>
27
28 struct disknode
29 {
30 uint_fast8_t type; /* DT_REG et al */
31
32 unsigned int gen;
33 off_t size;
34 mode_t mode;
35 nlink_t nlink;
36 uid_t uid, author;
37 gid_t gid;
38 struct timespec atime, mtime, ctime;
39 unsigned int flags;
40
41 char *trans;
42 size_t translen;
43
44 union
45 {
46 char *lnk; /* malloc'd symlink target */
47 struct
48 {
49 mach_port_t memobj, ro_memobj;
50 vm_address_t memref;
51 unsigned int allocpages; /* largest size while memobj was live */
52 } reg;
53 struct
54 {
55 struct tmpfs_dirent *entries;
56 struct disknode *dotdot;
57 } dir;
58 dev_t chr, blk;
59 } u;
60
61 struct node *hnext, **hprevp;
62 };
63
64 struct tmpfs_dirent
65 {
66 struct tmpfs_dirent *next;
67 struct disknode *dn;
68 uint8_t namelen;
69 char name[0];
70 };
71
72 extern off_t tmpfs_page_limit;
73 extern mach_port_t default_pager;
74
75 /* These two must be accessed using atomic operations. */
76 extern unsigned int num_files;
77 extern off_t tmpfs_space_used;
78
79 /* Convenience function to adjust tmpfs_space_used. */
80 static inline void
81 adjust_used (off_t change)
82 {
83 __atomic_add_fetch (&tmpfs_space_used, change, __ATOMIC_RELAXED);
84 }
85
86 /* Convenience function to get tmpfs_space_used. */
87 static inline off_t
88 get_used (void)
89 {
90 return __atomic_load_n (&tmpfs_space_used, __ATOMIC_RELAXED);
91 }
92
93 #endif