Print this page
6198 Let's EOL cachefs


   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.

  25  */
  26 
  27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
  28 /* All Rights Reserved */
  29 
  30 
  31 #include <stdio.h>
  32 #include <sys/types.h>
  33 #include <sys/stat.h>
  34 #include <archives.h>
  35 #include <errno.h>
  36 #include <fcntl.h>
  37 #include <limits.h>
  38 #include <stdlib.h>
  39 #include <unistd.h>
  40 #include <string.h>
  41 #include "pkglocale.h"
  42 #include "pkglibmsgs.h"
  43 
  44 /*


 328         FILE    *fp;
 329         char    line_buf[LINE_MAX];
 330 
 331         /* return if already initialized */
 332 
 333         if (numRemoteFstypes > 0) {
 334                 return;
 335         }
 336 
 337         /* if list is uninitialized, start with zero */
 338 
 339         if (numRemoteFstypes == -1) {
 340                 numRemoteFstypes = 0;
 341         }
 342 
 343         /* open the remote file system type database file */
 344 
 345         if ((fp = fopen(REMOTE_FS_DBFILE, "r")) == NULL) {
 346                 /* no remote type database: use predefined remote types */
 347                 remoteFstypes = (char **)realloc(remoteFstypes,
 348                                         sizeof (char *) * (numRemoteFstypes+3));
 349                 remoteFstypes[numRemoteFstypes++] = "nfs";      /* +1 */
 350                 remoteFstypes[numRemoteFstypes++] = "autofs";   /* +2 */
 351                 remoteFstypes[numRemoteFstypes++] = "cachefs";  /* +3 */
 352                 return;
 353         }
 354 
 355         /*
 356          * Read the remote file system type database; from fstypes(4):
 357          *
 358          * fstypes resides in directory /etc/dfs and lists distributed file
 359          * system utilities packages installed on the system. For each installed
 360          * distributed file system type, there is a line that begins with the
 361          * file system type name (for example, ``nfs''), followed by white space
 362          * and descriptive text.
 363          *
 364          * Lines will look at lot like this:
 365          *
 366          *      nfs NFS Utilities
 367          *      autofs AUTOFS Utilities
 368          *      cachefs CACHEFS Utilities
 369          */
 370 
 371         while (fgets(line_buf, sizeof (line_buf), fp) != NULL) {
 372                 char            buf[LINE_MAX];
 373                 static char     format[128] = {'\0'};
 374 
 375                 if (format[0] == '\0') {
 376                         /* create bounded format: %ns */
 377                         (void) snprintf(format, sizeof (format),
 378                                 "%%%ds", sizeof (buf)-1);
 379                 }
 380 
 381                 (void) sscanf(line_buf, format, buf);
 382 
 383                 remoteFstypes = realloc(remoteFstypes,
 384                                         sizeof (char *) * (numRemoteFstypes+1));
 385                 remoteFstypes[numRemoteFstypes++] = strdup(buf);
 386         }
 387 
 388         /* close database file and return */


   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
  26  */
  27 
  28 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
  29 /* All Rights Reserved */
  30 
  31 
  32 #include <stdio.h>
  33 #include <sys/types.h>
  34 #include <sys/stat.h>
  35 #include <archives.h>
  36 #include <errno.h>
  37 #include <fcntl.h>
  38 #include <limits.h>
  39 #include <stdlib.h>
  40 #include <unistd.h>
  41 #include <string.h>
  42 #include "pkglocale.h"
  43 #include "pkglibmsgs.h"
  44 
  45 /*


 329         FILE    *fp;
 330         char    line_buf[LINE_MAX];
 331 
 332         /* return if already initialized */
 333 
 334         if (numRemoteFstypes > 0) {
 335                 return;
 336         }
 337 
 338         /* if list is uninitialized, start with zero */
 339 
 340         if (numRemoteFstypes == -1) {
 341                 numRemoteFstypes = 0;
 342         }
 343 
 344         /* open the remote file system type database file */
 345 
 346         if ((fp = fopen(REMOTE_FS_DBFILE, "r")) == NULL) {
 347                 /* no remote type database: use predefined remote types */
 348                 remoteFstypes = (char **)realloc(remoteFstypes,
 349                     sizeof (char *) * (numRemoteFstypes+2));
 350                 remoteFstypes[numRemoteFstypes++] = "nfs";      /* +1 */
 351                 remoteFstypes[numRemoteFstypes++] = "autofs";   /* +2 */

 352                 return;
 353         }
 354 
 355         /*
 356          * Read the remote file system type database; from fstypes(4):
 357          *
 358          * fstypes resides in directory /etc/dfs and lists distributed file
 359          * system utilities packages installed on the system. For each installed
 360          * distributed file system type, there is a line that begins with the
 361          * file system type name (for example, ``nfs''), followed by white space
 362          * and descriptive text.
 363          *
 364          * Lines will look at lot like this:
 365          *
 366          *      nfs NFS Utilities
 367          *      autofs AUTOFS Utilities

 368          */
 369 
 370         while (fgets(line_buf, sizeof (line_buf), fp) != NULL) {
 371                 char            buf[LINE_MAX];
 372                 static char     format[128] = {'\0'};
 373 
 374                 if (format[0] == '\0') {
 375                         /* create bounded format: %ns */
 376                         (void) snprintf(format, sizeof (format),
 377                             "%%%ds", sizeof (buf)-1);
 378                 }
 379 
 380                 (void) sscanf(line_buf, format, buf);
 381 
 382                 remoteFstypes = realloc(remoteFstypes,
 383                     sizeof (char *) * (numRemoteFstypes+1));
 384                 remoteFstypes[numRemoteFstypes++] = strdup(buf);
 385         }
 386 
 387         /* close database file and return */