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 char deleted; /* did we delete this volume? */
63 byte wouldNeedCallback; /* set if the file server should issue
64 * call backs for all the files in this volume when
65 * the volume goes back on line */
69 IHandle_t *handle; /* Inode containing this index */
70 afs_sfsize_t nVnodes; /* Total number of vnodes in index */
71 afs_sfsize_t nAllocatedVnodes; /* Total number actually used */
72 int volumeBlockCount; /* Total number of blocks used by volume */
73 Inode *inodes; /* Directory only */
75 short count; /* Number of references to vnode; MUST BE SIGNED */
76 unsigned claimed:1; /* Set when a parent directory containing an entry
77 * referencing this vnode is found. The claim
78 * is that the parent in "parent" can point to
79 * this vnode, and no other */
80 unsigned changed:1; /* Set if any parameters (other than the count)
81 * in the vnode change. It is determined if the
82 * link count has changed by noting whether it is
83 * 0 after scanning all directories */
84 unsigned salvaged:1; /* Set if this directory vnode has already been salvaged. */
85 unsigned todelete:1; /* Set if this vnode is to be deleted (should not be claimed) */
86 afs_fsize_t blockCount;
87 /* Number of blocks (1K) used by this vnode,
89 VnodeId parent; /* parent in vnode */
90 Unique unique; /* Must match entry! */
91 char *name; /* Name of directory entry */
92 int modeBits; /* File mode bits */
93 Inode InodeNumber; /* file's inode */
94 int type; /* File type */
95 int author; /* File author */
96 int owner; /* File owner */
97 int group; /* File group */
102 struct DirHandle dirHandle;
105 unsigned haveDot, haveDotDot;
107 int copied; /* If the copy-on-write stuff has been applied */
116 #define ORPH_IGNORE 0
117 #define ORPH_REMOVE 1
118 #define ORPH_ATTACH 2
121 /* command line options */
122 extern int debug; /* -d flag */
123 extern int Testing; /* -n flag */
124 extern int ListInodeOption; /* -i flag */
125 extern int ShowRootFiles; /* -r flag */
126 extern int RebuildDirs; /* -sal flag */
127 extern int Parallel; /* -para X flag */
128 extern int PartsPerDisk; /* Salvage up to 8 partitions on same disk sequentially */
129 extern int forceR; /* -b flag */
130 extern int ShowLog; /* -showlog flag */
131 extern int ShowSuid; /* -showsuid flag */
132 extern int ShowMounts; /* -showmounts flag */
133 extern int orphans; /* -orphans option */
137 extern int useSyslog; /* -syslog flag */
138 extern int useSyslogFacility; /* -syslogfacility option */
141 #define MAXPARALLEL 32
143 extern int OKToZap; /* -o flag */
144 extern int ForceSalvage; /* If salvage should occur despite the DONT_SALVAGE flag
145 * in the volume header */
148 #define ROOTINODE 2 /* Root inode of a 4.2 Unix file system
153 extern char * tmpdir;
154 extern FILE *logFile; /* one of {/usr/afs/logs,/vice/file}/SalvageLog */
158 /* For NT, we can fork the per partition salvagers to gain the required
159 * safety against Aborts. But there's too many complex data structures at
160 * the per volume salvager layer to easilty copy the data across.
161 * childJobNumber is resset from -1 to the job number if this is a
162 * per partition child of the main salvager. This information is passed
163 * out-of-band in the extra data area setup for the now unused parent/child
166 #define SALVAGER_MAGIC 0x00BBaaDD
167 #define NOT_CHILD -1 /* job numbers start at 0 */
168 /* If new options need to be passed to child, add them here. */
175 /* Child job this process is running. */
176 extern childJob_t myjob;
178 extern int nt_SalvagePartition(char *partName, int jobn);
179 extern int nt_SetupPartitionSalvage(void *datap, int len);
182 struct InodeSummary *svgp_inodeSummaryp;
184 struct SalvInfo *svgp_salvinfo;
186 #endif /* AFS_NT40_ENV */
192 extern void Exit(int code) AFS_NORETURN;
193 extern int Fork(void);
194 extern int Wait(char *prog);
195 extern char *ToString(const char *s);
196 extern int AskDAFS(void);
197 extern void AskOffline(struct SalvInfo *salvinfo, VolumeId volumeId);
198 extern void AskOnline(struct SalvInfo *salvinfo, VolumeId volumeId);
199 extern void AskDelete(struct SalvInfo *salvinfo, VolumeId volumeId);
200 extern void CheckLogFile(char * log_path);
202 extern void TimeStampLogFile(char * log_path);
204 extern void ClearROInUseBit(struct VolumeSummary *summary);
205 extern void CopyAndSalvage(struct SalvInfo *salvinfo, struct DirSummary *dir);
206 extern int CopyInode(Device device, Inode inode1, Inode inode2, int rwvolume);
207 extern void CopyOnWrite(struct SalvInfo *salvinfo, struct DirSummary *dir);
208 extern void CountVolumeInodes(register struct ViceInodeInfo *ip, int maxInodes,
209 register struct InodeSummary *summary);
210 extern void DeleteExtraVolumeHeaderFile(struct SalvInfo *salvinfo,
211 struct VolumeSummary *vsp);
212 extern void DistilVnodeEssence(struct SalvInfo *salvinfo, VolumeId vid,
213 VnodeClass class, Inode ino, Unique * maxu);
214 extern int GetInodeSummary(struct SalvInfo *salvinfo, FD_t inodeFile,
215 VolumeId singleVolumeNumber);
216 extern int GetVolumeSummary(struct SalvInfo *salvinfo,
217 VolumeId singleVolumeNumber);
218 extern int JudgeEntry(void *dirVal, char *name, afs_int32 vnodeNumber,
220 extern void MaybeZapVolume(struct SalvInfo *salvinfo, struct InodeSummary *isp,
221 char *message, int deleteMe, int check);
222 extern void ObtainSalvageLock(void);
223 extern void ObtainSharedSalvageLock(void);
224 extern void PrintInodeList(struct SalvInfo *salvinfo);
225 extern void PrintInodeSummary(struct SalvInfo *salvinfo);
226 extern void PrintVolumeSummary(struct SalvInfo *salvinfo);
227 extern int QuickCheck(struct SalvInfo *salvinfo, struct InodeSummary *isp,
229 extern void RemoveTheForce(char *path);
230 extern void SalvageDir(struct SalvInfo *salvinfo, char *name, VolumeId rwVid,
231 struct VnodeInfo *dirVnodeInfo, IHandle_t * alinkH,
232 int i, struct DirSummary *rootdir, int *rootdirfound);
233 extern void SalvageFileSysParallel(struct DiskPartition64 *partP);
234 extern void SalvageFileSys(struct DiskPartition64 *partP, VolumeId singleVolumeNumber);
235 extern void SalvageFileSys1(struct DiskPartition64 *partP,
236 VolumeId singleVolumeNumber);
237 extern int SalvageHeader(struct SalvInfo *salvinfo, struct afs_inode_info *sp,
238 struct InodeSummary *isp, int check, int *deleteMe);
239 extern int SalvageIndex(struct SalvInfo *salvinfo, Inode ino, VnodeClass class,
240 int RW, struct ViceInodeInfo *ip, int nInodes,
241 struct VolumeSummary *volSummary, int check);
242 extern int SalvageVnodes(struct SalvInfo *salvinfo, struct InodeSummary *rwIsp,
243 struct InodeSummary *thisIsp,
244 struct ViceInodeInfo *inodes, int check);
245 extern int SalvageVolume(struct SalvInfo *salvinfo, struct InodeSummary *rwIsp,
247 extern void DoSalvageVolumeGroup(struct SalvInfo *salvinfo,
248 struct InodeSummary *isp, int nVols);
250 extern void nt_SalvageVolumeGroup(struct SalvInfo *salvinfo, struct InodeSummary *isp, int nVols);
252 extern int SalvageVolumeHeaderFile(struct SalvInfo *salvinfo,
253 struct InodeSummary *isp,
254 struct ViceInodeInfo *inodes, int RW,
255 int check, int *deleteMe);
256 extern void showlog(void);
257 extern int UseTheForceLuke(char *path);
261 #endif /* __vol_salvage_h_ */