1

Background

CLion's remote project feature currently doesn't support FreeBSD as a remote host OS, but I want to do some hacking and see if it works. By reading the log file, I think I have spotted (one of) the issue.

2019-04-10 00:13:55,850 [2221079]  DEBUG -         #com.jetbrains.ssh.nio - UnixSshFS:: SshCommandRunner.execute: test -e "/tmp" 
2019-04-10 00:13:55,851 [2221080]  DEBUG - ellij.ssh.SshConnectionService - Executing SSH command: env "LC_ALL"="C" "JETBRAINS_REMOTE_RUN"="1" test -e "/tmp" within SSH session @3aa57c95 to <user>@<host>::22 
2019-04-10 00:13:55,963 [2221192]  DEBUG -         #com.jetbrains.ssh.nio - UnixSshFS:: SshCommandRunner.execute: stat --printf "%W%i%F%F%F%F%X%Y%s" "/" 
2019-04-10 00:13:55,963 [2221192]  DEBUG - ellij.ssh.SshConnectionService - Executing SSH command: env "LC_ALL"="C" "JETBRAINS_REMOTE_RUN"="1" stat --printf "%W%i%F%F%F%F%X%Y%s" "/" within SSH session @3aa57c95 to <user>@<host>:22 
2019-04-10 00:13:56,071 [2221300]   INFO -         #com.jetbrains.ssh.nio - 
Exit code 1 

Basically, stat(1) behaves differently on Linux and on FreeBSD, so the following command fails on FreeBSD-12.0, halting the entire setting up procedure:

$ stat --printf "%W%i%F%F%F%F%X%Y%s" "/"
stat: illegal option -- -
usage: stat [-FLnq] [-f format | -l | -r | -s | -x] [-t timefmt] [file|handle ...]

I thought that the gstat utility in coreutils is the GNU version of stat, but I turned out to be wrong; they are two different commands. I have also tried translating it myself, but I ended up with something weird:

$ stat -f "%B%i%T%T%T%T%a%Y%z" "/"
15006030802////15041781781024

Question

Is it possible to rewrite the command stat --printf "%W%i%F%F%F%F%X%Y%s" "/" for FreeBSD, so that it works the same way as its counterpart does on GNU/Linux?

3
  • Grab the source for the stat you want and build it on the BSD system?
    – ivanivan
    Apr 9, 2019 at 17:16
  • 1
    @ivanivan Someone has tried to do this before, but they failed :(
    – nalzok
    Apr 9, 2019 at 17:20
  • Write a simple shell script that translates --printf arg to -f and call system stat with that.
    – arrowd
    Apr 9, 2019 at 18:06

1 Answer 1

5
stat -f 0%i%HT%HT%HT%HT%a%m%z /

on FreeBSD should be pretty similar to

stat --printf %W%i%F%F%F%F%X%Y%s /

on Linux, with the exception that %HT will expand to Directory instead of directory, as %F does on Linux.

I just inserted a 0 instead of %W (birth time), since on most Linux systems that will be 0 (unknown). Replace the 0 with %B if you really want the birth time.

That format is quite strange though, and I don't get its purpose; I guess it could be replaced with any "unique" garbage based on file's metadata ;-)


I thought that the gstat utility in coreutils is the GNU version of stat, but I turned out to be wrong; they are two different commands.

gstat on FreeBSD is another program (/usr/sbin/gstat, gstat(8)). You're looking for gnustat:

gnustat --printf %W%i%F%F%F%F%X%Y%s /

Just as with any other package pkg info -l coreutils | grep stat will tell you the files installed by the coreutils package.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .