OLD | NEW |
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package os | 5 package os |
6 | 6 |
7 import ( | 7 import ( |
8 "runtime" | 8 "runtime" |
9 "syscall" | 9 "syscall" |
10 ) | 10 ) |
11 | 11 |
12 func epipecheck(file *File, e syscall.Error) { | 12 func epipecheck(file *File, e syscall.Error) { |
13 } | 13 } |
14 | 14 |
15 | 15 |
16 // DevNull is the name of the operating system's ``null device.'' | 16 // DevNull is the name of the operating system's ``null device.'' |
17 // On Unix-like systems, it is "/dev/null"; on Windows, "NUL". | 17 // On Unix-like systems, it is "/dev/null"; on Windows, "NUL". |
18 const DevNull = "/dev/null" | 18 const DevNull = "/dev/null" |
19 | 19 |
20 // Open opens the named file with specified flag (O_RDONLY etc.) and perm. | 20 // OpenFile is the generalized open call; most users will use Open |
21 // If successful, methods on the returned File can be used for I/O. | 21 // or Create instead. It opens the named file with specified flag |
| 22 // (O_RDONLY etc.) and perm, (0666 etc.) if applicable. If successful, |
| 23 // methods on the returned File can be used for I/O. |
22 // It returns the File and an Error, if any. | 24 // It returns the File and an Error, if any. |
23 func Open(name string, flag int, perm uint32) (file *File, err Error) { | 25 func OpenFile(name string, flag int, perm uint32) (file *File, err Error) { |
24 var fd int | 26 var fd int |
25 var e syscall.Error | 27 var e syscall.Error |
26 | 28 |
27 syscall.ForkLock.RLock() | 29 syscall.ForkLock.RLock() |
28 » if flag&O_CREAT == O_CREAT { | 30 » if flag&O_CREATE == O_CREATE { |
29 » » fd, e = syscall.Create(name, flag & ^O_CREAT, perm) | 31 » » fd, e = syscall.Create(name, flag & ^O_CREATE, perm) |
30 } else { | 32 } else { |
31 fd, e = syscall.Open(name, flag) | 33 fd, e = syscall.Open(name, flag) |
32 } | 34 } |
33 syscall.ForkLock.RUnlock() | 35 syscall.ForkLock.RUnlock() |
34 | 36 |
35 if e != nil { | 37 if e != nil { |
36 return nil, &PathError{"open", name, e} | 38 return nil, &PathError{"open", name, e} |
37 } | 39 } |
38 | 40 |
39 return NewFile(fd, name), nil | 41 return NewFile(fd, name), nil |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 return EPLAN9 | 224 return EPLAN9 |
223 } | 225 } |
224 | 226 |
225 func Lchown(name string, uid, gid int) Error { | 227 func Lchown(name string, uid, gid int) Error { |
226 return EPLAN9 | 228 return EPLAN9 |
227 } | 229 } |
228 | 230 |
229 func (f *File) Chown(uid, gid int) Error { | 231 func (f *File) Chown(uid, gid int) Error { |
230 return EPLAN9 | 232 return EPLAN9 |
231 } | 233 } |
OLD | NEW |