2 * Copyright 2000, International Business Machines Corporation and others.
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
11 * Module: vol-salvage.h
14 #ifndef __vol_salvage_h_
15 #define __vol_salvage_h_
17 #define SalvageVersion "2.4"
20 #include "volinodes.h"
22 /* salvager data structures */
23 struct InodeSummary { /* Inode summary file--an entry for each
24 * volume in the inode file for a partition */
25 VolId volumeId; /* Volume id */
26 VolId RWvolumeId; /* RW volume associated */
27 int index; /* index into inode file (0, 1, 2 ...) */
28 int nInodes; /* Number of inodes for this volume */
29 int nSpecialInodes; /* Number of special inodes, i.e. volume
30 * header, index, etc. These are all
31 * marked (viceinode.h) and will all be sorted
32 * to the beginning of the information for
33 * this volume. Read-only volumes should
34 * ONLY have special inodes (all the other
35 * inodes look as if they belong to the
36 * original RW volume). */
37 Unique maxUniquifier; /* The maximum uniquifier found in all the inodes.
38 * This is only useful for RW volumes and is used
39 * to compute a new volume uniquifier in the event
40 * that the header needs to be recreated. The inode
41 * uniquifier may be a truncated version of vnode
42 * uniquifier (AFS_3DISPARES). The real maxUniquifer
43 * is from the vnodes and later calcuated from it */
44 struct VolumeSummary *volSummary;
45 /* Either a pointer to the original volume
46 * header summary, or constructed summary
49 #define readOnly(isp) ((isp)->volumeId != (isp)->RWvolumeId)
51 struct VolumeSummary { /* Volume summary an entry for each
52 * volume in a volume directory.
53 * Assumption: one volume directory per
55 char *fileName; /* File name on the partition for the volume
57 struct VolumeHeader header;
58 /* volume number, rw volume number, inode
59 * numbers of each major component of
61 IHandle_t *volumeInfoHandle;
62 byte wouldNeedCallback; /* set if the file server should issue
63 * call backs for all the files in this volume when
64 * the volume goes back on line */
68 IHandle_t *handle; /* Inode containing this index */
69 afs_sfsize_t nVnodes; /* Total number of vnodes in index */
70 afs_sfsize_t nAllocatedVnodes; /* Total number actually used */
71 int volumeBlockCount; /* Total number of blocks used by volume */
72 Inode *inodes; /* Directory only */
74 short count; /* Number of references to vnode; MUST BE SIGNED */
75 unsigned claimed:1; /* Set when a parent directory containing an entry
76 * referencing this vnode is found. The claim
77 * is that the parent in "parent" can point to
78 * this vnode, and no other */
79 unsigned changed:1; /* Set if any parameters (other than the count)
80 * in the vnode change. It is determined if the
81 * link count has changed by noting whether it is
82 * 0 after scanning all directories */
83 unsigned salvaged:1; /* Set if this directory vnode has already been salvaged. */
84 unsigned todelete:1; /* Set if this vnode is to be deleted (should not be claimed) */
85 afs_fsize_t blockCount;
86 /* Number of blocks (1K) used by this vnode,
88 VnodeId parent; /* parent in vnode */
89 Unique unique; /* Must match entry! */
90 char *name; /* Name of directory entry */
91 int modeBits; /* File mode bits */
92 Inode InodeNumber; /* file's inode */
93 int type; /* File type */
94 int author; /* File author */
95 int owner; /* File owner */
96 int group; /* File group */
101 struct DirHandle dirHandle;
104 unsigned haveDot, haveDotDot;
106 int copied; /* If the copy-on-write stuff has been applied */
115 #define ORPH_IGNORE 0
116 #define ORPH_REMOVE 1
117 #define ORPH_ATTACH 2
120 /* command line options */
121 extern int debug; /* -d flag */
122 extern int Testing; /* -n flag */
123 extern int ListInodeOption; /* -i flag */
124 extern int ShowRootFiles; /* -r flag */
125 extern int RebuildDirs; /* -sal flag */
126 extern int Parallel; /* -para X flag */
127 extern int PartsPerDisk; /* Salvage up to 8 partitions on same disk sequentially */
128 extern int forceR; /* -b flag */
129 extern int ShowLog; /* -showlog flag */
130 extern int ShowSuid; /* -showsuid flag */
131 extern int ShowMounts; /* -showmounts flag */
132 extern int orphans; /* -orphans option */
136 extern int useSyslog; /* -syslog flag */
137 extern int useSyslogFacility; /* -syslogfacility option */
140 #define MAXPARALLEL 32
142 extern int OKToZap; /* -o flag */
143 extern int ForceSalvage; /* If salvage should occur despite the DONT_SALVAGE flag
144 * in the volume header */
147 #define ROOTINODE 2 /* Root inode of a 4.2 Unix file system
152 extern char * tmpdir;
153 extern FILE *logFile; /* one of {/usr/afs/logs,/vice/file}/SalvageLog */
157 /* For NT, we can fork the per partition salvagers to gain the required
158 * safety against Aborts. But there's too many complex data structures at
159 * the per volume salvager layer to easilty copy the data across.
160 * childJobNumber is resset from -1 to the job number if this is a
161 * per partition child of the main salvager. This information is passed
162 * out-of-band in the extra data area setup for the now unused parent/child
165 #define SALVAGER_MAGIC 0x00BBaaDD
166 #define NOT_CHILD -1 /* job numbers start at 0 */
167 /* If new options need to be passed to child, add them here. */
174 /* Child job this process is running. */
175 extern childJob_t myjob;
177 extern int nt_SalvagePartition(char *partName, int jobn);
178 extern int nt_SetupPartitionSalvage(void *datap, int len);
181 struct InodeSummary *svgp_inodeSummaryp;
183 struct SalvInfo *svgp_salvinfo;
185 #endif /* AFS_NT40_ENV */
191 extern void Exit(int code) AFS_NORETURN;
192 extern int Fork(void);
193 extern int Wait(char *prog);
194 extern char *ToString(const char *s);
195 extern void AskOffline(struct SalvInfo *salvinfo, VolumeId volumeId);
196 extern void AskOnline(struct SalvInfo *salvinfo, VolumeId volumeId);
197 extern void CheckLogFile(char * log_path);
199 extern void TimeStampLogFile(char * log_path);
201 extern void ClearROInUseBit(struct VolumeSummary *summary);
202 extern void CopyAndSalvage(struct SalvInfo *salvinfo, struct DirSummary *dir);
203 extern int CopyInode(Device device, Inode inode1, Inode inode2, int rwvolume);
204 extern void CopyOnWrite(struct SalvInfo *salvinfo, struct DirSummary *dir);
205 extern void CountVolumeInodes(register struct ViceInodeInfo *ip, int maxInodes,
206 register struct InodeSummary *summary);
207 extern void DeleteExtraVolumeHeaderFile(struct SalvInfo *salvinfo,
208 struct VolumeSummary *vsp);
209 extern void DistilVnodeEssence(struct SalvInfo *salvinfo, VolumeId vid,
210 VnodeClass class, Inode ino, Unique * maxu);
211 extern int GetInodeSummary(struct SalvInfo *salvinfo, FILE *inodeFile,
212 VolumeId singleVolumeNumber);
213 extern int GetVolumeSummary(struct SalvInfo *salvinfo,
214 VolumeId singleVolumeNumber);
215 extern int JudgeEntry(void *dirVal, char *name, afs_int32 vnodeNumber,
217 extern void MaybeZapVolume(struct SalvInfo *salvinfo, struct InodeSummary *isp,
218 char *message, int deleteMe, int check);
219 extern void ObtainSalvageLock(void);
220 extern void ObtainSharedSalvageLock(void);
221 extern void PrintInodeList(struct SalvInfo *salvinfo);
222 extern void PrintInodeSummary(struct SalvInfo *salvinfo);
223 extern void PrintVolumeSummary(struct SalvInfo *salvinfo);
224 extern int QuickCheck(struct SalvInfo *salvinfo, struct InodeSummary *isp,
226 extern void RemoveTheForce(char *path);
227 extern void SalvageDir(struct SalvInfo *salvinfo, char *name, VolumeId rwVid,
228 struct VnodeInfo *dirVnodeInfo, IHandle_t * alinkH,
229 int i, struct DirSummary *rootdir, int *rootdirfound);
230 extern void SalvageFileSysParallel(struct DiskPartition64 *partP);
231 extern void SalvageFileSys(struct DiskPartition64 *partP, VolumeId singleVolumeNumber);
232 extern void SalvageFileSys1(struct DiskPartition64 *partP,
233 VolumeId singleVolumeNumber);
234 extern int SalvageHeader(struct SalvInfo *salvinfo, struct stuff *sp,
235 struct InodeSummary *isp, int check, int *deleteMe);
236 extern int SalvageIndex(struct SalvInfo *salvinfo, Inode ino, VnodeClass class,
237 int RW, struct ViceInodeInfo *ip, int nInodes,
238 struct VolumeSummary *volSummary, int check);
239 extern int SalvageVnodes(struct SalvInfo *salvinfo, struct InodeSummary *rwIsp,
240 struct InodeSummary *thisIsp,
241 struct ViceInodeInfo *inodes, int check);
242 extern int SalvageVolume(struct SalvInfo *salvinfo, struct InodeSummary *rwIsp,
244 extern void DoSalvageVolumeGroup(struct SalvInfo *salvinfo,
245 struct InodeSummary *isp, int nVols);
247 extern void SalvageVolumeGroup(struct InodeSummary *isp, int nVols);
249 #define SalvageVolumeGroup DoSalvageVolumeGroup
251 extern int SalvageVolumeHeaderFile(struct SalvInfo *salvinfo,
252 struct InodeSummary *isp,
253 struct ViceInodeInfo *inodes, int RW,
254 int check, int *deleteMe);
255 extern void showlog(void);
256 extern int UseTheForceLuke(char *path);
260 #endif /* __vol_salvage_h_ */