SerCeMan / jnr-fuse

FUSE implementation in Java using Java Native Runtime (JNR)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to set `birth_time` in `getattr`

Kianoosh76 opened this issue · comments

Hi!

I was following your examples for the getattr implementation. But when it comes to the Timespec fields, it won't work anymore

Here's the code:

    @Override
    public int getattr(String path, FileStat stat) {
        try {
            stat.st_uid.set(0);
            stat.st_gid.set(0);
            stat.st_size.set(100);
            stat.st_birthtime.tv_nsec.set(1 << 15); // Throws a NullPointerException
        } catch (Exception e){
            e.printStackTrace();
        }

        return 0;
    }

I couldn't find any documentation about how to instantiate the Timespec fields. Could you provide some hint?

commented

Its definitely far from obvious with no examples...I finally figure this out for my scenario to set the modified time:

stat.st_mtim.tv_nsec.set(System.currentTimeMillis());
stat.st_mtim.tv_sec.set((System.currentTimeMillis() / 1000L));

Thanks!

Yes that worked fine. The problem was that in my linux system birth_time was always null. It does not show that for regular files either