@@ -744,6 +744,111 @@ void load_recfm_from_dscb(const DSCBFormat1 *dscb, string *recfm)
744744 }
745745}
746746
747+ void load_date_from_dscb (const char *date_in, string *date_out)
748+ {
749+ // Date is in 'YDD' format (3 bytes): Year offset and day of year
750+ // If all zeros, date is not maintained
751+ unsigned char year_offset = static_cast <unsigned char >(date_in[0 ]);
752+ unsigned char day_high = static_cast <unsigned char >(date_in[1 ]);
753+ unsigned char day_low = static_cast <unsigned char >(date_in[2 ]);
754+
755+ // Check if date is zero (not maintained)
756+ if (year_offset == 0 && day_high == 0 && day_low == 0 )
757+ {
758+ *date_out = " " ;
759+ return ;
760+ }
761+
762+ // Parse year: add 1900 to the year offset
763+ int year = 1900 + year_offset;
764+
765+ // Parse day of year from 2-byte value (big-endian)
766+ int day_of_year = (day_high << 8 ) | day_low;
767+
768+ // Convert day of year to month/day
769+ static const int days_in_month[] = {31 , 28 , 31 , 30 , 31 , 30 , 31 , 31 , 30 , 31 , 30 , 31 };
770+
771+ // Check for leap year
772+ bool is_leap = (year % 4 == 0 && year % 100 != 0 ) || (year % 400 == 0 );
773+
774+ int month = 1 ;
775+ int day = day_of_year;
776+
777+ for (int i = 0 ; i < 12 && day > days_in_month[i]; i++)
778+ {
779+ int days_this_month = days_in_month[i];
780+ if (i == 1 && is_leap) // February in leap year
781+ days_this_month = 29 ;
782+
783+ day -= days_this_month;
784+ month++;
785+ }
786+
787+ // Format as "YYYY/MM/DD"
788+ char buffer[11 ];
789+ sprintf (buffer, " %04d/%02d/%02d" , year, month, day);
790+ *date_out = buffer;
791+ }
792+
793+ void load_size_from_dscb (const DSCBFormat1 *dscb, ZDSEntry &entry)
794+ {
795+ // extx: Number of extents on this volume
796+ entry.extx = dscb->ds1noepv ;
797+
798+ // Parse the extent information from ds1exnts (3 extents, 10 bytes each)
799+ // Each extent has: type(1), seq(1), lower_limit(4), upper_limit(4)
800+ const char *extent_data = dscb->ds1exnts ;
801+ int total_tracks = 0 ;
802+ bool has_overflow = false ;
803+
804+ for (int i = 0 ; i < 3 ; i++)
805+ {
806+ const char *extent = extent_data + (i * 10 );
807+ uint8_t extent_type = static_cast <uint8_t >(extent[0 ]);
808+
809+ // Check if this is a valid extent (not X'00')
810+ if (extent_type == 0x00 )
811+ break ;
812+
813+ // Check for overflow extent (ISAM X'02')
814+ if (extent_type & 0x02 )
815+ {
816+ has_overflow = true ;
817+ }
818+
819+ // Parse lower limit CCHH (4 bytes)
820+ uint16_t lower_cyl_low = (static_cast <unsigned char >(extent[2 ]) << 8 ) |
821+ static_cast <unsigned char >(extent[3 ]);
822+ uint16_t lower_cyl_high = (static_cast <unsigned char >(extent[4 ]) >> 4 ) & 0x0F ;
823+ uint16_t lower_head = ((static_cast <unsigned char >(extent[4 ]) & 0x0F ) << 8 ) |
824+ static_cast <unsigned char >(extent[5 ]);
825+
826+ // Parse upper limit CCHH (4 bytes)
827+ uint16_t upper_cyl_low = (static_cast <unsigned char >(extent[6 ]) << 8 ) |
828+ static_cast <unsigned char >(extent[7 ]);
829+ uint16_t upper_cyl_high = (static_cast <unsigned char >(extent[8 ]) >> 4 ) & 0x0F ;
830+ uint16_t upper_head = ((static_cast <unsigned char >(extent[8 ]) & 0x0F ) << 8 ) |
831+ static_cast <unsigned char >(extent[9 ]);
832+
833+ // Calculate full cylinder numbers (28-bit)
834+ uint32_t lower_cyl = (lower_cyl_high << 16 ) | lower_cyl_low;
835+ uint32_t upper_cyl = (upper_cyl_high << 16 ) | upper_cyl_low;
836+
837+ // Calculate tracks in this extent
838+ if (upper_cyl >= lower_cyl)
839+ {
840+ int tracks_in_extent = ((upper_cyl - lower_cyl) * 15 ) + (upper_head - lower_head) + 1 ;
841+ total_tracks += tracks_in_extent;
842+ }
843+ }
844+
845+ // sizex: Total tracks allocated
846+ entry.sizex = total_tracks;
847+
848+ // ovf: Overflow indicator
849+ entry.ovf = has_overflow;
850+ }
851+
747852void zds_get_attrs_from_dscb (ZDS *zds, ZDSEntry &entry)
748853{
749854 auto *dscb = (DSCBFormat1 *)__malloc31 (sizeof (DSCBFormat1));
@@ -759,6 +864,14 @@ void zds_get_attrs_from_dscb(ZDS *zds, ZDSEntry &entry)
759864 {
760865 load_dsorg_from_dscb (dscb, &entry.dsorg );
761866 load_recfm_from_dscb (dscb, &entry.recfm );
867+ entry.blksz = (static_cast <unsigned char >(dscb->ds1blkl [0 ]) << 8 ) |
868+ static_cast <unsigned char >(dscb->ds1blkl [1 ]);
869+ entry.lrecl = (static_cast <unsigned char >(dscb->ds1lrecl [0 ]) << 8 ) |
870+ static_cast <unsigned char >(dscb->ds1lrecl [1 ]);
871+ load_date_from_dscb (dscb->ds1credt , &entry.cdate );
872+ load_date_from_dscb (dscb->ds1expdt , &entry.edate );
873+ load_date_from_dscb (dscb->ds1refd , &entry.rdate );
874+ load_size_from_dscb (dscb, entry);
762875 }
763876 else
764877 {
0 commit comments