dp->next = 0;
strcpy(dp->name, path);
#if defined(AFS_NAMEI_ENV) && !defined(AFS_NT40_ENV)
-#ifdef AFS_SUN5_ENV
- strcpy(dp->devName, devname);
-#else /* AFS_SUN5_ENV */
+ /* Create a lockfile for the partition, of the form /vicepa/Lock/vicepa */
strcpy(dp->devName, path);
-#endif
+ strcat(dp->devName, "/");
+ strcat(dp->devName, "Lock");
+ mkdir(dp->devName, 0700);
+ strcat(dp->devName, path);
+ close(open(dp->devName, O_RDWR | O_CREAT, 0600));
dp->device = volutil_GetPartitionID(path);
#else
strcpy(dp->devName, devname);
return 0;
}
+
+/* VIsAlwaysAttach() checks whether a /vicepX directory should always be
+ * attached (return value 1), or only attached when it is a separately
+ * mounted partition (return value 0). For non-NAMEI environments, it
+ * always returns 0.
+ */
+static int VIsAlwaysAttach(part)
+ char *part;
+{
+#ifdef AFS_NAMEI_ENV
+ struct stat st;
+ char checkfile[256];
+ int ret;
+
+ if (strncmp(part, VICE_PARTITION_PREFIX, VICE_PREFIX_SIZE))
+ return 0;
+
+ strncpy(checkfile, part, 100);
+ strcat(checkfile, "/");
+ strcat(checkfile, VICE_ALWAYSATTACH_FILE);
+
+ ret = stat(checkfile, &st);
+ return (ret < 0) ? 0 : 1;
+#else /* AFS_NAMEI_ENV */
+ return 0;
+#endif /* AFS_NAMEI_ENV */
+}
+
+/* VAttachPartitions2() looks for and attaches /vicepX partitions
+ * where a special file (VICE_ALWAYSATTACH_FILE) exists. This is
+ * used to attach /vicepX directories which aren't on dedicated
+ * partitions, in the NAMEI fileserver.
+ */
+void VAttachPartitions2() {
+#ifdef AFS_NAMEI_ENV
+ DIR *dirp;
+ struct dirent *de;
+ char pname[32];
+
+ dirp = opendir("/");
+ while (de = readdir(dirp)) {
+ strcpy(pname, "/");
+ strncat(pname, de->d_name, 20);
+ pname[sizeof(pname)-1] = '\0';
+
+ /* Only keep track of "/vicepx" partitions since automounter
+ may hose us */
+ if (VIsAlwaysAttach(pname))
+ VCheckPartition(pname, "");
+ }
+ closedir(dirp);
+#endif /* AFS_NAMEI_ENV */
+}
#endif /* AFS_NT40_ENV */
#ifdef AFS_SUN5_ENV
(strncmp(mnt.mnt_mntopts, "ro,ignore",9) ==0))
continue;
+ /* If we're going to always attach this partition, do it later. */
+ if (VIsAlwaysAttach(mnt.mnt_mountp))
+ continue;
+
if (VCheckPartition(mnt.mnt_mountp, mnt.mnt_special) < 0 )
errors ++;
}
- (void) fclose(mntfile);
+ (void) fclose(mntfile);
+
+ /* Process the always-attach partitions, if any. */
+ VAttachPartitions2();
return errors ;
}
while (mntent = getmntent(mfd)) {
if (!hasmntopt(mntent, MNTOPT_RW)) continue;
+ /* If we're going to always attach this partition, do it later. */
+ if (VIsAlwaysAttach(mntent->mnt_dir))
+ continue;
+
if (VCheckPartition(mntent->mnt_dir, mntent->mnt_fsname) < 0 )
errors ++;
}
endmntent(mfd);
+ /* Process the always-attach partitions, if any. */
+ VAttachPartitions2();
+
return errors ;
}
#endif
}
#endif
+ /* If we're going to always attach this partition, do it later. */
+ if (VIsAlwaysAttach(part))
+ continue;
+
if (VCheckPartition(part, vmt2dataptr(vmountp, VMT_OBJECT)) < 0 )
errors ++;
}
- return errors ;
+ /* Process the always-attach partitions, if any. */
+ VAttachPartitions2();
+
+ return errors ;
}
#endif
#if defined(AFS_DUX40_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
while (fsent = getfsent()) {
if (strcmp(fsent->fs_type, "rw") != 0) continue;
+ /* If we're going to always attach this partition, do it later. */
+ if (VIsAlwaysAttach(fsent->fs_file))
+ continue;
+
if (VCheckPartition(fsent->fs_file, fsent->fs_spec) < 0 )
errors ++;
}
endfsent();
+ /* Process the always-attach partitions, if any. */
+ VAttachPartitions2();
+
return errors ;
}
#endif
}
}
while (mntent = getmntent(mfd)) {
+ /* If we're going to always attach this partition, do it later. */
+ if (VIsAlwaysAttach(mntent->mnt_dir))
+ continue;
+
if (VCheckPartition(mntent->mnt_dir, mntent->mnt_fsname) < 0 )
errors ++;
}
endmntent(mfd);
+ /* Process the always-attach partitions, if any. */
+ VAttachPartitions2();
+
return errors ;
}
#endif /* AFS_LINUX22_ENV */
assert (lockf(dp->lock_fd, F_LOCK, 0) != -1);
#else
assert (flock(dp->lock_fd, LOCK_EX) == 0);
-#endif /* defined(AFS_AIX_ENV) */
+#endif /* defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV) */
#endif
}
struct pIDs *partIds;
{
char namehead[9];
- struct stat rbuf, pbuf;
int code;
char i;
strcpy(namehead, "/vicep"); /*7 including null terminator*/
-#ifdef AFS_NT40_ENV
/* Just return attached partitions. */
namehead[7] = '\0';
for (i=0; i<26; i++) {
if (VGetPartition(namehead, 0))
partIds->partIds[i] = VGetPartition(namehead, 0) ? i : -1;
}
-#else
-
- (void) stat("/",&rbuf); /*interested in buf->st_dev*/
-
- for(i = 0 ; i < 26 ; i++){
-
- namehead[6] = i + 'a';
- namehead[7] = '\0';
- code = stat(namehead,&pbuf);
- if(!code){
- if(rbuf.st_dev != pbuf.st_dev) /*the partition is mounted */
- partIds->partIds[i] = i ;
- else partIds->partIds[i ] = -1;
- }
- else partIds->partIds[i ] = -1;
- }
-#endif
+
return 0;
}
int code, i, j=0, k;
strcpy(namehead, "/vicep"); /*7 including null terminator*/
-#ifdef AFS_NT40_ENV
+
+ /* Only report attached partitions */
for(i = 0 ; i < VOLMAXPARTS; i++){
if (i < 26) {
namehead[6] = i + 'a';
pEntries->partEntries_val = (afs_int32 *) malloc(j * sizeof(int));
memcpy((char *)pEntries->partEntries_val, (char *)&partList, j * sizeof(int));
pEntries->partEntries_len = j;
-#else
- code = stat("/",&rbuf); /*interested in buf->st_dev*/
- for(i = 0 ; i < VOLMAXPARTS; i++){
- if (i < 26) {
- namehead[6] = i + 'a';
- namehead[7] = '\0';
- } else {
- k = i - 26;
- namehead[6] = 'a' + (k/26);
- namehead[7] = 'a' + (k%26);
- namehead[8] = '\0';
- }
- code = stat(namehead,&pbuf);
- if(!code){
- if(rbuf.st_dev != pbuf.st_dev) /*the partition is mounted */
- partList.partId[j++] = i;
- }
- }
- pEntries->partEntries_val = (afs_int32 *) malloc(j * sizeof(int));
- memcpy((char *)pEntries->partEntries_val, (char *)&partList, j * sizeof(int));
- pEntries->partEntries_len = j;
-#endif
return 0;
}