1 .\" Author: Marshall Kirk McKusick <mckusick@freebsd.org>
2 .\" Date: January 19, 2018
4 .\" Manual page for libufs functions:
8 .\" This file is in the public domain.
16 .Nm getinode , putinode
17 .Nd fetch and store inodes on a UFS file system
25 .Fn getinode "struct uufsd *disk" "union dinodep *dp" "ino_t inumber"
27 .Fn putinode "struct uufsd *disk"
33 functions provide an inode fetch and store API for
36 They operate on a userland UFS disk structure.
39 function fetches the specified inode from the filesystem.
42 function stores the most recently fetched inode to the filesystem.
47 .Bd -literal -offset indent
49 struct ufs1_dinode *dp1;
50 struct ufs2_dinode *dp2;
54 Sample code to clear write permissions for inode number
56 stored on the filesystem described by
58 .Bd -literal -offset indent
62 #include <ufs/ufs/dinode.h>
63 #include <ufs/ffs/fs.h>
67 clearwrite(struct uufsd *diskp, ino_t inumber)
71 if (getinode(diskp, &dp, inumber) == -1)
72 err(1, "getinode: %s", diskp->d_error);
73 switch (diskp->d_ufs) {
74 case 1: /* UFS 1 filesystem */
75 dp.dp1->di_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH);
77 case 2: /* UFS 2 filesystem */
78 dp.dp2->di_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH);
81 errx(1, "unknown filesystem type");
83 if (putinode(diskp) == -1)
84 err(1, "putinode: %s", diskp->d_error);
92 functions return 0 on success, or \-1 in case of any error.
93 A string describing the error is stored in
97 often provides additional information.
103 for any of the errors specified for the library function
105 It can also fail if the inode number is out of the range of inodes
112 for any of the errors specified for the library functions
117 Additionally both functions may follow the
119 error methodologies in case of a device error.
126 These functions first appeared as part of
131 .An Marshall Kirk McKusick Aq Mt mckusick@freebsd.org