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
14 Institution: The Information Technology Center, Carnegie-Mellon University
18 #include <afs/param.h>
19 #include <afsconfig.h>
29 #include <sys/param.h>
30 #include <sys/types.h>
33 #include <sys/statvfs.h>
34 #endif /* AFS_HAVE_STATVFS */
35 #if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
36 #include <sys/mount.h>
39 #if !defined(AFS_SGI_ENV)
41 #include <sys/mount.h>
43 #else /* AFS_OSF_ENV */
44 #ifdef AFS_VFSINCL_ENV
47 #include <sys/fs/ufs_fs.h>
49 #if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
50 #include <ufs/ufs/dinode.h>
51 #include <ufs/ffs/fs.h>
56 #else /* AFS_VFSINCL_ENV */
57 #if !defined(AFS_AIX_ENV) && !defined(AFS_LINUX22_ENV) && !defined(AFS_DARWIN_ENV) && !defined(AFS_FBSD_ENV)
60 #endif /* AFS_VFSINCL_ENV */
61 #endif /* AFS_OSF_ENV */
62 #include <sys/errno.h>
68 #include <sys/lockf.h>
74 #include <checklist.h>
76 #if defined(AFS_SUN_ENV)
81 #include <sys/mnttab.h>
82 #include <sys/mntent.h>
84 #ifdef AFS_LINUX22_ENV
86 #include <sys/statfs.h>
93 #endif /* AFS_SGI_ENV */
94 #endif /* AFS_NT40_ENV */
95 #if defined(AFS_SGI_ENV)
96 #include <sys/errno.h>
104 #include <afs/afsint.h>
106 #include <afs/errors.h>
109 #include <afs/afssyscalls.h>
115 #include "namei_ops.h"
116 #if defined(AFS_SGI_ENV)
120 #endif /* AFS_SGI_ENV */
121 #endif /* AFS_NT40_ENV */
122 #endif /* AFS_NAMEI_ENV */
125 #include "partition.h"
126 #ifdef AFS_PTHREAD_ENV
128 #else /* AFS_PTHREAD_ENV */
129 #include <afs/assert.h>
130 #endif /* AFS_PTHREAD_ENV */
132 #if defined(AFS_HPUX_ENV)
133 #include <sys/types.h>
134 #include <sys/privgrp.h>
135 #endif /* defined(AFS_HPUX_ENV) */
138 #include <jfs/filsys.h>
141 int aixlow_water = 8; /* default 8% */
142 struct DiskPartition *DiskPartitionList;
144 #ifdef AFS_SGI_XFS_IOPS_ENV
145 /* Verify that the on disk XFS inodes on the partition are large enough to
146 * hold the AFS attribute. Returns -1 if the attribute can't be set or is
147 * too small to fit in the inode. Returns 0 if the attribute does fit in
150 #include <afs/xfsattrs.h>
151 static int VerifyXFSInodeSize(char *part, char *fstype)
154 int length = SIZEOF_XFS_ATTR_T;
159 if (strcmp("xfs", fstype))
162 if (attr_set(part, AFS_XFS_ATTR, &junk, length, ATTR_ROOT) == 0) {
163 if (((fd=open(part, O_RDONLY, 0)) != -1)
164 && (fcntl(fd, F_FSGETXATTRA, &fsx) == 0)) {
166 if (fsx.fsx_nextents) {
167 Log("Partition %s: XFS inodes too small, exiting.\n", part);
168 Log("Run xfs_size_check utility and remake partitions.\n");
176 (void) attr_remove(part, AFS_XFS_ATTR, ATTR_ROOT);
183 static void VInitPartition_r(char *path, char *devname, Device dev)
185 struct DiskPartition *dp, *op;
186 dp = (struct DiskPartition *) malloc(sizeof (struct DiskPartition));
187 /* Add it to the end, to preserve order when we print statistics */
188 for (op = DiskPartitionList; op; op = op->next) {
195 DiskPartitionList = dp;
197 strcpy(dp->name, path);
198 #if defined(AFS_NAMEI_ENV) && !defined(AFS_NT40_ENV)
200 strcpy(dp->devName, devname);
201 #else /* AFS_SUN5_ENV */
202 strcpy(dp->devName, path);
204 dp->device = volutil_GetPartitionID(path);
206 strcpy(dp->devName, devname);
211 dp->f_files = 1; /* just a default value */
212 #if defined(AFS_NAMEI_ENV) && !defined(AFS_NT40_ENV)
213 if (programType == fileServer)
214 (void) namei_ViceREADME(VPartitionPath(dp));
216 VSetPartitionDiskUsage_r(dp);
219 static void VInitPartition(char *path, char *devname, Device dev)
222 VInitPartition_r(path, devname, dev);
227 /* VAttachPartitions() finds the vice partitions on this server. Calls
228 * VCheckPartition() to do some basic checks on the partition. If the partition
229 * is a valid vice partition, VCheckPartition will add it to the DiskPartition
231 * Returns the number of errors returned by VCheckPartition. An error in
232 * VCheckPartition means that partition is a valid vice partition but the
233 * fileserver should not start because of the error found on that partition.
236 * No specific user space file system checks, since we don't know what
237 * is being used for vice partitions.
239 * Use partition name as devname.
241 int VCheckPartition(part, devname)
246 #if !defined(AFS_LINUX20_ENV) && !defined(AFS_NT40_ENV)
247 char AFSIDatPath[MAXPATHLEN];
250 /* Only keep track of "/vicepx" partitions since it can get hairy
251 * when NFS mounts are involved.. */
252 if (strncmp(part, VICE_PARTITION_PREFIX, VICE_PREFIX_SIZE)) {
255 if (stat(part, &status) < 0) {
256 Log("VInitVnodes: Couldn't find file system %s; ignored\n", part);
260 #ifndef AFS_AIX32_ENV
261 if (programType == fileServer) {
262 char salvpath[MAXPATHLEN];
263 strcpy(salvpath, part);
264 strcat(salvpath, "/FORCESALVAGE");
265 if (stat(salvpath, &status) == 0) {
266 Log("VInitVnodes: Found %s; aborting\n", salvpath);
272 #if !defined(AFS_LINUX20_ENV) && !defined(AFS_NT40_ENV)
273 strcpy(AFSIDatPath, part);
274 strcat(AFSIDatPath, "/AFSIDat");
276 if (stat(AFSIDatPath, &status) < 0) {
280 dirp = opendir(part);
282 while (dp = readdir(dirp)) {
283 if (dp->d_name[0] == 'V') {
284 Log("This program is compiled with AFS_NAMEI_ENV, but partition %s seems to contain volumes which don't use the namei-interface; aborting\n", part);
291 #else /* AFS_NAMEI_ENV */
292 if (stat(AFSIDatPath, &status) == 0) {
293 Log("This program is compiled without AFS_NAMEI_ENV, but partition %s seems to contain volumes which use the namei-interface; aborting\n", part);
296 #endif /* AFS_NAMEI_ENV */
299 #ifdef AFS_SGI_XFS_IOPS_ENV
300 if (VerifyXFSInodeSize(part, status.st_fstype) < 0)
305 if (status.st_ino != ROOTINO) {
306 Log("%s is not a mounted file system; ignored.\n", part);
311 VInitPartition(part, devname, status.st_dev);
315 #endif /* AFS_NT40_ENV */
318 int VAttachPartitions(void)
324 if (!(mntfile = fopen(MNTTAB, "r"))) {
325 Log("Can't open %s\n", MNTTAB);
329 while (!getmntent(mntfile, &mnt)) {
330 /* Ignore non ufs or non read/write partitions */
331 if ((strcmp(mnt.mnt_fstype, "ufs") !=0) ||
332 (strncmp(mnt.mnt_mntopts, "ro,ignore",9) ==0))
335 if (VCheckPartition(mnt.mnt_mountp, mnt.mnt_special) < 0 )
339 (void) fclose(mntfile);
344 #endif /* AFS_SUN5_ENV */
345 #if defined(AFS_SGI_ENV) || (defined(AFS_SUN_ENV) && !defined(AFS_SUN5_ENV)) || defined(AFS_HPUX_ENV)
346 int VAttachPartitions(void)
350 struct mntent *mntent;
352 if ((mfd = setmntent(MOUNTED, "r")) == NULL) {
353 Log("Problems in getting mount entries(setmntent)\n");
356 while (mntent = getmntent(mfd)) {
357 if (!hasmntopt(mntent, MNTOPT_RW)) continue;
359 if (VCheckPartition(mntent->mnt_dir, mntent->mnt_fsname) < 0 )
370 * (This function was grabbed from df.c)
374 register struct vmount **vmountpp; /* place to tell where buffer is */
377 register struct vmount *vm;
380 /* set initial size of mntctl buffer to a MAGIC NUMBER */
383 /* try the operation until ok or a fatal error */
385 if ((vm = (struct vmount *)malloc(size)) == NULL) {
386 /* failed getting memory for mount status buf */
387 perror("FATAL ERROR: get_stat malloc failed\n");
392 * perform the QUERY mntctl - if it returns > 0, that is the
393 * number of vmount structures in the buffer. If it returns
394 * -1, an error occured. If it returned 0, then look in
395 * first word of buffer for needed size.
397 if ((nmounts = mntctl(MCTL_QUERY, size, (caddr_t)vm)) > 0) {
398 /* OK, got it, now return */
402 } else if (nmounts == 0) {
403 /* the buffer wasn't big enough .... */
404 /* .... get required buffer size */
409 /* some other kind of error occurred */
416 int VAttachPartitions(void)
420 struct vmount *vmountp;
422 if ((nmounts = getmount(&vmountp)) <= 0) {
423 Log("Problems in getting # of mount entries(getmount)\n");
426 for (; nmounts; nmounts--,
427 vmountp = (struct vmount *)((int)vmountp + vmountp->vmt_length)) {
428 char *part = vmt2dataptr(vmountp, VMT_STUB);
430 if (vmountp->vmt_flags & (MNT_READONLY|MNT_REMOVABLE|MNT_REMOTE))
431 continue; /* Ignore any "special" partitions */
435 struct superblock fs;
436 /* The Log statements are non-sequiters in the SalvageLog and don't
437 * even appear in the VolserLog, so restrict them to the FileLog.
439 if (ReadSuper(&fs, vmt2dataptr(vmountp, VMT_OBJECT))<0) {
440 if (programType == fileServer)
441 Log("Can't read superblock for %s, ignoring it.\n", part);
444 if (IsBigFilesFileSystem(&fs)) {
445 if (programType == fileServer)
446 Log("%s is a big files filesystem, ignoring it.\n", part);
452 if (VCheckPartition(part, vmt2dataptr(vmountp, VMT_OBJECT)) < 0 )
459 #if defined(AFS_DUX40_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
460 int VAttachPartitions(void)
465 if (setfsent() < 0) {
466 Log("Error listing filesystems.\n");
470 while (fsent = getfsent()) {
471 if (strcmp(fsent->fs_type, "rw") != 0) continue;
473 if (VCheckPartition(fsent->fs_file, fsent->fs_spec) < 0 )
484 #include <sys/stat.h>
487 * validate names in vptab.
494 int VValidVPTEntry(struct vptab *vpe)
496 int len = strlen(vpe->vp_name);
499 if (len < VICE_PREFIX_SIZE+1 || len > VICE_PREFIX_SIZE + 2)
501 if (strncmp(vpe->vp_name, VICE_PARTITION_PREFIX, VICE_PREFIX_SIZE))
504 for (i=VICE_PREFIX_SIZE; i<len; i++) {
505 if (vpe->vp_name[i] < 'a' || vpe->vp_name[i] > 'z') {
506 Log("Invalid partition name %s in registry, ignoring it.\n",
511 if (len == VICE_PREFIX_SIZE + 2) {
512 i = (int)(vpe->vp_name[VICE_PREFIX_SIZE]-'a') * 26 +
513 (int)(vpe->vp_name[VICE_PREFIX_SIZE+1]-'a') ;
515 Log("Invalid partition name %s in registry, ignoring it.\n",
521 len = strlen(vpe->vp_dev);
522 if (len != 2 || vpe->vp_dev[1] != ':' || vpe->vp_dev[0] < 'A' ||
523 vpe->vp_dev[0] > 'Z') {
524 Log("Invalid device name %s in registry, ignoring it.\n",
532 int VCheckPartition(char *partName)
539 /* partName is presumed to be of the form "X:" */
540 (void) sprintf(volRoot, "%c:\\", *partName);
542 if (!GetVolumeInformation(volRoot, /* volume root directory */
543 NULL, /* volume name buffer */
544 0, /* volume name size */
545 NULL, /* volume serial number */
546 &dwDummy, /* max component length */
547 &dwDummy, /* file system flags */
548 volFsType, /* file system name */
549 sizeof(volFsType))) {
550 err = GetLastError();
551 Log("VCheckPartition: Failed to get partition information for %s, ignoring it.\n",
556 if (strcmp(volFsType, "NTFS")) {
557 Log("VCheckPartition: Partition %s is not an NTFS partition, ignoring it.\n", partName);
565 int VAttachPartitions(void)
567 struct DiskPartition *partP, *prevP, *nextP;
568 struct vpt_iter iter;
571 if (vpt_Start(&iter)<0) {
572 Log("No partitions to attach.\n");
576 while (0==vpt_NextEntry(&iter, &entry)) {
577 if (!VValidVPTEntry(&entry)) {
581 /* This test for duplicates relies on the fact that the method
582 * of storing the partition names in the NT registry means the same
583 * partition name will never appear twice in the list.
585 for (partP = DiskPartitionList; partP; partP = partP->next) {
586 if (*partP->devName == *entry.vp_dev) {
587 Log("Same drive (%s) used for both partition %s and partition %s, ignoring both.\n", entry.vp_dev, partP->name, entry.vp_name);
588 partP->flags = PART_DUPLICATE;
589 break; /* Only one entry will ever be in this list. */
592 if (partP) continue; /* found a duplicate */
594 if (VCheckPartition(entry.vp_dev)<0)
596 /* This test allows for manually inserting the FORCESALVAGE flag
597 * and thereby invoking the salvager. scandisk obviously won't be
600 if (programType == fileServer) {
602 char salvpath[MAXPATHLEN];
603 strcpy(salvpath, entry.vp_dev);
604 strcat(salvpath, "\\FORCESALVAGE");
605 if (stat(salvpath, &status) == 0) {
606 Log("VAttachPartitions: Found %s; aborting\n", salvpath);
610 VInitPartition(entry.vp_name, entry.vp_dev, *entry.vp_dev - 'A');
614 /* Run through partition list and clear out the dupes. */
615 prevP = nextP = NULL;
616 for (partP = DiskPartitionList; partP; partP = nextP) {
618 if (partP->flags == PART_DUPLICATE) {
620 prevP->next = partP->next;
622 DiskPartitionList = partP->next;
633 #ifdef AFS_LINUX22_ENV
634 int VAttachPartitions(void)
638 struct mntent *mntent;
640 if ((mfd = setmntent("/proc/mounts", "r")) == NULL) {
641 if ((mfd = setmntent("/etc/mtab", "r")) == NULL) {
642 Log("Problems in getting mount entries(setmntent)\n");
646 while (mntent = getmntent(mfd)) {
647 if (VCheckPartition(mntent->mnt_dir, mntent->mnt_fsname) < 0 )
654 #endif /* AFS_LINUX22_ENV */
656 /* This routine is to be called whenever the actual name of the partition
657 * is required. The canonical name is still in part->name.
659 char * VPartitionPath(struct DiskPartition *part)
662 return part->devName;
668 /* get partition structure, abortp tells us if we should abort on failure */
669 struct DiskPartition *VGetPartition_r(char *name, int abortp)
671 register struct DiskPartition *dp;
672 for (dp = DiskPartitionList; dp; dp = dp->next) {
673 if (strcmp(dp->name, name) == 0)
681 struct DiskPartition *VGetPartition(char *name, int abortp)
683 struct DiskPartition *retVal;
685 retVal = VGetPartition_r(name, abortp);
691 void VSetPartitionDiskUsage_r(register struct DiskPartition *dp)
693 ULARGE_INTEGER free_user, total, free_total;
694 int ufree, tot, tfree;
696 if (!GetDiskFreeSpaceEx(VPartitionPath(dp), &free_user, &total,
698 printf("Failed to get disk space info for %s, error = %d\n",
699 dp->name, GetLastError());
703 /* Convert to 1K units. */
704 ufree = (int) Int64ShraMod32(free_user.QuadPart, 10);
705 tot = (int) Int64ShraMod32(total.QuadPart, 10);
706 tfree = (int) Int64ShraMod32(free_total.QuadPart, 10);
708 dp->minFree = tfree - ufree; /* only used in VPrintDiskStats_r */
709 dp->totalUsable = tot;
714 void VSetPartitionDiskUsage_r(register struct DiskPartition *dp)
717 int fd, totalblks, free, used, availblks, bsize, code;
720 struct statvfs statbuf;
722 struct statfs statbuf;
725 if (dp->flags & PART_DONTUPDATE)
727 /* Note: we don't bother syncing because it's only an estimate, update
728 is syncing every 30 seconds anyway, we only have to keep the disk
729 approximately 10% from full--you just can't get the stuff in from
730 the net fast enough to worry */
732 code = statvfs(dp->name, &statbuf);
734 code = statfs(dp->name, &statbuf);
737 Log("statfs of %s failed in VSetPartitionDiskUsage (errno = %d)\n", dp->name, errno);
740 if (statbuf.f_blocks == -1) { /* Undefined; skip stats.. */
741 Log("statfs of %s failed in VSetPartitionDiskUsage\n", dp->name);
744 totalblks = statbuf.f_blocks;
745 free = statbuf.f_bfree;
746 reserved = free - statbuf.f_bavail;
748 bsize = statbuf.f_frsize;
750 bsize = statbuf.f_bsize;
752 availblks = totalblks - reserved;
753 dp->f_files = statbuf.f_files; /* max # of files in partition */
755 /* Now free and totalblks are in fragment units, but we want them in
759 free *= (bsize/1024);
760 totalblks *= (bsize / 1024);
761 availblks *= (bsize / 1024 );
762 reserved *= (bsize / 1024 );
765 free /= (1024/bsize);
766 totalblks /= (1024/bsize);
767 availblks /= (1024/bsize);
768 reserved /= (1024/bsize);
770 /* now compute remaining figures */
771 used = totalblks - free;
773 dp->minFree = reserved; /* only used in VPrintDiskStats_r */
774 dp->totalUsable = availblks;
775 dp->free = availblks - used; /* this is exactly f_bavail */
777 #endif /* AFS_NT40_ENV */
779 void VSetPartitionDiskUsage(register struct DiskPartition *dp)
782 VSetPartitionDiskUsage_r(dp);
786 void VResetDiskUsage_r(void)
788 struct DiskPartition *dp;
789 for (dp = DiskPartitionList; dp; dp = dp->next) {
790 VSetPartitionDiskUsage_r(dp);
791 #ifndef AFS_PTHREAD_ENV
793 #endif /* !AFS_PTHREAD_ENV */
797 void VResetDiskUsage(void)
804 void VAdjustDiskUsage_r(Error *ec, Volume *vp, afs_int32 blocks, afs_int32 checkBlocks)
806 afs_int32 rem, minavail;
808 /* why blocks instead of checkBlocks in the check below? Otherwise, any check
809 for less than BlocksSpare would skip the error-checking path, and we
810 could grow existing files forever, not just for another BlocksSpare
814 if ((rem = vp->partition->free - checkBlocks) <
815 (minavail = (vp->partition->totalUsable * aixlow_water) / 100))
817 if (vp->partition->free - checkBlocks < 0)
820 else if (V_maxquota(vp) && V_diskused(vp) + checkBlocks > V_maxquota(vp))
823 vp->partition->free -= blocks;
824 V_diskused(vp) += blocks;
827 void VAdjustDiskUsage(Error *ec, Volume *vp, afs_int32 blocks, afs_int32 checkBlocks)
830 VAdjustDiskUsage_r(ec, vp, blocks, checkBlocks);
834 int VDiskUsage_r(Volume *vp, afs_int32 blocks)
836 afs_int32 rem, minavail;
839 if ((rem = vp->partition->free - blocks) <
840 (minavail = (vp->partition->totalUsable * aixlow_water) / 100))
842 if (vp->partition->free - blocks < 0)
846 vp->partition->free -= blocks;
850 int VDiskUsage(Volume *vp, afs_int32 blocks)
854 retVal = VDiskUsage_r(vp, blocks);
859 void VPrintDiskStats_r(void)
861 struct DiskPartition *dp;
862 for (dp = DiskPartitionList; dp; dp = dp->next) {
863 Log("Partition %s: %d available 1K blocks (minfree=%d), ",
864 dp->name, dp->totalUsable, dp->minFree);
866 Log("overallocated by %d blocks\n", -dp->free);
868 Log("%d free blocks\n", dp->free);
872 void VPrintDiskStats(void)
880 /* Need a separate lock file on NT, since NT only has mandatory file locks. */
881 #define LOCKFILE "LOCKFILE"
882 void VLockPartition_r(char *name)
884 struct DiskPartition *dp = VGetPartition_r(name, 0);
888 if (dp->lock_fd == -1) {
891 (void) sprintf(path, "%s\\%s", VPartitionPath(dp), LOCKFILE);
892 dp->lock_fd = (int)CreateFile(path, GENERIC_WRITE,
893 FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
894 CREATE_ALWAYS, FILE_ATTRIBUTE_HIDDEN, NULL);
895 assert (dp->lock_fd != (int)INVALID_HANDLE_VALUE);
897 memset((char*)&lap, 0, sizeof(lap));
898 rc = LockFileEx((HANDLE)dp->lock_fd, LOCKFILE_EXCLUSIVE_LOCK,
904 void VUnlockPartition_r(char *name)
906 register struct DiskPartition *dp = VGetPartition_r(name, 0);
909 if (!dp) return; /* no partition, will fail later */
910 memset((char*)&lap, 0, sizeof(lap));
912 UnlockFileEx((HANDLE)dp->lock_fd, 0, 1, 0, &lap);
913 CloseHandle((HANDLE)dp->lock_fd);
916 #else /* AFS_NT40_ENV */
918 #if defined(AFS_HPUX_ENV)
919 #define BITS_PER_CHAR (8)
920 #define BITS(type) (sizeof(type) * BITS_PER_CHAR)
922 #define LOCKRDONLY_OFFSET ((PRIV_LOCKRDONLY - 1) / BITS(int))
923 #endif /* defined(AFS_HPUX_ENV) */
925 void VLockPartition_r(char *name)
927 register struct DiskPartition *dp = VGetPartition_r(name, 0);
930 struct timeval pausing;
931 #if defined(AFS_HPUX_ENV)
933 struct privgrp_map privGrpList[PRIV_MAXGRPS];
934 unsigned int *globalMask;
936 #endif /* defined(AFS_HPUX_ENV) */
938 if (!dp) return; /* no partition, will fail later */
939 if (dp->lock_fd != -1) return;
941 #if defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV)
942 partitionName = dp->devName;
945 partitionName = dp->name;
949 for (retries=25; retries; retries--) {
950 dp->lock_fd = open(partitionName, code);
951 if (dp->lock_fd != -1) break;
953 pausing.tv_usec = 500000;
954 select(0, NULL, NULL, NULL, &pausing);
956 assert(retries != 0);
958 #if defined (AFS_HPUX_ENV)
960 assert(getprivgrp(privGrpList) == 0);
963 * In general, it will difficult and time-consuming ,if not impossible,
964 * to try to find the privgroup to which this process belongs that has the
965 * smallest membership, to minimise the security hole. So, we use the privgrp
966 * to which everybody belongs.
968 /* first, we have to find the global mask */
969 for (globalMaskIndex = 0; globalMaskIndex < PRIV_MAXGRPS;
971 if (privGrpList[globalMaskIndex].priv_groupno == PRIV_GLOBAL) {
972 globalMask = &(privGrpList[globalMaskIndex].
973 priv_mask[LOCKRDONLY_OFFSET]);
978 if (((*globalMask) & privmask(PRIV_LOCKRDONLY)) == 0) {
979 /* allow everybody to set a lock on a read-only file descriptor */
980 (*globalMask) |= privmask(PRIV_LOCKRDONLY);
981 assert(setprivgrp(PRIV_GLOBAL,
982 privGrpList[globalMaskIndex].priv_mask) == 0);
984 lockfRtn = lockf(dp->lock_fd, F_LOCK, 0);
986 /* remove the privilege granted to everybody to lock a read-only fd */
987 (*globalMask) &= ~(privmask(PRIV_LOCKRDONLY));
988 assert(setprivgrp(PRIV_GLOBAL,
989 privGrpList[globalMaskIndex].priv_mask) == 0);
992 /* in this case, we should be able to do this with impunity, anyway */
993 lockfRtn = lockf(dp->lock_fd, F_LOCK, 0);
996 assert (lockfRtn != -1);
998 #if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV)
999 assert (lockf(dp->lock_fd, F_LOCK, 0) != -1);
1001 assert (flock(dp->lock_fd, LOCK_EX) == 0);
1002 #endif /* defined(AFS_AIX_ENV) */
1006 void VUnlockPartition_r(char *name)
1008 register struct DiskPartition *dp = VGetPartition_r(name, 0);
1009 if (!dp) return; /* no partition, will fail later */
1014 #endif /* AFS_NT40_ENV */
1016 void VLockPartition(char *name)
1019 VLockPartition_r(name);
1023 void VUnlockPartition(char *name)
1026 VUnlockPartition_r(name);