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
16 Institution: The Information Technology Center, Carnegie-Mellon University
20 #include <afs/param.h>
27 #include <sys/param.h>
28 #include <sys/types.h>
31 #include <sys/statvfs.h>
32 #endif /* AFS_HAVE_STATVFS */
33 #if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
34 #include <sys/mount.h>
37 #if !defined(AFS_SGI_ENV)
39 #include <sys/mount.h>
41 #else /* AFS_OSF_ENV */
42 #ifdef AFS_VFSINCL_ENV
45 #include <sys/fs/ufs_fs.h>
47 #if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
48 #include <ufs/ufs/dinode.h>
49 #include <ufs/ffs/fs.h>
54 #else /* AFS_VFSINCL_ENV */
55 #if !defined(AFS_AIX_ENV) && !defined(AFS_LINUX22_ENV) && !defined(AFS_DARWIN_ENV) && !defined(AFS_FBSD_ENV)
58 #endif /* AFS_VFSINCL_ENV */
59 #endif /* AFS_OSF_ENV */
60 #include <sys/errno.h>
66 #include <sys/lockf.h>
72 #include <checklist.h>
74 #if defined(AFS_SUN_ENV)
79 #include <sys/mnttab.h>
80 #include <sys/mntent.h>
82 #ifdef AFS_LINUX22_ENV
84 #include <sys/statfs.h>
91 #endif /* AFS_SGI_ENV */
92 #endif /* AFS_NT40_ENV */
93 #if defined(AFS_SGI_ENV)
94 #include <sys/errno.h>
102 #include <afs/afsint.h>
104 #include <afs/errors.h>
107 #include <afs/afssyscalls.h>
113 #include "namei_ops.h"
114 #if defined(AFS_SGI_ENV)
118 #endif /* AFS_SGI_ENV */
119 #endif /* AFS_NT40_ENV */
120 #endif /* AFS_NAMEI_ENV */
123 #include "partition.h"
124 #ifdef AFS_PTHREAD_ENV
126 #else /* AFS_PTHREAD_ENV */
127 #include <afs/assert.h>
128 #endif /* AFS_PTHREAD_ENV */
130 #if defined(AFS_HPUX_ENV)
131 #include <sys/types.h>
132 #include <sys/privgrp.h>
133 #endif /* defined(AFS_HPUX_ENV) */
136 #include <jfs/filsys.h>
139 int aixlow_water = 8; /* default 8% */
140 struct DiskPartition *DiskPartitionList;
142 #ifdef AFS_SGI_XFS_IOPS_ENV
143 /* Verify that the on disk XFS inodes on the partition are large enough to
144 * hold the AFS attribute. Returns -1 if the attribute can't be set or is
145 * too small to fit in the inode. Returns 0 if the attribute does fit in
148 #include <afs/xfsattrs.h>
149 static int VerifyXFSInodeSize(char *part, char *fstype)
152 int length = SIZEOF_XFS_ATTR_T;
157 if (strcmp("xfs", fstype))
160 if (attr_set(part, AFS_XFS_ATTR, &junk, length, ATTR_ROOT) == 0) {
161 if (((fd=open(part, O_RDONLY, 0)) != -1)
162 && (fcntl(fd, F_FSGETXATTRA, &fsx) == 0)) {
164 if (fsx.fsx_nextents) {
165 Log("Partition %s: XFS inodes too small, exiting.\n", part);
166 Log("Run xfs_size_check utility and remake partitions.\n");
174 (void) attr_remove(part, AFS_XFS_ATTR, ATTR_ROOT);
181 static void VInitPartition_r(char *path, char *devname, Device dev)
183 struct DiskPartition *dp, *op;
184 dp = (struct DiskPartition *) malloc(sizeof (struct DiskPartition));
185 /* Add it to the end, to preserve order when we print statistics */
186 for (op = DiskPartitionList; op; op = op->next) {
193 DiskPartitionList = dp;
195 strcpy(dp->name, path);
196 #if defined(AFS_NAMEI_ENV) && !defined(AFS_NT40_ENV)
198 strcpy(dp->devName, devname);
199 #else /* AFS_SUN5_ENV */
200 strcpy(dp->devName, path);
202 dp->device = volutil_GetPartitionID(path);
204 strcpy(dp->devName, devname);
209 dp->f_files = 1; /* just a default value */
210 #if defined(AFS_NAMEI_ENV) && !defined(AFS_NT40_ENV)
211 if (programType == fileServer)
212 (void) namei_ViceREADME(VPartitionPath(dp));
214 VSetPartitionDiskUsage_r(dp);
217 static void VInitPartition(char *path, char *devname, Device dev)
220 VInitPartition_r(path, devname, dev);
225 /* VAttachPartitions() finds the vice partitions on this server. Calls
226 * VCheckPartition() to do some basic checks on the partition. If the partition
227 * is a valid vice partition, VCheckPartition will add it to the DiskPartition
229 * Returns the number of errors returned by VCheckPartition. An error in
230 * VCheckPartition means that partition is a valid vice partition but the
231 * fileserver should not start because of the error found on that partition.
234 * No specific user space file system checks, since we don't know what
235 * is being used for vice partitions.
237 * Use partition name as devname.
239 int VCheckPartition(part, devname)
244 #if !defined(AFS_LINUX20_ENV) && !defined(AFS_NT40_ENV)
245 char AFSIDatPath[MAXPATHLEN];
248 /* Only keep track of "/vicepx" partitions since it can get hairy
249 * when NFS mounts are involved.. */
250 if (strncmp(part, VICE_PARTITION_PREFIX, VICE_PREFIX_SIZE)) {
253 if (stat(part, &status) < 0) {
254 Log("VInitVnodes: Couldn't find file system %s; ignored\n", part);
258 #ifndef AFS_AIX32_ENV
259 if (programType == fileServer) {
260 char salvpath[MAXPATHLEN];
261 strcpy(salvpath, part);
262 strcat(salvpath, "/FORCESALVAGE");
263 if (stat(salvpath, &status) == 0) {
264 Log("VInitVnodes: Found %s; aborting\n", salvpath);
270 #if !defined(AFS_LINUX20_ENV) && !defined(AFS_NT40_ENV)
271 strcpy(AFSIDatPath, part);
272 strcat(AFSIDatPath, "/AFSIDat");
274 if (stat(AFSIDatPath, &status) < 0) {
278 dirp = opendir(part);
280 while (dp = readdir(dirp)) {
281 if (dp->d_name[0] == 'V') {
282 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);
289 #else /* AFS_NAMEI_ENV */
290 if (stat(AFSIDatPath, &status) == 0) {
291 Log("This program is compiled without AFS_NAMEI_ENV, but partition %s seems to contain volumes which use the namei-interface; aborting\n", part);
294 #endif /* AFS_NAMEI_ENV */f
297 #ifdef AFS_SGI_XFS_IOPS_ENV
298 if (VerifyXFSInodeSize(part, status.st_fstype) < 0)
303 if (status.st_ino != ROOTINO) {
304 Log("%s is not a mounted file system; ignored.\n", part);
309 VInitPartition(part, devname, status.st_dev);
313 #endif /* AFS_NT40_ENV */
316 int VAttachPartitions(void)
322 if (!(mntfile = fopen(MNTTAB, "r"))) {
323 Log("Can't open %s\n", MNTTAB);
327 while (!getmntent(mntfile, &mnt)) {
328 /* Ignore non ufs or non read/write partitions */
329 if ((strcmp(mnt.mnt_fstype, "ufs") !=0) ||
330 (strncmp(mnt.mnt_mntopts, "ro,ignore",9) ==0))
333 if (VCheckPartition(mnt.mnt_mountp, mnt.mnt_special) < 0 )
337 (void) fclose(mntfile);
342 #endif /* AFS_SUN5_ENV */
343 #if defined(AFS_SGI_ENV) || (defined(AFS_SUN_ENV) && !defined(AFS_SUN5_ENV)) || defined(AFS_HPUX_ENV)
344 int VAttachPartitions(void)
348 struct mntent *mntent;
350 if ((mfd = setmntent(MOUNTED, "r")) == NULL) {
351 Log("Problems in getting mount entries(setmntent)\n");
354 while (mntent = getmntent(mfd)) {
355 if (!hasmntopt(mntent, MNTOPT_RW)) continue;
357 if (VCheckPartition(mntent->mnt_dir, mntent->mnt_fsname) < 0 )
368 * (This function was grabbed from df.c)
372 register struct vmount **vmountpp; /* place to tell where buffer is */
375 register struct vmount *vm;
378 /* set initial size of mntctl buffer to a MAGIC NUMBER */
381 /* try the operation until ok or a fatal error */
383 if ((vm = (struct vmount *)malloc(size)) == NULL) {
384 /* failed getting memory for mount status buf */
385 perror("FATAL ERROR: get_stat malloc failed\n");
390 * perform the QUERY mntctl - if it returns > 0, that is the
391 * number of vmount structures in the buffer. If it returns
392 * -1, an error occured. If it returned 0, then look in
393 * first word of buffer for needed size.
395 if ((nmounts = mntctl(MCTL_QUERY, size, (caddr_t)vm)) > 0) {
396 /* OK, got it, now return */
400 } else if (nmounts == 0) {
401 /* the buffer wasn't big enough .... */
402 /* .... get required buffer size */
407 /* some other kind of error occurred */
414 int VAttachPartitions(void)
418 struct vmount *vmountp;
420 if ((nmounts = getmount(&vmountp)) <= 0) {
421 Log("Problems in getting # of mount entries(getmount)\n");
424 for (; nmounts; nmounts--,
425 vmountp = (struct vmount *)((int)vmountp + vmountp->vmt_length)) {
426 char *part = vmt2dataptr(vmountp, VMT_STUB);
428 if (vmountp->vmt_flags & (MNT_READONLY|MNT_REMOVABLE|MNT_REMOTE))
429 continue; /* Ignore any "special" partitions */
433 struct superblock fs;
434 /* The Log statements are non-sequiters in the SalvageLog and don't
435 * even appear in the VolserLog, so restrict them to the FileLog.
437 if (ReadSuper(&fs, vmt2dataptr(vmountp, VMT_OBJECT))<0) {
438 if (programType == fileServer)
439 Log("Can't read superblock for %s, ignoring it.\n", part);
442 if (IsBigFilesFileSystem(&fs)) {
443 if (programType == fileServer)
444 Log("%s is a big files filesystem, ignoring it.\n", part);
450 if (VCheckPartition(part, vmt2dataptr(vmountp, VMT_OBJECT)) < 0 )
457 #if defined(AFS_DUX40_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
458 int VAttachPartitions(void)
463 if (setfsent() < 0) {
464 Log("Error listing filesystems.\n");
468 while (fsent = getfsent()) {
469 if (strcmp(fsent->fs_type, "rw") != 0) continue;
471 if (VCheckPartition(fsent->fs_file, fsent->fs_spec) < 0 )
482 #include <sys/stat.h>
485 * validate names in vptab.
492 int VValidVPTEntry(struct vptab *vpe)
494 int len = strlen(vpe->vp_name);
497 if (len < VICE_PREFIX_SIZE+1 || len > VICE_PREFIX_SIZE + 2)
499 if (strncmp(vpe->vp_name, VICE_PARTITION_PREFIX, VICE_PREFIX_SIZE))
502 for (i=VICE_PREFIX_SIZE; i<len; i++) {
503 if (vpe->vp_name[i] < 'a' || vpe->vp_name[i] > 'z') {
504 Log("Invalid partition name %s in registry, ignoring it.\n",
509 if (len == VICE_PREFIX_SIZE + 2) {
510 i = (int)(vpe->vp_name[VICE_PREFIX_SIZE]-'a') * 26 +
511 (int)(vpe->vp_name[VICE_PREFIX_SIZE+1]-'a') ;
513 Log("Invalid partition name %s in registry, ignoring it.\n",
519 len = strlen(vpe->vp_dev);
520 if (len != 2 || vpe->vp_dev[1] != ':' || vpe->vp_dev[0] < 'A' ||
521 vpe->vp_dev[0] > 'Z') {
522 Log("Invalid device name %s in registry, ignoring it.\n",
530 int VCheckPartition(char *partName)
537 /* partName is presumed to be of the form "X:" */
538 (void) sprintf(volRoot, "%c:\\", *partName);
540 if (!GetVolumeInformation(volRoot, /* volume root directory */
541 NULL, /* volume name buffer */
542 0, /* volume name size */
543 NULL, /* volume serial number */
544 &dwDummy, /* max component length */
545 &dwDummy, /* file system flags */
546 volFsType, /* file system name */
547 sizeof(volFsType))) {
548 err = GetLastError();
549 Log("VCheckPartition: Failed to get partition information for %s, ignoring it.\n",
554 if (strcmp(volFsType, "NTFS")) {
555 Log("VCheckPartition: Partition %s is not an NTFS partition, ignoring it.\n", partName);
563 int VAttachPartitions(void)
565 struct DiskPartition *partP, *prevP, *nextP;
566 struct vpt_iter iter;
569 if (vpt_Start(&iter)<0) {
570 Log("No partitions to attach.\n");
574 while (0==vpt_NextEntry(&iter, &entry)) {
575 if (!VValidVPTEntry(&entry)) {
579 /* This test for duplicates relies on the fact that the method
580 * of storing the partition names in the NT registry means the same
581 * partition name will never appear twice in the list.
583 for (partP = DiskPartitionList; partP; partP = partP->next) {
584 if (*partP->devName == *entry.vp_dev) {
585 Log("Same drive (%s) used for both partition %s and partition %s, ignoring both.\n", entry.vp_dev, partP->name, entry.vp_name);
586 partP->flags = PART_DUPLICATE;
587 break; /* Only one entry will ever be in this list. */
590 if (partP) continue; /* found a duplicate */
592 if (VCheckPartition(entry.vp_dev)<0)
594 /* This test allows for manually inserting the FORCESALVAGE flag
595 * and thereby invoking the salvager. scandisk obviously won't be
598 if (programType == fileServer) {
600 char salvpath[MAXPATHLEN];
601 strcpy(salvpath, entry.vp_dev);
602 strcat(salvpath, "\\FORCESALVAGE");
603 if (stat(salvpath, &status) == 0) {
604 Log("VAttachPartitions: Found %s; aborting\n", salvpath);
608 VInitPartition(entry.vp_name, entry.vp_dev, *entry.vp_dev - 'A');
612 /* Run through partition list and clear out the dupes. */
613 prevP = nextP = NULL;
614 for (partP = DiskPartitionList; partP; partP = nextP) {
616 if (partP->flags == PART_DUPLICATE) {
618 prevP->next = partP->next;
620 DiskPartitionList = partP->next;
631 #ifdef AFS_LINUX22_ENV
632 int VAttachPartitions(void)
636 struct mntent *mntent;
638 if ((mfd = setmntent("/proc/mounts", "r")) == NULL) {
639 if ((mfd = setmntent("/etc/mtab", "r")) == NULL) {
640 Log("Problems in getting mount entries(setmntent)\n");
644 while (mntent = getmntent(mfd)) {
645 if (VCheckPartition(mntent->mnt_dir, mntent->mnt_fsname) < 0 )
652 #endif /* AFS_LINUX22_ENV */
654 /* This routine is to be called whenever the actual name of the partition
655 * is required. The canonical name is still in part->name.
657 char * VPartitionPath(struct DiskPartition *part)
660 return part->devName;
666 /* get partition structure, abortp tells us if we should abort on failure */
667 struct DiskPartition *VGetPartition_r(char *name, int abortp)
669 register struct DiskPartition *dp;
670 for (dp = DiskPartitionList; dp; dp = dp->next) {
671 if (strcmp(dp->name, name) == 0)
679 struct DiskPartition *VGetPartition(char *name, int abortp)
681 struct DiskPartition *retVal;
683 retVal = VGetPartition_r(name, abortp);
689 void VSetPartitionDiskUsage_r(register struct DiskPartition *dp)
691 ULARGE_INTEGER free_user, total, free_total;
692 int ufree, tot, tfree;
694 if (!GetDiskFreeSpaceEx(VPartitionPath(dp), &free_user, &total,
696 printf("Failed to get disk space info for %s, error = %d\n",
697 dp->name, GetLastError());
701 /* Convert to 1K units. */
702 ufree = (int) Int64ShraMod32(free_user.QuadPart, 10);
703 tot = (int) Int64ShraMod32(total.QuadPart, 10);
704 tfree = (int) Int64ShraMod32(free_total.QuadPart, 10);
706 dp->minFree = tfree - ufree; /* only used in VPrintDiskStats_r */
707 dp->totalUsable = tot;
712 void VSetPartitionDiskUsage_r(register struct DiskPartition *dp)
715 int fd, totalblks, free, used, availblks, bsize, code;
718 struct statvfs statbuf;
720 struct statfs statbuf;
723 if (dp->flags & PART_DONTUPDATE)
725 /* Note: we don't bother syncing because it's only an estimate, update
726 is syncing every 30 seconds anyway, we only have to keep the disk
727 approximately 10% from full--you just can't get the stuff in from
728 the net fast enough to worry */
730 code = statvfs(dp->name, &statbuf);
732 code = statfs(dp->name, &statbuf);
735 Log("statfs of %s failed in VSetPartitionDiskUsage (errno = %d)\n", dp->name, errno);
738 if (statbuf.f_blocks == -1) { /* Undefined; skip stats.. */
739 Log("statfs of %s failed in VSetPartitionDiskUsage\n", dp->name);
742 totalblks = statbuf.f_blocks;
743 free = statbuf.f_bfree;
744 reserved = free - statbuf.f_bavail;
746 bsize = statbuf.f_frsize;
748 bsize = statbuf.f_bsize;
750 availblks = totalblks - reserved;
751 dp->f_files = statbuf.f_files; /* max # of files in partition */
753 /* Now free and totalblks are in fragment units, but we want them in
757 free *= (bsize/1024);
758 totalblks *= (bsize / 1024);
759 availblks *= (bsize / 1024 );
760 reserved *= (bsize / 1024 );
763 free /= (1024/bsize);
764 totalblks /= (1024/bsize);
765 availblks /= (1024/bsize);
766 reserved /= (1024/bsize);
768 /* now compute remaining figures */
769 used = totalblks - free;
771 dp->minFree = reserved; /* only used in VPrintDiskStats_r */
772 dp->totalUsable = availblks;
773 dp->free = availblks - used; /* this is exactly f_bavail */
775 #endif /* AFS_NT40_ENV */
777 void VSetPartitionDiskUsage(register struct DiskPartition *dp)
780 VSetPartitionDiskUsage_r(dp);
784 void VResetDiskUsage_r(void)
786 struct DiskPartition *dp;
787 for (dp = DiskPartitionList; dp; dp = dp->next) {
788 VSetPartitionDiskUsage_r(dp);
789 #ifndef AFS_PTHREAD_ENV
791 #endif /* !AFS_PTHREAD_ENV */
795 void VResetDiskUsage(void)
802 void VAdjustDiskUsage_r(Error *ec, Volume *vp, afs_int32 blocks, afs_int32 checkBlocks)
804 afs_int32 rem, minavail;
806 /* why blocks instead of checkBlocks in the check below? Otherwise, any check
807 for less than BlocksSpare would skip the error-checking path, and we
808 could grow existing files forever, not just for another BlocksSpare
812 if ((rem = vp->partition->free - checkBlocks) <
813 (minavail = (vp->partition->totalUsable * aixlow_water) / 100))
815 if (vp->partition->free - checkBlocks < 0)
818 else if (V_maxquota(vp) && V_diskused(vp) + checkBlocks > V_maxquota(vp))
821 vp->partition->free -= blocks;
822 V_diskused(vp) += blocks;
825 void VAdjustDiskUsage(Error *ec, Volume *vp, afs_int32 blocks, afs_int32 checkBlocks)
828 VAdjustDiskUsage_r(ec, vp, blocks, checkBlocks);
832 int VDiskUsage_r(Volume *vp, afs_int32 blocks)
834 afs_int32 rem, minavail;
837 if ((rem = vp->partition->free - blocks) <
838 (minavail = (vp->partition->totalUsable * aixlow_water) / 100))
840 if (vp->partition->free - blocks < 0)
844 vp->partition->free -= blocks;
848 int VDiskUsage(Volume *vp, afs_int32 blocks)
852 retVal = VDiskUsage_r(vp, blocks);
857 void VPrintDiskStats_r(void)
859 struct DiskPartition *dp;
860 for (dp = DiskPartitionList; dp; dp = dp->next) {
861 Log("Partition %s: %d available 1K blocks (minfree=%d), ",
862 dp->name, dp->totalUsable, dp->minFree);
864 Log("overallocated by %d blocks\n", -dp->free);
866 Log("%d free blocks\n", dp->free);
870 void VPrintDiskStats(void)
878 /* Need a separate lock file on NT, since NT only has mandatory file locks. */
879 #define LOCKFILE "LOCKFILE"
880 void VLockPartition_r(char *name)
882 struct DiskPartition *dp = VGetPartition_r(name, 0);
886 if (dp->lock_fd == -1) {
889 (void) sprintf(path, "%s\\%s", VPartitionPath(dp), LOCKFILE);
890 dp->lock_fd = (int)CreateFile(path, GENERIC_WRITE,
891 FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
892 CREATE_ALWAYS, FILE_ATTRIBUTE_HIDDEN, NULL);
893 assert (dp->lock_fd != (int)INVALID_HANDLE_VALUE);
895 memset((char*)&lap, 0, sizeof(lap));
896 rc = LockFileEx((HANDLE)dp->lock_fd, LOCKFILE_EXCLUSIVE_LOCK,
902 void VUnlockPartition_r(char *name)
904 register struct DiskPartition *dp = VGetPartition_r(name, 0);
907 if (!dp) return; /* no partition, will fail later */
908 memset((char*)&lap, 0, sizeof(lap));
910 UnlockFileEx((HANDLE)dp->lock_fd, 0, 1, 0, &lap);
911 CloseHandle((HANDLE)dp->lock_fd);
914 #else /* AFS_NT40_ENV */
916 #if defined(AFS_HPUX_ENV)
917 #define BITS_PER_CHAR (8)
918 #define BITS(type) (sizeof(type) * BITS_PER_CHAR)
920 #define LOCKRDONLY_OFFSET ((PRIV_LOCKRDONLY - 1) / BITS(int))
921 #endif /* defined(AFS_HPUX_ENV) */
923 void VLockPartition_r(char *name)
925 register struct DiskPartition *dp = VGetPartition_r(name, 0);
928 struct timeval pausing;
929 #if defined(AFS_HPUX_ENV)
931 struct privgrp_map privGrpList[PRIV_MAXGRPS];
932 unsigned int *globalMask;
934 #endif /* defined(AFS_HPUX_ENV) */
936 if (!dp) return; /* no partition, will fail later */
937 if (dp->lock_fd != -1) return;
939 #if defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV)
940 partitionName = dp->devName;
943 partitionName = dp->name;
947 for (retries=25; retries; retries--) {
948 dp->lock_fd = open(partitionName, code);
949 if (dp->lock_fd != -1) break;
951 pausing.tv_usec = 500000;
952 select(0, NULL, NULL, NULL, &pausing);
954 assert(retries != 0);
956 #if defined (AFS_HPUX_ENV)
958 assert(getprivgrp(privGrpList) == 0);
961 * In general, it will difficult and time-consuming ,if not impossible,
962 * to try to find the privgroup to which this process belongs that has the
963 * smallest membership, to minimise the security hole. So, we use the privgrp
964 * to which everybody belongs.
966 /* first, we have to find the global mask */
967 for (globalMaskIndex = 0; globalMaskIndex < PRIV_MAXGRPS;
969 if (privGrpList[globalMaskIndex].priv_groupno == PRIV_GLOBAL) {
970 globalMask = &(privGrpList[globalMaskIndex].
971 priv_mask[LOCKRDONLY_OFFSET]);
976 if (((*globalMask) & privmask(PRIV_LOCKRDONLY)) == 0) {
977 /* allow everybody to set a lock on a read-only file descriptor */
978 (*globalMask) |= privmask(PRIV_LOCKRDONLY);
979 assert(setprivgrp(PRIV_GLOBAL,
980 privGrpList[globalMaskIndex].priv_mask) == 0);
982 lockfRtn = lockf(dp->lock_fd, F_LOCK, 0);
984 /* remove the privilege granted to everybody to lock a read-only fd */
985 (*globalMask) &= ~(privmask(PRIV_LOCKRDONLY));
986 assert(setprivgrp(PRIV_GLOBAL,
987 privGrpList[globalMaskIndex].priv_mask) == 0);
990 /* in this case, we should be able to do this with impunity, anyway */
991 lockfRtn = lockf(dp->lock_fd, F_LOCK, 0);
994 assert (lockfRtn != -1);
996 #if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV)
997 assert (lockf(dp->lock_fd, F_LOCK, 0) != -1);
999 assert (flock(dp->lock_fd, LOCK_EX) == 0);
1000 #endif /* defined(AFS_AIX_ENV) */
1004 void VUnlockPartition_r(char *name)
1006 register struct DiskPartition *dp = VGetPartition_r(name, 0);
1007 if (!dp) return; /* no partition, will fail later */
1012 #endif /* AFS_NT40_ENV */
1014 void VLockPartition(char *name)
1017 VLockPartition_r(name);
1021 void VUnlockPartition(char *name)
1024 VUnlockPartition_r(name);