ignore-new-targets-20060327
[openafs.git] / src / vol / partition.h
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  *
9  * Portions Copyright (c) 2006 Sine Nomine Associates
10  */
11
12 /*
13         System:         VICE-TWO
14         Module:         partition.h
15         Institution:    The Information Technology Center, Carnegie-Mellon University
16
17  */
18
19 #include <afs/param.h>
20 #include "nfs.h"
21 #if     defined(AFS_HPUX_ENV)
22 #define AFS_DSKDEV      "/dev/dsk"
23 #define AFS_RDSKDEV     "/dev/rdsk/"
24 #define AFS_LVOLDEV     "/dev/vg0"
25 #define AFS_ACVOLDEV    "/dev/ac"
26 #define AFS_RACVOLDEV   "/dev/ac/r"
27 #else
28 #define AFS_DSKDEV      "/dev"
29 #define AFS_RDSKDEV     "/dev/r"
30 #endif
31
32
33 /* All Vice partitions on a server will have the following name prefix */
34 #define VICE_PARTITION_PREFIX   "/vicep"
35 #define VICE_PREFIX_SIZE        (sizeof(VICE_PARTITION_PREFIX)-1)
36
37 /* If a file by this name exists in a /vicepX directory, it means that
38  * this directory should be used as an AFS partition even if it's not
39  * on a separate partition (for instance if it's part of a large /).
40  * This feature only works with the NAMEI fileserver.
41  */
42 #ifdef AFS_NAMEI_ENV
43 #define VICE_ALWAYSATTACH_FILE  "AlwaysAttach"
44 #endif
45
46 /* For NT, the roles of "name" and "devName" are reversed. That is, "name"
47  * refers to the drive letter name and "devName" refers to the /vicep style
48  * or name. The reason for this is that a lot of places assume that "name"
49  * is the right thing to use to access the partition. Silly of them isn't it?
50  * The NT version of VInitPartition does the intial setup. There is an NT
51  * variant for VGetPartition as well. Also, the VolPartitionInfo RPC does
52  * a swap before sending the data out on the wire.
53  */
54 struct DiskPartition {
55     struct DiskPartition *next;
56     char *name;                 /* Mounted partition name */
57     char *devName;              /* Device mounted on */
58     Device device;              /* device number */
59     afs_int32 index;            /* partition index (0<=x<=VOLMAXPARTS) */
60     int lock_fd;                /* File descriptor of this partition if locked; otherwise -1;
61                                  * Not used by the file server */
62     int free;                   /* Total number of blocks (1K) presumed
63                                  * available on this partition (accounting
64                                  * for the minfree parameter for the
65                                  * partition).  This is adjusted
66                                  * approximately by the sizes of files
67                                  * and directories read/written, and
68                                  * periodically the superblock is read and
69                                  * this is recomputed.  This number can
70                                  * be negative, if the partition starts
71                                  * out too full */
72     int totalUsable;            /* Total number of blocks available on this
73                                  * partition, taking into account the minfree
74                                  * parameter for the partition (see the
75                                  * 4.2bsd command tunefs, but note that the
76                                  * bug mentioned there--that the superblock
77                                  * is not reread--does not apply here.  The
78                                  * superblock is re-read periodically by
79                                  * VSetPartitionDiskUsage().) */
80     int minFree;                /* Number blocks to be kept free, as last read
81                                  * from the superblock */
82     int flags;
83     int f_files;                /* total number of files in this partition */
84 #ifdef AFS_DEMAND_ATTACH_FS
85     struct {
86         struct rx_queue head;   /* list of volumes on this partition (VByPList) */
87         afs_uint32 len;         /* length of volume list */
88         int busy;               /* asynch vol list op in progress */
89         pthread_cond_t cv;      /* vol_list.busy change cond var */
90     } vol_list;
91 #endif /* AFS_DEMAND_ATTACH_FS */
92 };
93
94 struct DiskPartitionStats {
95     afs_int32 free;
96     afs_int32 totalUsable;
97     afs_int32 minFree;
98     afs_int32 f_files;
99 #ifdef AFS_DEMAND_ATTACH_FS
100     afs_int32 vol_list_len;
101 #endif
102 };
103
104 #define PART_DONTUPDATE 1
105 #define PART_DUPLICATE  2       /* NT - used if we find more than one partition 
106                                  * using the same drive. Will be dumped before
107                                  * all partitions attached.
108                                  */
109
110 #ifdef AFS_NT40_ENV
111 #include <WINNT/vptab.h>
112 extern int VValidVPTEntry(struct vptab *vptp);
113 #endif
114
115
116 struct Volume;                  /* Potentially forward definition */
117
118 extern struct DiskPartition *DiskPartitionList;
119 extern struct DiskPartition *VGetPartition(char * name, int abortp);
120 extern struct DiskPartition *VGetPartition_r(char * name, int abortp);
121 #ifdef AFS_DEMAND_ATTACH_FS
122 extern struct DiskPartition *VGetPartitionById(afs_int32 index, int abortp);
123 extern struct DiskPartition *VGetPartitionById_r(afs_int32 index, int abortp);
124 #endif
125 extern int VAttachPartitions(void);
126 extern void VLockPartition(char *name);
127 extern void VLockPartition_r(char *name);
128 extern void VUnlockPartition(char *name);
129 extern void VUnlockPartition_r(char *name);
130 extern void VResetDiskUsage(void);
131 extern void VResetDiskUsage_r(void);
132 extern void VSetPartitionDiskUsage(register struct DiskPartition *dp);
133 extern void VSetPartitionDiskUsage_r(register struct DiskPartition *dp);
134 extern char *VPartitionPath(struct DiskPartition *p);
135 extern void VAdjustDiskUsage(Error * ec, struct Volume *vp,
136                              afs_sfsize_t blocks, afs_sfsize_t checkBlocks);
137 extern int VDiskUsage(struct Volume *vp, afs_sfsize_t blocks);
138 extern void VPrintDiskStats(void);
139 extern int VInitPartitionPackage(void);