add provision for short symbolic links
[unix-history] / usr / src / sys / ufs / ffs / dinode.h
CommitLineData
da7c5cc6 1/*
6d0f0ece
KM
2 * Copyright (c) 1982, 1989 The Regents of the University of California.
3 * All rights reserved.
da7c5cc6 4 *
b702c21d 5 * %sccs.include.redist.c%
6d0f0ece 6 *
1471ece5 7 * @(#)dinode.h 7.17 (Berkeley) %G%
da7c5cc6 8 */
d0064d3a 9
b5cc7ac7
KB
10/*
11 * The root inode is the root of the file system. Inode 0 can't be used for
12 * normal purposes and historically bad blocks were linked to inode 1, thus
13 * the root inode is 2. (Inode 1 is no longer used for this purpose, however
14 * numerous dump tapes make this assumption, so we are stuck with it).
15 */
16#define ROOTINO ((ino_t)2)
17
d0064d3a 18/*
a3257f3c
KM
19 * A dinode contains all the meta-data associated with a UFS file.
20 * This structure defines the on-disk format of a dinode.
d0064d3a 21 */
ad30fb67 22
af0b24db
SL
23#define NDADDR 12 /* direct addresses in inode */
24#define NIADDR 3 /* indirect addresses in inode */
d0064d3a 25
ad30fb67 26struct dinode {
53bbebfd
KM
27 u_short di_mode; /* 0: mode and type of file */
28 short di_nlink; /* 2: number of links to file */
29 u_short di_ouid; /* 4: old owner's user id */
30 u_short di_ogid; /* 6: old owner's group id */
2d42ef07 31 u_quad_t di_size; /* 8: number of bytes in file */
f9c05f63
KM
32 struct timespec di_atime; /* 16: time last accessed */
33 struct timespec di_mtime; /* 24: time last modified */
34 struct timespec di_ctime; /* 32: last time inode changed */
53bbebfd
KM
35 daddr_t di_db[NDADDR]; /* 40: disk block addresses */
36 daddr_t di_ib[NIADDR]; /* 88: indirect blocks */
37 long di_flags; /* 100: status, currently unused */
38 long di_blocks; /* 104: blocks actually held */
39 long di_gen; /* 108: generation number */
40 u_long di_uid; /* 112: owner's user id */
41 u_long di_gid; /* 116: owner's group id */
42 long di_spare[2]; /* 120: reserved, currently unused */
ad30fb67
KM
43};
44
1471ece5
KM
45/*
46 * The di_db fields may be overlaid with other information for
47 * file types that do not have associated disk storage. Block
48 * and character devices overlay the first data block with their
49 * dev_t value. Short symbolic links place their path in the
50 * di_db area.
51 */
55a2aa38 52#define di_rdev di_db[0]
1471ece5
KM
53#define di_shortlink di_db
54#define MAXSYMLINKLEN (NDADDR * sizeof(daddr_t))
af0b24db 55
55a2aa38 56/* file modes */
a3257f3c 57#define IFMT 0170000 /* mask of file type */
d328121a 58#define IFIFO 0010000 /* named pipe (fifo) */
a3257f3c 59#define IFCHR 0020000 /* character special device */
ad30fb67 60#define IFDIR 0040000 /* directory */
a3257f3c
KM
61#define IFBLK 0060000 /* block special device */
62#define IFREG 0100000 /* regular file */
ad30fb67 63#define IFLNK 0120000 /* symbolic link */
a3257f3c 64#define IFSOCK 0140000 /* UNIX domain socket */
dc9a2d80 65
a3257f3c
KM
66#define ISUID 04000 /* set user identifier when exec'ing */
67#define ISGID 02000 /* set group identifier when exec'ing */
68#define ISVTX 01000 /* save execution information on exit */
69#define IREAD 0400 /* read permission */
70#define IWRITE 0200 /* write permission */
71#define IEXEC 0100 /* execute permission */