Print this page
6063 pkgadd breaks with too many mountpoints


 199         if (mktemp(testfile) == NULL)
 200                 return (0);     /* may as well be read-only */
 201         /* LINTED do not use creat(); use open(path,... */
 202         else if ((fd = creat(testfile, 0777)) == -1)
 203                 return (0);     /* can't write */
 204         else if (fstat(fd, &status) == -1)
 205                 retval = 0;     /* may as well be read-only */
 206         else if (status.st_uid != 0)
 207                 retval = 0;     /* too many restrictions */
 208         else
 209                 retval = 1;
 210 
 211         (void) close(fd);
 212         (void) unlink(testfile);
 213 
 214         return (retval);
 215 }
 216 
 217 /* This returns the hostname portion of a remote path. */
 218 char *
 219 get_server_host(short n)
 220 {
 221         static char hostname[HOST_NM_LN], *host_end;
 222 
 223         if (fs_tab_used == 0) {
 224                 return ("unknown source");
 225         }
 226 
 227         if (n >= 0 && n < fs_tab_used) {
 228                 (void) strcpy(hostname, fs_tab[n]->remote_name);
 229                 if ((host_end = strchr(hostname, ':')) == NULL) {
 230                         if ((strcmp(fs_tab[n]->fstype, MNTTYPE_AUTO)) == NULL)
 231                                 return ("automounter");
 232                         else
 233                                 return (fs_tab[n]->fstype);
 234                 } else {
 235                         *host_end = '\0';
 236                         return (hostname);
 237                 }
 238         }
 239 
 240         return ("unknown source");
 241 }
 242 
 243 /*
 244  * This pulls the path out of a hostpath which may be of the form host:path
 245  * where path is an absolute path. NOTE: If path turns out to be relative,
 246  * this returns NULL.
 247  */


 549                                 /* close all file descriptors except stdio */
 550 
 551                                 closefrom(3);
 552 
 553                                 exit_no = execve(arg[0], arg, environ);
 554                                 _exit(exit_no);
 555                                 /*NOTREACHED*/
 556                         }
 557                 }
 558         }
 559         return (retcode);
 560 }
 561 
 562 /*
 563  * This function maps path, on a loopback filesystem, back to the real server
 564  * filesystem. fsys_value is the fs_tab[] entry to which the loopback'd path is
 565  * mapped. This returns a pointer to a static area. If the result is needed
 566  * for further processing, it should be strdup()'d or something.
 567  */
 568 char *
 569 server_map(char *path, short fsys_value)
 570 {
 571         static char server_construction[PATH_MAX];
 572 
 573         if (fs_tab_used == 0) {
 574                 (void) strcpy(server_construction, path);
 575         } else if (fsys_value >= 0 && fsys_value < fs_tab_used) {
 576                 (void) snprintf(server_construction,
 577                         sizeof (server_construction),
 578                         "%s%s", fs_tab[fsys_value]->remote_name,
 579                         path+strlen(fs_tab[fsys_value]->name));
 580         } else {
 581                 (void) strcpy(server_construction, path);
 582         }
 583 
 584         return (server_construction);
 585 }
 586 
 587 /* This function sets up the standard parts of the fs_tab. */
 588 static struct fstable *
 589 fs_tab_init(char *mountp, char *fstype)
 590 {
 591         struct fstable *nfte;
 592 
 593         /* Create the array if necessary. */
 594         if (fs_list == -1) {
 595                 fs_list = ar_create(ALLOC_CHUNK,


1034 
1035         /*
1036          * Allocate space for the 'special' name.
1037          */
1038         if ((nfte->remote_name = malloc(strlen(remote_name)+1)) == NULL) {
1039                 progerr(ERR_MALLOC, "remote_name", errno, strerror(errno));
1040                 return (1);
1041         }
1042 
1043         (void) strcpy(nfte->remote_name, remote_name);
1044 
1045         return (0);
1046 }
1047 
1048 /*
1049  * Given a path, return the table index of the filesystem the file apparently
1050  * resides on. This doesn't put any time into resolving filesystems that
1051  * refer to other filesystems. It just returns the entry containing this
1052  * path.
1053  */
1054 short
1055 fsys(char *path)
1056 {
1057         register int i;
1058         char    real_path[PATH_MAX];
1059         char    path_copy[PATH_MAX];
1060         char    *path2use;
1061         char    *cp;
1062         int     pathlen;
1063         boolean_t found = B_FALSE;
1064 
1065         /*
1066          * The loop below represents our best effort to identify real path of
1067          * a file, which doesn't need to exist. realpath() returns error for
1068          * nonexistent path, therefore we need to cut off trailing components
1069          * of path until we get path which exists and can be resolved by
1070          * realpath(). Lookup of "/dir/symlink/nonexistent-file" would fail
1071          * to resolve symlink without this.
1072          */
1073         (void) strlcpy(path_copy, path, PATH_MAX);
1074         for (cp = dirname(path_copy); strlen(cp) > 1; cp = dirname(cp)) {


1130                     ((term_char == '/' || term_char == NULL) &&
1131                     strncmp(fs_tab[i]->name, path2use, fs_namelen) == 0))
1132                         return (i);
1133         }
1134 
1135         /*
1136          * It only gets here if the root filesystem is fundamentally corrupt.
1137          * (This can happen!)
1138          */
1139         progerr(ERR_FSYS_FELLOUT, path2use);
1140 
1141         return (-1);
1142 }
1143 
1144 /*
1145  * This function returns the entry in the fs_tab[] corresponding to the
1146  * actual filesystem of record. It won't return a loopback filesystem entry,
1147  * it will return the filesystem that the loopback filesystem is mounted
1148  * over.
1149  */
1150 short
1151 resolved_fsys(char *path)
1152 {
1153         int i = -1;
1154         char path2use[PATH_MAX];
1155 
1156         (void) strcpy(path2use, path);
1157 
1158         /* If this isn't a "real" filesystem, resolve the map. */
1159         do {
1160                 (void) strcpy(path2use, server_map(path2use, i));
1161                 i = fsys(path2use);
1162         } while (fs_tab[i]->srvr_map);
1163 
1164         return (i);
1165 }
1166 
1167 /*
1168  * This function returns the srvr_map status based upon the fs_tab entry
1169  * number. This tells us if the server path constructed from the package
1170  * install root is really the target filesystem.
1171  */
1172 int
1173 use_srvr_map_n(short n)
1174 {
1175         return ((int)fs_tab[n]->srvr_map);
1176 }
1177 
1178 /*
1179  * This function returns the mount status based upon the fs_tab entry
1180  * number. This tells us if there is any hope of gaining access
1181  * to this file system.
1182  */
1183 int
1184 is_mounted_n(short n)
1185 {
1186         return ((int)fs_tab[n]->mounted);
1187 }
1188 
1189 /*
1190  * is_fs_writeable_n - given an fstab index, return 1
1191  *      if it's writeable, 0 if read-only.
1192  */
1193 int
1194 is_fs_writeable_n(short n)
1195 {
1196         /*
1197          * If the write access permissions haven't been confirmed, do that
1198          * now. Note that the only reason we need to do the special check is
1199          * in the case of an NFS mount (remote) because we can't determine if
1200          * root has access in any other way.
1201          */
1202         if (fs_tab[n]->remote && fs_tab[n]->mounted &&
1203             !fs_tab[n]->write_tested) {
1204                 if (fs_tab[n]->writeable && !really_write(fs_tab[n]->name))
1205                         fs_tab[n]->writeable = 0;    /* not really */
1206 
1207                 fs_tab[n]->write_tested = 1; /* confirmed */
1208         }
1209 
1210         return ((int)fs_tab[n]->writeable);
1211 }
1212 
1213 /*
1214  * is_remote_fs_n - given an fstab index, return 1
1215  *      if it's a remote filesystem, 0 if local.
1216  *
1217  *      Note: Upon entry, a valid fsys() is required.
1218  */
1219 int
1220 is_remote_fs_n(short n)
1221 {
1222         return ((int)fs_tab[n]->remote);
1223 }
1224 
1225 /* index-driven is_served() */
1226 int
1227 is_served_n(short n)
1228 {
1229         return ((int)fs_tab[n]->served);
1230 }
1231 
1232 /*
1233  * This returns the number of blocks available on the indicated filesystem.
1234  *
1235  *      Note: Upon entry, a valid fsys() is required.
1236  */
1237 fsblkcnt_t
1238 get_blk_free_n(short n)
1239 {
1240         return (fs_tab[n]->bfree);
1241 }
1242 
1243 /*
1244  * This returns the number of blocks being used on the indicated filesystem.
1245  *
1246  *      Note: Upon entry, a valid fsys() is required.
1247  */
1248 fsblkcnt_t
1249 get_blk_used_n(short n)
1250 {
1251         return (fs_tab[n]->bused);
1252 }
1253 
1254 /*
1255  * This returns the number of inodes available on the indicated filesystem.
1256  *
1257  *      Note: Upon entry, a valid fsys() is required.
1258  */
1259 fsblkcnt_t
1260 get_inode_free_n(short n)
1261 {
1262         return (fs_tab[n]->ffree);
1263 }
1264 
1265 /*
1266  * This returns the number of inodes being used on the indicated filesystem.
1267  *
1268  *      Note: Upon entry, a valid fsys() is required.
1269  */
1270 fsblkcnt_t
1271 get_inode_used_n(short n)
1272 {
1273         return (fs_tab[n]->fused);
1274 }
1275 
1276 /*
1277  * Sets the number of blocks being used on the indicated filesystem.
1278  *
1279  *      Note: Upon entry, a valid fsys() is required.
1280  */
1281 void
1282 set_blk_used_n(short n, fsblkcnt_t value)
1283 {
1284         fs_tab[n]->bused = value;
1285 }
1286 
1287 /* Get the filesystem block size. */
1288 fsblkcnt_t
1289 get_blk_size_n(short n)
1290 {
1291         return (fs_tab[n]->bsize);
1292 }
1293 
1294 /* Get the filesystem fragment size. */
1295 fsblkcnt_t
1296 get_frag_size_n(short n)
1297 {
1298         return (fs_tab[n]->bsize);
1299 }
1300 
1301 /*
1302  * This returns the name of the indicated filesystem.
1303  */
1304 char *
1305 get_fs_name_n(short n)
1306 {
1307         if (fs_tab_used == 0) {
1308                 return (NULL);
1309         } else if (n >= fs_tab_used) {
1310                 return (NULL);
1311         } else {
1312                 return (fs_tab[n]->name);
1313         }
1314 }
1315 
1316 /*
1317  * This returns the remote name of the indicated filesystem.
1318  *
1319  *      Note: Upon entry, a valid fsys() is required.
1320  */
1321 char *
1322 get_source_name_n(short n)
1323 {
1324         return (fs_tab[n]->remote_name);
1325 }
1326 
1327 /*
1328  * This function returns the srvr_map status based upon the path.
1329  */
1330 int
1331 use_srvr_map(char *path, short *fsys_value)
1332 {
1333         if (*fsys_value == BADFSYS)
1334                 *fsys_value = fsys(path);
1335 
1336         return (use_srvr_map_n(*fsys_value));
1337 }
1338 
1339 /*
1340  * This function returns the mount status based upon the path.
1341  */
1342 int
1343 is_mounted(char *path, short *fsys_value)
1344 {
1345         if (*fsys_value == BADFSYS)
1346                 *fsys_value = fsys(path);
1347 
1348         return (is_mounted_n(*fsys_value));
1349 }
1350 
1351 /*
1352  * is_fs_writeable - given a cfent entry, return 1
1353  *      if it's writeable, 0 if read-only.
1354  *
1355  *      Note: Upon exit, a valid fsys() is guaranteed. This is
1356  *      an interface requirement.
1357  */
1358 int
1359 is_fs_writeable(char *path, short *fsys_value)
1360 {
1361         if (*fsys_value == BADFSYS)
1362                 *fsys_value = fsys(path);
1363 
1364         return (is_fs_writeable_n(*fsys_value));
1365 }
1366 
1367 /*
1368  * is_remote_fs - given a cfent entry, return 1
1369  *      if it's a remote filesystem, 0 if local.
1370  *
1371  *      Also Note: Upon exit, a valid fsys() is guaranteed. This is
1372  *      an interface requirement.
1373  */
1374 int
1375 is_remote_fs(char *path, short *fsys_value)
1376 {
1377         if (*fsys_value == BADFSYS)
1378                 *fsys_value = fsys(path);
1379 
1380         return (is_remote_fs_n(*fsys_value));
1381 }
1382 
1383 /*
1384  * This function returns the served status of the filesystem. Served means a
1385  * client is getting this file from a server and it is not writeable by the
1386  * client. It has nothing to do with whether or not this particular operation
1387  * (eg: pkgadd or pkgrm) will be writing to it.
1388  */
1389 int
1390 is_served(char *path, short *fsys_value)
1391 {
1392         if (*fsys_value == BADFSYS)
1393                 *fsys_value = fsys(path);
1394 
1395         return (is_served_n(*fsys_value));
1396 }
1397 
1398 /*
1399  * get_remote_path - given a filesystem table index, return the
1400  *      path of the filesystem on the remote system.  Otherwise,
1401  *      return NULL if it's a local filesystem.
1402  */
1403 char *
1404 get_remote_path(short n)
1405 {
1406         char    *p;
1407 
1408         if (!is_remote_fs_n(n))
1409                 return (NULL);  /* local */
1410         p = strchr(fs_tab[n]->remote_name, ':');
1411         if (!p)
1412                 p = fs_tab[n]->remote_name;  /* Loopback */
1413         else
1414                 p++;    /* remote */
1415         return (p);
1416 }
1417 
1418 /*
1419  * get_mount_point - given a filesystem table index, return the
1420  *      path of the mount point.  Otherwise,
1421  *      return NULL if it's a local filesystem.
1422  */
1423 char *
1424 get_mount_point(short n)
1425 {
1426         if (!is_remote_fs_n(n))
1427                 return (NULL);  /* local */
1428         return (fs_tab[n]->name);
1429 }
1430 
1431 struct fstable *
1432 get_fs_entry(short n)
1433 {
1434         if (fs_tab_used == 0) {
1435                 return (NULL);
1436         } else if (n >= fs_tab_used) {
1437                 return (NULL);
1438         } else {
1439                 return (fs_tab[n]);
1440         }
1441 }


 199         if (mktemp(testfile) == NULL)
 200                 return (0);     /* may as well be read-only */
 201         /* LINTED do not use creat(); use open(path,... */
 202         else if ((fd = creat(testfile, 0777)) == -1)
 203                 return (0);     /* can't write */
 204         else if (fstat(fd, &status) == -1)
 205                 retval = 0;     /* may as well be read-only */
 206         else if (status.st_uid != 0)
 207                 retval = 0;     /* too many restrictions */
 208         else
 209                 retval = 1;
 210 
 211         (void) close(fd);
 212         (void) unlink(testfile);
 213 
 214         return (retval);
 215 }
 216 
 217 /* This returns the hostname portion of a remote path. */
 218 char *
 219 get_server_host(uint32_t n)
 220 {
 221         static char hostname[HOST_NM_LN], *host_end;
 222 
 223         if (fs_tab_used == 0) {
 224                 return ("unknown source");
 225         }
 226 
 227         if (n < fs_tab_used) {
 228                 (void) strcpy(hostname, fs_tab[n]->remote_name);
 229                 if ((host_end = strchr(hostname, ':')) == NULL) {
 230                         if ((strcmp(fs_tab[n]->fstype, MNTTYPE_AUTO)) == NULL)
 231                                 return ("automounter");
 232                         else
 233                                 return (fs_tab[n]->fstype);
 234                 } else {
 235                         *host_end = '\0';
 236                         return (hostname);
 237                 }
 238         }
 239 
 240         return ("unknown source");
 241 }
 242 
 243 /*
 244  * This pulls the path out of a hostpath which may be of the form host:path
 245  * where path is an absolute path. NOTE: If path turns out to be relative,
 246  * this returns NULL.
 247  */


 549                                 /* close all file descriptors except stdio */
 550 
 551                                 closefrom(3);
 552 
 553                                 exit_no = execve(arg[0], arg, environ);
 554                                 _exit(exit_no);
 555                                 /*NOTREACHED*/
 556                         }
 557                 }
 558         }
 559         return (retcode);
 560 }
 561 
 562 /*
 563  * This function maps path, on a loopback filesystem, back to the real server
 564  * filesystem. fsys_value is the fs_tab[] entry to which the loopback'd path is
 565  * mapped. This returns a pointer to a static area. If the result is needed
 566  * for further processing, it should be strdup()'d or something.
 567  */
 568 char *
 569 server_map(char *path, uint32_t fsys_value)
 570 {
 571         static char server_construction[PATH_MAX];
 572 
 573         if (fs_tab_used == 0) {
 574                 (void) strcpy(server_construction, path);
 575         } else if (fsys_value < fs_tab_used) {
 576                 (void) snprintf(server_construction,
 577                         sizeof (server_construction),
 578                         "%s%s", fs_tab[fsys_value]->remote_name,
 579                         path+strlen(fs_tab[fsys_value]->name));
 580         } else {
 581                 (void) strcpy(server_construction, path);
 582         }
 583 
 584         return (server_construction);
 585 }
 586 
 587 /* This function sets up the standard parts of the fs_tab. */
 588 static struct fstable *
 589 fs_tab_init(char *mountp, char *fstype)
 590 {
 591         struct fstable *nfte;
 592 
 593         /* Create the array if necessary. */
 594         if (fs_list == -1) {
 595                 fs_list = ar_create(ALLOC_CHUNK,


1034 
1035         /*
1036          * Allocate space for the 'special' name.
1037          */
1038         if ((nfte->remote_name = malloc(strlen(remote_name)+1)) == NULL) {
1039                 progerr(ERR_MALLOC, "remote_name", errno, strerror(errno));
1040                 return (1);
1041         }
1042 
1043         (void) strcpy(nfte->remote_name, remote_name);
1044 
1045         return (0);
1046 }
1047 
1048 /*
1049  * Given a path, return the table index of the filesystem the file apparently
1050  * resides on. This doesn't put any time into resolving filesystems that
1051  * refer to other filesystems. It just returns the entry containing this
1052  * path.
1053  */
1054 uint32_t
1055 fsys(char *path)
1056 {
1057         register int i;
1058         char    real_path[PATH_MAX];
1059         char    path_copy[PATH_MAX];
1060         char    *path2use;
1061         char    *cp;
1062         int     pathlen;
1063         boolean_t found = B_FALSE;
1064 
1065         /*
1066          * The loop below represents our best effort to identify real path of
1067          * a file, which doesn't need to exist. realpath() returns error for
1068          * nonexistent path, therefore we need to cut off trailing components
1069          * of path until we get path which exists and can be resolved by
1070          * realpath(). Lookup of "/dir/symlink/nonexistent-file" would fail
1071          * to resolve symlink without this.
1072          */
1073         (void) strlcpy(path_copy, path, PATH_MAX);
1074         for (cp = dirname(path_copy); strlen(cp) > 1; cp = dirname(cp)) {


1130                     ((term_char == '/' || term_char == NULL) &&
1131                     strncmp(fs_tab[i]->name, path2use, fs_namelen) == 0))
1132                         return (i);
1133         }
1134 
1135         /*
1136          * It only gets here if the root filesystem is fundamentally corrupt.
1137          * (This can happen!)
1138          */
1139         progerr(ERR_FSYS_FELLOUT, path2use);
1140 
1141         return (-1);
1142 }
1143 
1144 /*
1145  * This function returns the entry in the fs_tab[] corresponding to the
1146  * actual filesystem of record. It won't return a loopback filesystem entry,
1147  * it will return the filesystem that the loopback filesystem is mounted
1148  * over.
1149  */
1150 uint32_t
1151 resolved_fsys(char *path)
1152 {
1153         int i = -1;
1154         char path2use[PATH_MAX];
1155 
1156         (void) strcpy(path2use, path);
1157 
1158         /* If this isn't a "real" filesystem, resolve the map. */
1159         do {
1160                 (void) strcpy(path2use, server_map(path2use, i));
1161                 i = fsys(path2use);
1162         } while (fs_tab[i]->srvr_map);
1163 
1164         return (i);
1165 }
1166 
1167 /*
1168  * This function returns the srvr_map status based upon the fs_tab entry
1169  * number. This tells us if the server path constructed from the package
1170  * install root is really the target filesystem.
1171  */
1172 int
1173 use_srvr_map_n(uint32_t n)
1174 {
1175         return ((int)fs_tab[n]->srvr_map);
1176 }
1177 
1178 /*
1179  * This function returns the mount status based upon the fs_tab entry
1180  * number. This tells us if there is any hope of gaining access
1181  * to this file system.
1182  */
1183 int
1184 is_mounted_n(uint32_t n)
1185 {
1186         return ((int)fs_tab[n]->mounted);
1187 }
1188 
1189 /*
1190  * is_fs_writeable_n - given an fstab index, return 1
1191  *      if it's writeable, 0 if read-only.
1192  */
1193 int
1194 is_fs_writeable_n(uint32_t n)
1195 {
1196         /*
1197          * If the write access permissions haven't been confirmed, do that
1198          * now. Note that the only reason we need to do the special check is
1199          * in the case of an NFS mount (remote) because we can't determine if
1200          * root has access in any other way.
1201          */
1202         if (fs_tab[n]->remote && fs_tab[n]->mounted &&
1203             !fs_tab[n]->write_tested) {
1204                 if (fs_tab[n]->writeable && !really_write(fs_tab[n]->name))
1205                         fs_tab[n]->writeable = 0;    /* not really */
1206 
1207                 fs_tab[n]->write_tested = 1; /* confirmed */
1208         }
1209 
1210         return ((int)fs_tab[n]->writeable);
1211 }
1212 
1213 /*
1214  * is_remote_fs_n - given an fstab index, return 1
1215  *      if it's a remote filesystem, 0 if local.
1216  *
1217  *      Note: Upon entry, a valid fsys() is required.
1218  */
1219 int
1220 is_remote_fs_n(uint32_t n)
1221 {
1222         return ((int)fs_tab[n]->remote);
1223 }
1224 
1225 /* index-driven is_served() */
1226 int
1227 is_served_n(uint32_t n)
1228 {
1229         return ((int)fs_tab[n]->served);
1230 }
1231 
1232 /*
1233  * This returns the number of blocks available on the indicated filesystem.
1234  *
1235  *      Note: Upon entry, a valid fsys() is required.
1236  */
1237 fsblkcnt_t
1238 get_blk_free_n(uint32_t n)
1239 {
1240         return (fs_tab[n]->bfree);
1241 }
1242 
1243 /*
1244  * This returns the number of blocks being used on the indicated filesystem.
1245  *
1246  *      Note: Upon entry, a valid fsys() is required.
1247  */
1248 fsblkcnt_t
1249 get_blk_used_n(uint32_t n)
1250 {
1251         return (fs_tab[n]->bused);
1252 }
1253 
1254 /*
1255  * This returns the number of inodes available on the indicated filesystem.
1256  *
1257  *      Note: Upon entry, a valid fsys() is required.
1258  */
1259 fsblkcnt_t
1260 get_inode_free_n(uint32_t n)
1261 {
1262         return (fs_tab[n]->ffree);
1263 }
1264 
1265 /*
1266  * This returns the number of inodes being used on the indicated filesystem.
1267  *
1268  *      Note: Upon entry, a valid fsys() is required.
1269  */
1270 fsblkcnt_t
1271 get_inode_used_n(uint32_t n)
1272 {
1273         return (fs_tab[n]->fused);
1274 }
1275 
1276 /*
1277  * Sets the number of blocks being used on the indicated filesystem.
1278  *
1279  *      Note: Upon entry, a valid fsys() is required.
1280  */
1281 void
1282 set_blk_used_n(uint32_t n, fsblkcnt_t value)
1283 {
1284         fs_tab[n]->bused = value;
1285 }
1286 
1287 /* Get the filesystem block size. */
1288 fsblkcnt_t
1289 get_blk_size_n(uint32_t n)
1290 {
1291         return (fs_tab[n]->bsize);
1292 }
1293 
1294 /* Get the filesystem fragment size. */
1295 fsblkcnt_t
1296 get_frag_size_n(uint32_t n)
1297 {
1298         return (fs_tab[n]->bsize);
1299 }
1300 
1301 /*
1302  * This returns the name of the indicated filesystem.
1303  */
1304 char *
1305 get_fs_name_n(uint32_t n)
1306 {
1307         if (fs_tab_used == 0) {
1308                 return (NULL);
1309         } else if (n >= fs_tab_used) {
1310                 return (NULL);
1311         } else {
1312                 return (fs_tab[n]->name);
1313         }
1314 }
1315 
1316 /*
1317  * This returns the remote name of the indicated filesystem.
1318  *
1319  *      Note: Upon entry, a valid fsys() is required.
1320  */
1321 char *
1322 get_source_name_n(uint32_t n)
1323 {
1324         return (fs_tab[n]->remote_name);
1325 }
1326 
1327 /*
1328  * This function returns the srvr_map status based upon the path.
1329  */
1330 int
1331 use_srvr_map(char *path, uint32_t *fsys_value)
1332 {
1333         if (*fsys_value == BADFSYS)
1334                 *fsys_value = fsys(path);
1335 
1336         return (use_srvr_map_n(*fsys_value));
1337 }
1338 
1339 /*
1340  * This function returns the mount status based upon the path.
1341  */
1342 int
1343 is_mounted(char *path, uint32_t *fsys_value)
1344 {
1345         if (*fsys_value == BADFSYS)
1346                 *fsys_value = fsys(path);
1347 
1348         return (is_mounted_n(*fsys_value));
1349 }
1350 
1351 /*
1352  * is_fs_writeable - given a cfent entry, return 1
1353  *      if it's writeable, 0 if read-only.
1354  *
1355  *      Note: Upon exit, a valid fsys() is guaranteed. This is
1356  *      an interface requirement.
1357  */
1358 int
1359 is_fs_writeable(char *path, uint32_t *fsys_value)
1360 {
1361         if (*fsys_value == BADFSYS)
1362                 *fsys_value = fsys(path);
1363 
1364         return (is_fs_writeable_n(*fsys_value));
1365 }
1366 
1367 /*
1368  * is_remote_fs - given a cfent entry, return 1
1369  *      if it's a remote filesystem, 0 if local.
1370  *
1371  *      Also Note: Upon exit, a valid fsys() is guaranteed. This is
1372  *      an interface requirement.
1373  */
1374 int
1375 is_remote_fs(char *path, uint32_t *fsys_value)
1376 {
1377         if (*fsys_value == BADFSYS)
1378                 *fsys_value = fsys(path);
1379 
1380         return (is_remote_fs_n(*fsys_value));
1381 }
1382 
1383 /*
1384  * This function returns the served status of the filesystem. Served means a
1385  * client is getting this file from a server and it is not writeable by the
1386  * client. It has nothing to do with whether or not this particular operation
1387  * (eg: pkgadd or pkgrm) will be writing to it.
1388  */
1389 int
1390 is_served(char *path, uint32_t *fsys_value)
1391 {
1392         if (*fsys_value == BADFSYS)
1393                 *fsys_value = fsys(path);
1394 
1395         return (is_served_n(*fsys_value));
1396 }
1397 
1398 /*
1399  * get_remote_path - given a filesystem table index, return the
1400  *      path of the filesystem on the remote system.  Otherwise,
1401  *      return NULL if it's a local filesystem.
1402  */
1403 char *
1404 get_remote_path(uint32_t n)
1405 {
1406         char    *p;
1407 
1408         if (!is_remote_fs_n(n))
1409                 return (NULL);  /* local */
1410         p = strchr(fs_tab[n]->remote_name, ':');
1411         if (!p)
1412                 p = fs_tab[n]->remote_name;  /* Loopback */
1413         else
1414                 p++;    /* remote */
1415         return (p);
1416 }
1417 
1418 /*
1419  * get_mount_point - given a filesystem table index, return the
1420  *      path of the mount point.  Otherwise,
1421  *      return NULL if it's a local filesystem.
1422  */
1423 char *
1424 get_mount_point(uint32_t n)
1425 {
1426         if (!is_remote_fs_n(n))
1427                 return (NULL);  /* local */
1428         return (fs_tab[n]->name);
1429 }
1430 
1431 struct fstable *
1432 get_fs_entry(uint32_t n)
1433 {
1434         if (fs_tab_used == 0) {
1435                 return (NULL);
1436         } else if (n >= fs_tab_used) {
1437                 return (NULL);
1438         } else {
1439                 return (fs_tab[n]);
1440         }
1441 }