Print this page
6063 pkgadd breaks with too many mountpoints

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/svr4pkg/libinst/mntinfo.c
          +++ new/usr/src/cmd/svr4pkg/libinst/mntinfo.c
↓ open down ↓ 208 lines elided ↑ open up ↑
 209  209                  retval = 1;
 210  210  
 211  211          (void) close(fd);
 212  212          (void) unlink(testfile);
 213  213  
 214  214          return (retval);
 215  215  }
 216  216  
 217  217  /* This returns the hostname portion of a remote path. */
 218  218  char *
 219      -get_server_host(short n)
      219 +get_server_host(uint32_t n)
 220  220  {
 221  221          static char hostname[HOST_NM_LN], *host_end;
 222  222  
 223  223          if (fs_tab_used == 0) {
 224  224                  return ("unknown source");
 225  225          }
 226  226  
 227      -        if (n >= 0 && n < fs_tab_used) {
      227 +        if (n < fs_tab_used) {
 228  228                  (void) strcpy(hostname, fs_tab[n]->remote_name);
 229  229                  if ((host_end = strchr(hostname, ':')) == NULL) {
 230  230                          if ((strcmp(fs_tab[n]->fstype, MNTTYPE_AUTO)) == NULL)
 231  231                                  return ("automounter");
 232  232                          else
 233  233                                  return (fs_tab[n]->fstype);
 234  234                  } else {
 235  235                          *host_end = '\0';
 236  236                          return (hostname);
 237  237                  }
↓ open down ↓ 321 lines elided ↑ open up ↑
 559  559          return (retcode);
 560  560  }
 561  561  
 562  562  /*
 563  563   * This function maps path, on a loopback filesystem, back to the real server
 564  564   * filesystem. fsys_value is the fs_tab[] entry to which the loopback'd path is
 565  565   * mapped. This returns a pointer to a static area. If the result is needed
 566  566   * for further processing, it should be strdup()'d or something.
 567  567   */
 568  568  char *
 569      -server_map(char *path, short fsys_value)
      569 +server_map(char *path, uint32_t fsys_value)
 570  570  {
 571  571          static char server_construction[PATH_MAX];
 572  572  
 573  573          if (fs_tab_used == 0) {
 574  574                  (void) strcpy(server_construction, path);
 575      -        } else if (fsys_value >= 0 && fsys_value < fs_tab_used) {
      575 +        } else if (fsys_value < fs_tab_used) {
 576  576                  (void) snprintf(server_construction,
 577  577                          sizeof (server_construction),
 578  578                          "%s%s", fs_tab[fsys_value]->remote_name,
 579  579                          path+strlen(fs_tab[fsys_value]->name));
 580  580          } else {
 581  581                  (void) strcpy(server_construction, path);
 582  582          }
 583  583  
 584  584          return (server_construction);
 585  585  }
↓ open down ↓ 458 lines elided ↑ open up ↑
1044 1044  
1045 1045          return (0);
1046 1046  }
1047 1047  
1048 1048  /*
1049 1049   * Given a path, return the table index of the filesystem the file apparently
1050 1050   * resides on. This doesn't put any time into resolving filesystems that
1051 1051   * refer to other filesystems. It just returns the entry containing this
1052 1052   * path.
1053 1053   */
1054      -short
     1054 +uint32_t
1055 1055  fsys(char *path)
1056 1056  {
1057 1057          register int i;
1058 1058          char    real_path[PATH_MAX];
1059 1059          char    path_copy[PATH_MAX];
1060 1060          char    *path2use;
1061 1061          char    *cp;
1062 1062          int     pathlen;
1063 1063          boolean_t found = B_FALSE;
1064 1064  
↓ open down ↓ 75 lines elided ↑ open up ↑
1140 1140  
1141 1141          return (-1);
1142 1142  }
1143 1143  
1144 1144  /*
1145 1145   * This function returns the entry in the fs_tab[] corresponding to the
1146 1146   * actual filesystem of record. It won't return a loopback filesystem entry,
1147 1147   * it will return the filesystem that the loopback filesystem is mounted
1148 1148   * over.
1149 1149   */
1150      -short
     1150 +uint32_t
1151 1151  resolved_fsys(char *path)
1152 1152  {
1153 1153          int i = -1;
1154 1154          char path2use[PATH_MAX];
1155 1155  
1156 1156          (void) strcpy(path2use, path);
1157 1157  
1158 1158          /* If this isn't a "real" filesystem, resolve the map. */
1159 1159          do {
1160 1160                  (void) strcpy(path2use, server_map(path2use, i));
↓ open down ↓ 2 lines elided ↑ open up ↑
1163 1163  
1164 1164          return (i);
1165 1165  }
1166 1166  
1167 1167  /*
1168 1168   * This function returns the srvr_map status based upon the fs_tab entry
1169 1169   * number. This tells us if the server path constructed from the package
1170 1170   * install root is really the target filesystem.
1171 1171   */
1172 1172  int
1173      -use_srvr_map_n(short n)
     1173 +use_srvr_map_n(uint32_t n)
1174 1174  {
1175 1175          return ((int)fs_tab[n]->srvr_map);
1176 1176  }
1177 1177  
1178 1178  /*
1179 1179   * This function returns the mount status based upon the fs_tab entry
1180 1180   * number. This tells us if there is any hope of gaining access
1181 1181   * to this file system.
1182 1182   */
1183 1183  int
1184      -is_mounted_n(short n)
     1184 +is_mounted_n(uint32_t n)
1185 1185  {
1186 1186          return ((int)fs_tab[n]->mounted);
1187 1187  }
1188 1188  
1189 1189  /*
1190 1190   * is_fs_writeable_n - given an fstab index, return 1
1191 1191   *      if it's writeable, 0 if read-only.
1192 1192   */
1193 1193  int
1194      -is_fs_writeable_n(short n)
     1194 +is_fs_writeable_n(uint32_t n)
1195 1195  {
1196 1196          /*
1197 1197           * If the write access permissions haven't been confirmed, do that
1198 1198           * now. Note that the only reason we need to do the special check is
1199 1199           * in the case of an NFS mount (remote) because we can't determine if
1200 1200           * root has access in any other way.
1201 1201           */
1202 1202          if (fs_tab[n]->remote && fs_tab[n]->mounted &&
1203 1203              !fs_tab[n]->write_tested) {
1204 1204                  if (fs_tab[n]->writeable && !really_write(fs_tab[n]->name))
↓ open down ↓ 5 lines elided ↑ open up ↑
1210 1210          return ((int)fs_tab[n]->writeable);
1211 1211  }
1212 1212  
1213 1213  /*
1214 1214   * is_remote_fs_n - given an fstab index, return 1
1215 1215   *      if it's a remote filesystem, 0 if local.
1216 1216   *
1217 1217   *      Note: Upon entry, a valid fsys() is required.
1218 1218   */
1219 1219  int
1220      -is_remote_fs_n(short n)
     1220 +is_remote_fs_n(uint32_t n)
1221 1221  {
1222 1222          return ((int)fs_tab[n]->remote);
1223 1223  }
1224 1224  
1225 1225  /* index-driven is_served() */
1226 1226  int
1227      -is_served_n(short n)
     1227 +is_served_n(uint32_t n)
1228 1228  {
1229 1229          return ((int)fs_tab[n]->served);
1230 1230  }
1231 1231  
1232 1232  /*
1233 1233   * This returns the number of blocks available on the indicated filesystem.
1234 1234   *
1235 1235   *      Note: Upon entry, a valid fsys() is required.
1236 1236   */
1237 1237  fsblkcnt_t
1238      -get_blk_free_n(short n)
     1238 +get_blk_free_n(uint32_t n)
1239 1239  {
1240 1240          return (fs_tab[n]->bfree);
1241 1241  }
1242 1242  
1243 1243  /*
1244 1244   * This returns the number of blocks being used on the indicated filesystem.
1245 1245   *
1246 1246   *      Note: Upon entry, a valid fsys() is required.
1247 1247   */
1248 1248  fsblkcnt_t
1249      -get_blk_used_n(short n)
     1249 +get_blk_used_n(uint32_t n)
1250 1250  {
1251 1251          return (fs_tab[n]->bused);
1252 1252  }
1253 1253  
1254 1254  /*
1255 1255   * This returns the number of inodes available on the indicated filesystem.
1256 1256   *
1257 1257   *      Note: Upon entry, a valid fsys() is required.
1258 1258   */
1259 1259  fsblkcnt_t
1260      -get_inode_free_n(short n)
     1260 +get_inode_free_n(uint32_t n)
1261 1261  {
1262 1262          return (fs_tab[n]->ffree);
1263 1263  }
1264 1264  
1265 1265  /*
1266 1266   * This returns the number of inodes being used on the indicated filesystem.
1267 1267   *
1268 1268   *      Note: Upon entry, a valid fsys() is required.
1269 1269   */
1270 1270  fsblkcnt_t
1271      -get_inode_used_n(short n)
     1271 +get_inode_used_n(uint32_t n)
1272 1272  {
1273 1273          return (fs_tab[n]->fused);
1274 1274  }
1275 1275  
1276 1276  /*
1277 1277   * Sets the number of blocks being used on the indicated filesystem.
1278 1278   *
1279 1279   *      Note: Upon entry, a valid fsys() is required.
1280 1280   */
1281 1281  void
1282      -set_blk_used_n(short n, fsblkcnt_t value)
     1282 +set_blk_used_n(uint32_t n, fsblkcnt_t value)
1283 1283  {
1284 1284          fs_tab[n]->bused = value;
1285 1285  }
1286 1286  
1287 1287  /* Get the filesystem block size. */
1288 1288  fsblkcnt_t
1289      -get_blk_size_n(short n)
     1289 +get_blk_size_n(uint32_t n)
1290 1290  {
1291 1291          return (fs_tab[n]->bsize);
1292 1292  }
1293 1293  
1294 1294  /* Get the filesystem fragment size. */
1295 1295  fsblkcnt_t
1296      -get_frag_size_n(short n)
     1296 +get_frag_size_n(uint32_t n)
1297 1297  {
1298 1298          return (fs_tab[n]->bsize);
1299 1299  }
1300 1300  
1301 1301  /*
1302 1302   * This returns the name of the indicated filesystem.
1303 1303   */
1304 1304  char *
1305      -get_fs_name_n(short n)
     1305 +get_fs_name_n(uint32_t n)
1306 1306  {
1307 1307          if (fs_tab_used == 0) {
1308 1308                  return (NULL);
1309 1309          } else if (n >= fs_tab_used) {
1310 1310                  return (NULL);
1311 1311          } else {
1312 1312                  return (fs_tab[n]->name);
1313 1313          }
1314 1314  }
1315 1315  
1316 1316  /*
1317 1317   * This returns the remote name of the indicated filesystem.
1318 1318   *
1319 1319   *      Note: Upon entry, a valid fsys() is required.
1320 1320   */
1321 1321  char *
1322      -get_source_name_n(short n)
     1322 +get_source_name_n(uint32_t n)
1323 1323  {
1324 1324          return (fs_tab[n]->remote_name);
1325 1325  }
1326 1326  
1327 1327  /*
1328 1328   * This function returns the srvr_map status based upon the path.
1329 1329   */
1330 1330  int
1331      -use_srvr_map(char *path, short *fsys_value)
     1331 +use_srvr_map(char *path, uint32_t *fsys_value)
1332 1332  {
1333 1333          if (*fsys_value == BADFSYS)
1334 1334                  *fsys_value = fsys(path);
1335 1335  
1336 1336          return (use_srvr_map_n(*fsys_value));
1337 1337  }
1338 1338  
1339 1339  /*
1340 1340   * This function returns the mount status based upon the path.
1341 1341   */
1342 1342  int
1343      -is_mounted(char *path, short *fsys_value)
     1343 +is_mounted(char *path, uint32_t *fsys_value)
1344 1344  {
1345 1345          if (*fsys_value == BADFSYS)
1346 1346                  *fsys_value = fsys(path);
1347 1347  
1348 1348          return (is_mounted_n(*fsys_value));
1349 1349  }
1350 1350  
1351 1351  /*
1352 1352   * is_fs_writeable - given a cfent entry, return 1
1353 1353   *      if it's writeable, 0 if read-only.
1354 1354   *
1355 1355   *      Note: Upon exit, a valid fsys() is guaranteed. This is
1356 1356   *      an interface requirement.
1357 1357   */
1358 1358  int
1359      -is_fs_writeable(char *path, short *fsys_value)
     1359 +is_fs_writeable(char *path, uint32_t *fsys_value)
1360 1360  {
1361 1361          if (*fsys_value == BADFSYS)
1362 1362                  *fsys_value = fsys(path);
1363 1363  
1364 1364          return (is_fs_writeable_n(*fsys_value));
1365 1365  }
1366 1366  
1367 1367  /*
1368 1368   * is_remote_fs - given a cfent entry, return 1
1369 1369   *      if it's a remote filesystem, 0 if local.
1370 1370   *
1371 1371   *      Also Note: Upon exit, a valid fsys() is guaranteed. This is
1372 1372   *      an interface requirement.
1373 1373   */
1374 1374  int
1375      -is_remote_fs(char *path, short *fsys_value)
     1375 +is_remote_fs(char *path, uint32_t *fsys_value)
1376 1376  {
1377 1377          if (*fsys_value == BADFSYS)
1378 1378                  *fsys_value = fsys(path);
1379 1379  
1380 1380          return (is_remote_fs_n(*fsys_value));
1381 1381  }
1382 1382  
1383 1383  /*
1384 1384   * This function returns the served status of the filesystem. Served means a
1385 1385   * client is getting this file from a server and it is not writeable by the
1386 1386   * client. It has nothing to do with whether or not this particular operation
1387 1387   * (eg: pkgadd or pkgrm) will be writing to it.
1388 1388   */
1389 1389  int
1390      -is_served(char *path, short *fsys_value)
     1390 +is_served(char *path, uint32_t *fsys_value)
1391 1391  {
1392 1392          if (*fsys_value == BADFSYS)
1393 1393                  *fsys_value = fsys(path);
1394 1394  
1395 1395          return (is_served_n(*fsys_value));
1396 1396  }
1397 1397  
1398 1398  /*
1399 1399   * get_remote_path - given a filesystem table index, return the
1400 1400   *      path of the filesystem on the remote system.  Otherwise,
1401 1401   *      return NULL if it's a local filesystem.
1402 1402   */
1403 1403  char *
1404      -get_remote_path(short n)
     1404 +get_remote_path(uint32_t n)
1405 1405  {
1406 1406          char    *p;
1407 1407  
1408 1408          if (!is_remote_fs_n(n))
1409 1409                  return (NULL);  /* local */
1410 1410          p = strchr(fs_tab[n]->remote_name, ':');
1411 1411          if (!p)
1412 1412                  p = fs_tab[n]->remote_name;     /* Loopback */
1413 1413          else
1414 1414                  p++;    /* remote */
1415 1415          return (p);
1416 1416  }
1417 1417  
1418 1418  /*
1419 1419   * get_mount_point - given a filesystem table index, return the
1420 1420   *      path of the mount point.  Otherwise,
1421 1421   *      return NULL if it's a local filesystem.
1422 1422   */
1423 1423  char *
1424      -get_mount_point(short n)
     1424 +get_mount_point(uint32_t n)
1425 1425  {
1426 1426          if (!is_remote_fs_n(n))
1427 1427                  return (NULL);  /* local */
1428 1428          return (fs_tab[n]->name);
1429 1429  }
1430 1430  
1431 1431  struct fstable *
1432      -get_fs_entry(short n)
     1432 +get_fs_entry(uint32_t n)
1433 1433  {
1434 1434          if (fs_tab_used == 0) {
1435 1435                  return (NULL);
1436 1436          } else if (n >= fs_tab_used) {
1437 1437                  return (NULL);
1438 1438          } else {
1439 1439                  return (fs_tab[n]);
1440 1440          }
1441 1441  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX