17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 22*96ca3711SMarcel Telka 23*96ca3711SMarcel Telka /* 24*96ca3711SMarcel Telka * Copyright 2015 Nexenta Systems, Inc. All rights reserved. 25*96ca3711SMarcel Telka */ 26*96ca3711SMarcel Telka 277c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990, 1991, 1997 SMI */ 287c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #include <stdio.h> 317c478bd9Sstevel@tonic-gate #include <deflt.h> 327c478bd9Sstevel@tonic-gate #include <string.h> 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #define LOCAL "/etc/default/fs" 357c478bd9Sstevel@tonic-gate #define REMOTE "/etc/dfs/fstypes" 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate /* 387c478bd9Sstevel@tonic-gate * This is used to figure out the default file system type if "-F FStype" 397c478bd9Sstevel@tonic-gate * is not specified with the file system command and no entry in the 407c478bd9Sstevel@tonic-gate * /etc/vfstab matches the specified special. 417c478bd9Sstevel@tonic-gate * If the first character of the "special" is a "/" (eg, "/dev/dsk/c0d1s2"), 427c478bd9Sstevel@tonic-gate * returns the default local filesystem type. 437c478bd9Sstevel@tonic-gate * Otherwise (eg, "server:/path/name" or "resource"), returns the default 447c478bd9Sstevel@tonic-gate * remote filesystem type. 457c478bd9Sstevel@tonic-gate */ 467c478bd9Sstevel@tonic-gate char * 477c478bd9Sstevel@tonic-gate default_fstype(char *special) 487c478bd9Sstevel@tonic-gate { 49*96ca3711SMarcel Telka char *deffs = NULL; 507c478bd9Sstevel@tonic-gate static char buf[BUFSIZ]; 517c478bd9Sstevel@tonic-gate FILE *fp; 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate if (*special == '/') { 54*96ca3711SMarcel Telka if (defopen(LOCAL) == 0) { 55*96ca3711SMarcel Telka deffs = defread("LOCAL="); 567c478bd9Sstevel@tonic-gate defopen(NULL); /* close default file */ 577c478bd9Sstevel@tonic-gate } 587c478bd9Sstevel@tonic-gate } else { 59*96ca3711SMarcel Telka if ((fp = fopen(REMOTE, "r")) != NULL) { 60*96ca3711SMarcel Telka if (fgets(buf, sizeof (buf), fp) != NULL) 617c478bd9Sstevel@tonic-gate deffs = strtok(buf, " \t\n"); 627c478bd9Sstevel@tonic-gate fclose(fp); 637c478bd9Sstevel@tonic-gate } 64*96ca3711SMarcel Telka if (deffs == NULL) 65*96ca3711SMarcel Telka deffs = "nfs"; 667c478bd9Sstevel@tonic-gate } 67*96ca3711SMarcel Telka 68*96ca3711SMarcel Telka return (deffs != NULL ? deffs : "ufs"); 697c478bd9Sstevel@tonic-gate } 70