--- src/viced/viced.c 2001/08/08 00:04:21 1.11 +++ src/viced/viced.c 2001/09/19 22:51:17 @@ -349,6 +349,11 @@ } #endif confDir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH); + if (!confDir) { + fprintf(stderr, "Unable to open config directory %s\n", + AFSDIR_SERVER_ETC_DIRPATH); + exit(-1); + } NewParms(1); --- src/vol/namei_ops.c 2001/07/12 19:59:33 1.9 +++ src/vol/namei_ops.c 2001/09/19 22:51:18 @@ -204,6 +204,10 @@ char filename[32]; int fd; + /* Create the inode directory if we're starting for the first time */ + sprintf(filename, "%s/%s", partition, INODEDIR); + mkdir(filename, 0700); + sprintf(filename, "%s/%s/README", partition, INODEDIR); fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0444); if (fd >= 0) { --- src/vol/partition.c 2001/09/17 19:43:03 1.13 +++ src/vol/partition.c 2001/09/19 22:51:18 @@ -196,11 +196,13 @@ 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); @@ -312,6 +314,54 @@ 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; + + 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'; + + if (VIsAlwaysAttach(pname)) + VCheckPartition(pname, ""); + } + closedir(dirp); +#endif /* AFS_NAMEI_ENV */ +} #endif /* AFS_NT40_ENV */ #ifdef AFS_SUN5_ENV @@ -332,11 +382,18 @@ (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 ; } @@ -356,12 +413,19 @@ 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 @@ -449,11 +513,18 @@ } #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) @@ -470,11 +541,18 @@ 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 @@ -644,11 +722,18 @@ } } 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 */ @@ -1001,7 +1086,7 @@ 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 } --- src/vol/partition.h 2001/07/05 15:21:20 1.3 +++ src/vol/partition.h 2001/09/19 22:51:18 @@ -31,6 +31,15 @@ #define VICE_PARTITION_PREFIX "/vicep" #define VICE_PREFIX_SIZE (sizeof(VICE_PARTITION_PREFIX)-1) +/* If a file by this name exists in a /vicepX directory, it means that + * this directory should be used as an AFS partition even if it's not + * on a separate partition (for instance if it's part of a large /). + * This feature only works with the NAMEI fileserver. + */ +#ifdef AFS_NAMEI_ENV +#define VICE_ALWAYSATTACH_FILE "AlwaysAttach" +#endif + /* For NT, the roles of "name" and "devName" are reversed. That is, "name" * refers to the drive letter name and "devName" refers to the /vicep style * or name. The reason for this is that a lot of places assume that "name" --- src/volser/volprocs.c 2001/09/17 19:43:05 1.7 +++ src/volser/volprocs.c 2001/09/19 22:51:18 @@ -1585,13 +1585,11 @@ 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++) { @@ -1599,23 +1597,7 @@ 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; } @@ -1642,7 +1624,8 @@ 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'; @@ -1660,28 +1643,6 @@ 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; } --- NEWS 2001/09/11 06:56:23 1.4 +++ NEWS 2001/09/19 23:01:14 @@ -1,4 +1,12 @@ -Openafs News -- history of user Visible changes. 11 July 2001 +OpenAFS News -- history of user-visible changes. 19 September 2001 + +* Changes since OpenAFS 1.2.0 + +** AFS namei fileserver partitions don't have to be mountpoints anymore. + The existence of /vicepX/AlwaysAttach will cause that vice partition + to be attached. This allows the fileserver to use the space on the + root partition, or on any other existing partition (e.g. by use of + a /vicepX symlink). * Changes since OpenAFS 1.1.1