Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2002-02-15
21:42 • Closed ticket [219396ffff]: seek offset is limited to sizeof(int), where sizeof(... artifact: 6fb305823c user: dkf
21:42 • Ticket [219396ffff]: 1 change artifact: 01f2d8cbf6 user: dkf
21:42 • Open ticket [219396ffff]. artifact: b0ac69587c user: dkf
21:42 • Open ticket [219396ffff]. artifact: c2d4665aa8 user: dkf
2001-09-20
17:38 • Ticket [219396ffff]: 6 changes artifact: 1692c5058c user: dkf
2001-04-03
06:19 • Ticket [219396ffff]: 1 change artifact: 065cab53f4 user: dgp
2000-11-28
20:33 • Ticket [219396ffff]: 4 changes artifact: b3928050af user: dkf
2000-11-15
22:13 • Ticket [219396ffff]: 1 change artifact: 1a4dbd452a user: dkf
2000-10-26
05:12 • New ticket [219396ffff]. artifact: af91b7326e user: nobody

seek offset is limited to sizeof(int), where sizeof(long) sh

Closed / Fixed219396ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 25 years ago
Descriptionplain2000-10-26 05:12:23
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.
dkf Ticket [219396ffff]: 1 change [History diff]2000-11-15 22:13:10
dkfplain2000-11-28 20:33:06
Yet another instance of the problems Tcl has with the difference between 32 bits and 64 bits (which also bites in expressions and clock handling; maybe elsewhere too) and which will take a concerted piece of monster effort to fix.  I'm not even sure that the underlying API for seeks to non-32bit locations is common across all UNIX platforms; if this is the case, then additional configure tests will be needed too.  :^(
dgp Ticket [219396ffff]: 1 change [History diff]2001-04-03 06:19:31
dkfplain2001-09-20 17:38:06
Logged In: YES 
user_id=79902

Assigning to myself really just to remind me that this is a
sort-of duplicate of another bug I'm thinking of how to fix.
dkf Open ticket [219396ffff]. [History diff]2002-02-15 21:42:25
dkf Open ticket [219396ffff]. [History diff]2002-02-15 21:42:26
dkf Ticket [219396ffff]: 1 change [History diff]2002-02-15 21:42:27
dkf Closed ticket [219396ffff]. [History diff]2002-02-15 21:42:28
Log in (anonymous is fine) to add a comment.