]> Cypherpunks repositories - gostls13.git/commitdiff
add fstat, stat
authorRob Pike <r@golang.org>
Sat, 26 Jul 2008 23:22:14 +0000 (16:22 -0700)
committerRob Pike <r@golang.org>
Sat, 26 Jul 2008 23:22:14 +0000 (16:22 -0700)
R=ken
OCL=13497
CL=13497

src/syscall/Makefile
src/syscall/stat_amd64_darwin.go [new file with mode: 0644]
src/syscall/stat_amd64_linux.go [new file with mode: 0644]
src/syscall/syscall.go
src/syscall/syscall_amd64_darwin.s
src/syscall/syscall_amd64_linux.s

index fc21794c70f5f68a7892ed65cec607c59bf0ccf4..c5257b6a5fb69a603495ba2846ca49518177109f 100644 (file)
@@ -13,6 +13,7 @@ PKG=syscall.a
 OFILES=\
        syscall.$O \
        errstr_$(GOOS).$O \
+       stat_$(GOARCH)_$(GOOS).$O \
        syscall_$(GOARCH)_$(GOOS).$O \
 
 
diff --git a/src/syscall/stat_amd64_darwin.go b/src/syscall/stat_amd64_darwin.go
new file mode 100644 (file)
index 0000000..84a09d2
--- /dev/null
@@ -0,0 +1,49 @@
+// Copyright 2009 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package syscall
+
+func stat(*byte, *Stat) (ret int64, errno int64);
+func fstat(int64, *Stat) (ret int64, errno int64);
+
+export Stat
+export stat, fstat
+
+// Stat and relatives for Linux
+
+type dev_t uint32;
+type ino_t uint64;
+type mode_t uint16;
+type nlink_t uint16;
+type uid_t uint32;
+type gid_t uint32;
+type off_t int64;
+type blksize_t int64;
+type blkcnt_t int64;
+type time_t int64;
+
+type Timespec struct {
+       tv_sec  time_t;
+       tv_nsec int64;
+}
+
+type Stat struct {
+       st_dev  dev_t;     /* ID of device containing file */
+       st_mode mode_t;    /* protection */
+       st_nlink        nlink_t;   /* number of hard links */
+       st_ino  ino_t;     /* inode number */
+       st_uid  uid_t;     /* user ID of owner */
+       st_gid  gid_t;     /* group ID of owner */
+       st_rdev dev_t;    /* device ID (if special file) */
+       st_atime        Timespec;   /* time of last access */
+       st_mtime        Timespec;   /* time of last modification */
+       st_ctime        Timespec;   /* time of last status change */
+       st_birthtimespec        Timespec;   /* birth time */
+       st_size off_t;    /* total size, in bytes */
+       st_blocks       blkcnt_t;  /* number of blocks allocated */
+       st_blksize      blksize_t; /* blocksize for filesystem I/O */
+       st_flags        uint32;
+       st_gen          uint32;
+       st_qspare[2]    int64;
+}
diff --git a/src/syscall/stat_amd64_linux.go b/src/syscall/stat_amd64_linux.go
new file mode 100644 (file)
index 0000000..92d99e4
--- /dev/null
@@ -0,0 +1,47 @@
+// Copyright 2009 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package syscall
+
+func stat(*byte, *Stat) (ret int64, errno int64);
+func fstat(int64, *Stat) (ret int64, errno int64);
+
+export Stat
+export stat, fstat
+
+// Stat and relatives for Linux
+
+type dev_t uint64;
+type ino_t uint64;
+type mode_t uint32;
+type nlink_t uint64;
+type uid_t uint32;
+type gid_t uint32;
+type off_t int64;
+type blksize_t int64;
+type blkcnt_t int64;
+type time_t int64;
+
+type Timespec struct {
+       tv_sec  time_t;
+       tv_nsec int64;
+}
+
+type Stat struct {
+       st_dev  dev_t;     /* ID of device containing file */
+       st_ino  ino_t;     /* inode number */
+       st_nlink        nlink_t;   /* number of hard links */
+       st_mode mode_t;    /* protection */
+       st_uid  uid_t;     /* user ID of owner */
+       st_gid  gid_t;     /* group ID of owner */
+       pad0    int32;
+       st_rdev dev_t;    /* device ID (if special file) */
+       st_size off_t;    /* total size, in bytes */
+       st_blksize      blksize_t; /* blocksize for filesystem I/O */
+       st_blocks       blkcnt_t;  /* number of blocks allocated */
+       st_atime        Timespec;   /* time of last access */
+       st_mtime        Timespec;   /* time of last modification */
+       st_ctime        Timespec;   /* time of last status change */
+}
+
index 49d7401ed47a073d117da9edc86f061fd20797d2..f6277d414f667fb73cb1ae83d334e4075050e4a1 100644 (file)
@@ -4,8 +4,12 @@
 
 package syscall
 
