Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: af91b7326eaeb557d60204242057d8da5faacd04
Ticket: 219396ffffffffffffffffffffffffffffffffff
seek offset is limited to sizeof(int), where sizeof(long) sh
User & Date: nobody on 2000-10-26 05:12:23
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    OriginalBugID: 6215 Bug
    Version: 8.3.2
    SubmitDate: '2000-09-05'
    LastModified: '2000-10-25'
    Severity: MED
    Status: UnAssn
    Submitter: techsupp
    OS: Digital Unix
    Machine: 64-bit Compaq Alpha
    FixedDate: '2000-10-25'
    ClosedDate: '2000-10-25'
    
    
    Name:
    Robin T. Miller
    
    CustomShell:
    No patches, no customizations.
    
    ReproducibleScript:
    On Tru64 Unix, file offsets are sizeof(long), but the definition of seek limits the file offset to sizeof(int) or 31 bits (must be positive value). I had a simple C function used to determine disk capacity, that I decided to re-write in Tcl, but was disappointed to see that seek has this limitation.  Of course to be portable to other platforms, 64-bit file system support is necessary.
    
    Here's the simple Tcl code to reproduce this problem:
    
    set attempts    0
    set bsize       512
    set mbyte       [expr (1024 * 1024)]
    set adjust      [expr ($mbyte * 250)]
    set offset      $adjust
    
    while { 1 } {
        incr attempts
        if [catch {seek $chan $offset start} result] {
            puts stderr "seek failed!\n$result"
            break
        }
        set off [tell $chan]
        if { $opts(DebugFlag) } {
            puts [format "offset = %ld, lba = %lu"  $off [expr ($off / $bsize)]]
        }
        if [catch {read $chan $bsize} result] {
            puts stderr "read failed!\n$result"
            break
        }
        if [eof $chan] {
            set adjust [expr ($adjust / 2)]
            if { ($adjust == 0) } {
                incr adjust
            }
            set offset [expr ($off - $adjust)]
        } else {
            incr offset $adjust
            if { ($adjust == 1) } {
                break;                      ;# We have max capacity!
            }
        }
    }
    
    puts "    Attempts: $attempts"
    puts "      Offset: $offset"
    puts "    Capacity: [expr ($offset / $bsize)]"
    
    I consider this a bug rather than a feature enhancement, since Tru64 Unix is naturally a 64-bit system.
    
    ObservedBehavior:
    tru64% getcapacity -device rz2 -debug
    offset = 262144000, lba = 512000
    offset = 524288000, lba = 1024000
    offset = 786432000, lba = 1536000
    offset = 1048576000, lba = 2048000
    offset = 1310720000, lba = 2560000
    offset = 1572864000, lba = 3072000
    offset = 1835008000, lba = 3584000
    offset = 2097152000, lba = 4096000
    seek failed!
    integer value too large to represent as non-long integer
        Attempts: 9
          Offset: 2359296000
        Capacity: 4608000
    tru64% tclsh
    % set chan [open /dev/rrz2c r]
    file5
    % seek $chan 2359296000 start
    integer value too large to represent as non-long integer
    % close $chan 
    % exit
    tru64%
    
    DesiredBehavior:
    I expect seek to allow a sizeof(long) offset value.
    
    
    
    
    
  4. foundin changed to: "obsolete: 8.3.2"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "nobody"
  9. subsystem changed to: "69. Other"
  10. title changed to:
    seek offset is limited to sizeof(int), where sizeof(long) sh
    
  11. type changed to: "Bug"