+
+ /* check tapetype-based splitting parameters */
+ part_size = tapetype_get_part_size(tp);
+ part_cache_type = tapetype_get_part_cache_type(tp);
+ part_cache_dir = tapetype_get_part_cache_dir(tp);
+ part_cache_max_size = tapetype_get_part_cache_max_size(tp);
+
+ if (!tapetype_seen(tp, TAPETYPE_PART_SIZE)) {
+ if (tapetype_seen(tp, TAPETYPE_PART_CACHE_TYPE)) {
+ g_fprintf(outf, "ERROR: part-cache-type specified, but no part-size\n");
+ tapebad = 1;
+ }
+ if (tapetype_seen(tp, TAPETYPE_PART_CACHE_DIR)) {
+ g_fprintf(outf, "ERROR: part-cache-dir specified, but no part-size\n");
+ tapebad = 1;
+ }
+ if (tapetype_seen(tp, TAPETYPE_PART_CACHE_MAX_SIZE)) {
+ g_fprintf(outf, "ERROR: part-cache-max-size specified, but no part-size\n");
+ tapebad = 1;
+ }
+ } else {
+ switch (part_cache_type) {
+ case PART_CACHE_TYPE_DISK:
+ if (!tapetype_seen(tp, TAPETYPE_PART_CACHE_DIR)
+ || !part_cache_dir || !*part_cache_dir) {
+ g_fprintf(outf,
+ "ERROR: part-cache-type is DISK, but no part-cache-dir specified\n");
+ tapebad = 1;
+ } else {
+ if(get_fs_usage(part_cache_dir, NULL, &fsusage) == -1) {
+ g_fprintf(outf, "ERROR: part-cache-dir '%s': %s\n",
+ part_cache_dir, strerror(errno));
+ tapebad = 1;
+ } else {
+ kb_avail = fsusage.fsu_bavail_top_bit_set?
+ 0 : fsusage.fsu_bavail / 1024 * fsusage.fsu_blocksize;
+ kb_needed = part_size;
+ if (tapetype_seen(tp, TAPETYPE_PART_CACHE_MAX_SIZE)) {
+ kb_needed = part_cache_max_size;
+ }
+ if (kb_avail < kb_needed) {
+ g_fprintf(outf,
+ "ERROR: part-cache-dir has %ju %sB available, but needs %ju %sB\n",
+ kb_avail/(uintmax_t)unitdivisor, displayunit,
+ kb_needed/(uintmax_t)unitdivisor, displayunit);
+ tapebad = 1;
+ }
+ }
+ }
+ break;
+
+ case PART_CACHE_TYPE_MEMORY:
+ kb_avail = physmem_total() / 1024;
+ kb_needed = part_size;
+ if (tapetype_seen(tp, TAPETYPE_PART_CACHE_MAX_SIZE)) {
+ kb_needed = part_cache_max_size;
+ }
+ if (kb_avail < kb_needed) {
+ g_fprintf(outf,
+ "ERROR: system has %ju %sB memory, but part cache needs %ju %sB\n",
+ kb_avail/(uintmax_t)unitdivisor, displayunit,
+ kb_needed/(uintmax_t)unitdivisor, displayunit);
+ tapebad = 1;
+ }
+
+ /* FALL THROUGH */
+
+ case PART_CACHE_TYPE_NONE:
+ if (tapetype_seen(tp, TAPETYPE_PART_CACHE_DIR)) {
+ g_fprintf(outf,
+ "ERROR: part-cache-dir specified, but part-cache-type is not DISK\n");
+ tapebad = 1;
+ }
+ break;
+ }
+ }
+
+ if (tapetype_seen(tp, TAPETYPE_PART_SIZE) && part_size == 0
+ && part_cache_type != PART_CACHE_TYPE_NONE) {
+ g_fprintf(outf,
+ "ERROR: part_size is zero, but part-cache-type is not 'none'\n");
+ tapebad = 1;
+ }
+
+ if (tapetype_seen(tp, TAPETYPE_PART_CACHE_MAX_SIZE)) {
+ if (part_cache_type == PART_CACHE_TYPE_NONE) {
+ g_fprintf(outf,
+ "ERROR: part-cache-max-size is specified but no part cache is in use\n");
+ tapebad = 1;
+ }
+
+ if (part_cache_max_size > part_size) {
+ g_fprintf(outf,
+ "WARNING: part-cache-max-size is greater than part-size\n");
+ }
+ }
+
+ tape_size = tapetype_get_length(tp);
+ if (part_size && part_size * 1000 < tape_size) {
+ g_fprintf(outf,
+ _("WARNING: part-size of %ju %sB < 0.1%% of tape length.\n"),
+ (uintmax_t)part_size/(uintmax_t)unitdivisor, displayunit);
+ if (!printed_small_part_size_warning) {
+ printed_small_part_size_warning = TRUE;
+ g_fprintf(outf, "%s", small_part_size_warning);
+ }
+ } else if (part_cache_max_size && part_cache_max_size * 1000 < tape_size) {
+ g_fprintf(outf,
+ _("WARNING: part-cache-max-size of %ju %sB < 0.1%% of tape length.\n"),
+ (uintmax_t)part_cache_max_size/(uintmax_t)unitdivisor, displayunit);
+ if (!printed_small_part_size_warning) {
+ printed_small_part_size_warning = TRUE;
+ g_fprintf(outf, "%s", small_part_size_warning);
+ }
+ }