-// for simplicity of addressing in assembler, all integers are 64 bits
-// in these calling sequences.
+/*
+ * These calls have signatures that are independent of operating system.
+ *
+ * For simplicity of addressing in assembler, all integers are 64 bits
+ * in these calling sequences.
+ */
 
 func open(*byte, int64) (ret int64, errno int64);
 func close(int64) (ret int64, errno int64);
index a87352e8e2ba8f7a8479e2d25268b2b09a386543..3f32ff653b9e67b5d6f28c70e6862c65e06a703e 100644 (file)
@@ -6,13 +6,6 @@
 // System calls for AMD64, Darwin
 //
 
-//TEXT syscall·exit(SB),1,$-8
-//     MOVL    8(SP), DI               // arg 1 exit status
-//     MOVL    $(0x2000000+1), AX      // syscall entry
-//     SYSCALL
-//     CALL    notok(SB)
-//     RET
-
 TEXT   syscall·open(SB),1,$-8
        MOVQ    8(SP), DI
        MOVQ    16(SP), SI
@@ -67,41 +60,28 @@ TEXT        syscall·write(SB),1,$-8
        MOVQ    $0, 40(SP)
        RET
 
-//TEXT fstat(SB),1,$-8
-//     MOVL    8(SP), DI
-//     MOVQ    16(SP), SI
-//     MOVL    $(0x2000000+339), AX    // syscall entry; really fstat64
-//     SYSCALL
-//     RET
-//
-//TEXT syscall·sigaction(SB),1,$-8
-//     MOVL    8(SP), DI               // arg 1 sig
-//     MOVQ    16(SP), SI              // arg 2 act
-//     MOVQ    24(SP), DX              // arg 3 oact
-//     MOVQ    24(SP), CX              // arg 3 oact
-//     MOVQ    24(SP), R10             // arg 3 oact
-//     MOVL    $(0x2000000+46), AX     // syscall entry
-//     SYSCALL
-//     JCC     2(PC)
-//     CALL    notok(SB)
-//     RET
-//
-//TEXT sigtramp(SB),1,$24
-//     MOVL    DX,0(SP)
-//     MOVQ    CX,8(SP)
-//     MOVQ    R8,16(SP)
-//     CALL    sighandler(SB)
-//     RET
-//
-//TEXT syscall·mmap(SB),1,$-8
-//     MOVQ    8(SP), DI               // arg 1 addr
-//     MOVL    16(SP), SI              // arg 2 len
-//     MOVL    20(SP), DX              // arg 3 prot
-//     MOVL    24(SP), R10             // arg 4 flags
-//     MOVL    28(SP), R8              // arg 5 fid
-//     MOVL    32(SP), R9              // arg 6 offset
-//     MOVL    $(0x2000000+197), AX    // syscall entry
-//     SYSCALL
-//     JCC     2(PC)
-//     CALL    notok(SB)
-//     RET
+TEXT   syscall·stat(SB),1,$-8
+       MOVQ    8(SP), DI
+       MOVQ    16(SP), SI
+       MOVL    $(0x2000000+338), AX    // syscall entry
+       SYSCALL
+       JCC     4(PC)
+       MOVQ    $-1, 24(SP)
+       MOVQ    AX, 32(SP)
+       RET
+       MOVQ    AX, 24(SP)
+       MOVQ    $0, 32(SP)
+       RET
+
+TEXT   syscall·fstat(SB),1,$-8
+       MOVQ    8(SP), DI
+       MOVQ    16(SP), SI
+       MOVL    $(0x2000000+339), AX    // syscall entry
+       SYSCALL
+       JCC     4(PC)
+       MOVQ    $-1, 24(SP)
+       MOVQ    AX, 32(SP)
+       RET
+       MOVQ    AX, 24(SP)
+       MOVQ    $0, 32(SP)
+       RET
index 9690a96362a9ab4ff08f1c84fc1a0c1da2525172..7eab69fc0d84e9033d8e5b96823588cf2f62bc91 100644 (file)
@@ -6,12 +6,6 @@
 // System calls for AMD64, Linux
 //
 
