Skip to content

Commit

Permalink
Add missing fun def for __xstat (#11985)
Browse files Browse the repository at this point in the history
Fixes #11157 (comment)

Also includes two small cleanups/refactors.
  • Loading branch information
straight-shoota authored Apr 21, 2022
1 parent e34020d commit 124a663
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/crystal/system/unix/file.cr
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,23 @@ module Crystal::System::File

def self.stat(path, stat)
{% if LibC.has_method?(:__xstat) %}
LibC.__xstat(1, path, stat)
LibC.__xstat(LibC::STAT_VER, path, stat)
{% else %}
LibC.stat(path, stat)
{% end %}
end

def self.fstat(path, stat)
{% if LibC.has_method?(:__fxstat) %}
LibC.__fxstat(1, path, stat)
LibC.__fxstat(LibC::STAT_VER, path, stat)
{% else %}
LibC.fstat(path, stat)
{% end %}
end

def self.lstat(path, stat)
{% if LibC.has_method?(:__lxstat) %}
LibC.__lxstat(1, path, stat)
LibC.__lxstat(LibC::STAT_VER, path, stat)
{% else %}
LibC.lstat(path, stat)
{% end %}
Expand Down
4 changes: 3 additions & 1 deletion src/lib_c/x86_64-linux-gnu/c/sys/stat.cr
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,17 @@ lib LibC
__glibc_reserved : StaticArray(Long, 3)
end

STAT_VER = 1

fun chmod(file : Char*, mode : ModeT) : Int
fun fstat(fd : Int, buf : Stat*) : Int
fun __fxstat(ver : Int, fd : Int, buf : Stat*) : Int
fun lstat(file : Char*, buf : Stat*) : Int
fun __fxstat(ver : Int, fd : Int, buf : Stat*) : Int
fun __lxstat(ver : Int, file : Char*, buf : Stat*) : Int
fun mkdir(path : Char*, mode : ModeT) : Int
fun mkfifo(path : Char*, mode : ModeT) : Int
fun mknod(path : Char*, mode : ModeT, dev : DevT) : Int
fun stat(file : Char*, buf : Stat*) : Int
fun __xstat(ver : Int, file : Char*, buf : Stat*) : Int
fun umask(mask : ModeT) : ModeT
end

0 comments on commit 124a663

Please sign in to comment.