mirror of
https://github.com/golang/go
synced 2024-11-22 22:10:03 -07:00
add lstat
clean up some code fix comments add paramter names to interface R=ken OCL=13521 CL=13521
This commit is contained in:
parent
4a9b4e6604
commit
d302244c6c
@ -329,8 +329,6 @@ func init(){
|
||||
error[ELAST] = "Must be equal largest errno";
|
||||
}
|
||||
|
||||
var digits string = "0123456789"
|
||||
|
||||
func str(val int64) string { // do it here rather than with fmt to avoid dependency
|
||||
if val < 0 {
|
||||
return "-" + str(-val);
|
||||
@ -338,11 +336,11 @@ func str(val int64) string { // do it here rather than with fmt to avoid depend
|
||||
var buf [32]byte; // big enough for int64
|
||||
i := len(buf)-1;
|
||||
for val >= 10 {
|
||||
buf[i] = digits[val%10];
|
||||
buf[i] = val%10 + '0';
|
||||
i--;
|
||||
val /= 10;
|
||||
}
|
||||
buf[i] = digits[val];
|
||||
buf[i] = val + '0';
|
||||
return string(buf)[i:len(buf)];
|
||||
}
|
||||
|
||||
|
@ -403,8 +403,6 @@ func init(){
|
||||
error[EKEYREJECTED] = "Key was rejected by service";
|
||||
}
|
||||
|
||||
var digits string = "0123456789"
|
||||
|
||||
func str(val int64) string { // do it here rather than with fmt to avoid dependency
|
||||
if val < 0 {
|
||||
return "-" + str(-val);
|
||||
@ -412,11 +410,11 @@ func str(val int64) string { // do it here rather than with fmt to avoid depend
|
||||
var buf [32]byte; // big enough for int64
|
||||
i := len(buf)-1;
|
||||
for val >= 10 {
|
||||
buf[i] = digits[val%10];
|
||||
buf[i] = val%10 + '0';
|
||||
i--;
|
||||
val /= 10;
|
||||
}
|
||||
buf[i] = digits[val];
|
||||
buf[i] = val + '0';
|
||||
return string(buf)[i:len(buf)];
|
||||
}
|
||||
|
||||
|
@ -4,13 +4,14 @@
|
||||
|
||||
package syscall
|
||||
|
||||
func stat(*byte, *Stat) (ret int64, errno int64);
|
||||
func fstat(int64, *Stat) (ret int64, errno int64);
|
||||
func stat(name *byte, buf *Stat) (ret int64, errno int64);
|
||||
func fstat(fd int64, buf *Stat) (ret int64, errno int64);
|
||||
func lstat(name *byte, buf *Stat) (ret int64, errno int64);
|
||||
|
||||
export Stat
|
||||
export stat, fstat
|
||||
export stat, fstat, lstat
|
||||
|
||||
// Stat and relatives for Linux
|
||||
// Stat and relatives for Darwin
|
||||
|
||||
type dev_t uint32;
|
||||
type ino_t uint64;
|
||||
|
@ -4,11 +4,12 @@
|
||||
|
||||
package syscall
|
||||
|
||||
func stat(*byte, *Stat) (ret int64, errno int64);
|
||||
func fstat(int64, *Stat) (ret int64, errno int64);
|
||||
func stat(name *byte, buf *Stat) (ret int64, errno int64);
|
||||
func fstat(fd int64, buf *Stat) (ret int64, errno int64);
|
||||
func lstat(name *byte, buf *Stat) (ret int64, errno int64);
|
||||
|
||||
export Stat
|
||||
export stat, fstat
|
||||
export stat, fstat, lstat
|
||||
|
||||
// Stat and relatives for Linux
|
||||
|
||||
|
@ -11,9 +11,9 @@ package syscall
|
||||
* in these calling sequences.
|
||||
*/
|
||||
|
||||
func open(*byte, int64) (ret int64, errno int64);
|
||||
func close(int64) (ret int64, errno int64);
|
||||
func read(int64, *byte, int64) (ret int64, errno int64);
|
||||
func write(int64, *byte, int64) (ret int64, errno int64);
|
||||
func open(name *byte, mode int64) (ret int64, errno int64);
|
||||
func close(fd int64) (ret int64, errno int64);
|
||||
func read(fd int64, buf *byte, nbytes int64) (ret int64, errno int64);
|
||||
func write(fd int64, buf *byte, nbytes int64) (ret int64, errno int64);
|
||||
|
||||
export open, close, read, write
|
||||
|
@ -85,3 +85,16 @@ TEXT syscall·fstat(SB),1,$-8
|
||||
MOVQ AX, 24(SP)
|
||||
MOVQ $0, 32(SP)
|
||||
RET
|
||||
|
||||
TEXT syscall·lstat(SB),1,$-8
|
||||
MOVQ 8(SP), DI
|
||||
MOVQ 16(SP), SI
|
||||
MOVL $(0x2000000+340), 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
|
||||
|
@ -99,3 +99,19 @@ TEXT syscall·fstat(SB),1,$0-16
|
||||
MOVQ AX, 24(SP)
|
||||
MOVQ $0, 32(SP)
|
||||
RET
|
||||
|
||||
TEXT syscall·lstat(SB),1,$0-16
|
||||
MOVL 8(SP), DI
|
||||
MOVQ 16(SP), SI
|
||||
MOVQ $0, DX
|
||||
MOVQ $6, 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
|
||||
|
Loading…
Reference in New Issue
Block a user