-//TEXT sys·exit(SB),1,$0-8
-//     MOVL    8(SP), DI
-//     MOVL    $60, AX
-//     SYSCALL
-//     RET
-
 TEXT   syscall·open(SB),1,$0-16
        MOVQ    8(SP), DI
        MOVQ    16(SP), SI
@@ -42,13 +36,6 @@ TEXT syscall·close(SB),1,$0-16
        MOVQ    $0, 24(SP)
        RET
 
-//TEXT fstat(SB),1,$0-16
-//     MOVL    8(SP), DI
-//     MOVQ    16(SP), SI
-//     MOVL    $5, AX                  // syscall entry
-//     SYSCALL
-//     RET
-
 TEXT   syscall·read(SB),1,$0-16
        MOVL    8(SP), DI
        MOVQ    16(SP), SI
@@ -81,43 +68,34 @@ TEXT        syscall·write(SB),1,$0-16
        MOVQ    $0, 40(SP)
        RET
 
-//TEXT sys·rt_sigaction(SB),1,$0-32
-//     MOVL    8(SP), DI
-//     MOVQ    16(SP), SI
-//     MOVQ    24(SP), DX
-//     MOVQ    32(SP), CX
-//     MOVL    CX, R10
-//     MOVL    $13, AX                 // syscall entry
-//     SYSCALL
-//     RET
-//
-//TEXT sigtramp(SB),1,$24-16
-//     MOVQ    DI,0(SP)
-//     MOVQ    SI,8(SP)
-//     MOVQ    DX,16(SP)
-//     CALL    sighandler(SB)
-//     RET
-//
-//TEXT sys·mmap(SB),1,$0-32
-//     MOVQ    8(SP), DI
-//     MOVL    16(SP), SI
-//     MOVL    20(SP), DX
-//     MOVL    24(SP), CX
-//     MOVL    28(SP), R8
-//     MOVL    32(SP), R9
-//
-///* flags arg for ANON is 1000 but sb 20 */
-//     MOVL    CX, AX
-//     ANDL    $~0x1000, CX
-//     ANDL    $0x1000, AX
-//     SHRL    $7, AX
-//     ORL     AX, CX
-//
-//     MOVL    CX, R10
-//     MOVL    $9, AX                  // syscall entry
-//     SYSCALL
-//     CMPQ    AX, $0xfffffffffffff001
-//     JLS     2(PC)
-//     CALL    notok(SB)
-//     RET
-//
+TEXT   syscall·stat(SB),1,$0-16
+       MOVQ    8(SP), DI
+       MOVQ    16(SP), SI
+       MOVQ    $0, DX
+       MOVQ    $5, AX                  // syscall entry
+       SYSCALL
+       CMPQ    AX, $0xfffffffffffff001
+       JLS     5(PC)
+       MOVQ    $-1, 24(SP)
+       NEGQ    AX
+       MOVQ    AX, 32(SP)
+       RET
+       MOVQ    AX, 24(SP)
+       MOVQ    $0, 32(SP)
+       RET
+
+TEXT   syscall·fstat(SB),1,$0-16
+       MOVL    8(SP), DI
+       MOVQ    16(SP), SI
+       MOVQ    $0, DX
+       MOVQ    $5, AX                  // syscall entry
+       SYSCALL
+       CMPQ    AX, $0xfffffffffffff001
+       JLS     5(PC)
+       MOVQ    $-1, 24(SP)
+       NEGQ    AX
+       MOVQ    AX, 32(SP)
+       RET
+       MOVQ    AX, 24(SP)
+       MOVQ    $0, 32(SP)
+       RET