This file is indexed.

/usr/share/gocode/src/github.com/hanwen/go-fuse/benchmark/statfs.cc is in golang-github-hanwen-go-fuse-dev 0.0~git20171124.0.14c3015-4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// +build !cgo
// g++ -Wall `pkg-config fuse --cflags --libs` statfs.cc -o statfs

#include <unordered_map>
#include <string>

using std::string;
using std::unordered_map;

#define FUSE_USE_VERSION 26

extern "C" {
#include <fuse.h>
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>

useconds_t delay_usec;

class StatFs {
public:
  void readFrom(const string& fn);
  unordered_map<string, bool> is_dir_;

  int GetAttr(const char *name, struct stat *statbuf) {
    if (strcmp(name, "/") == 0) {
      statbuf->st_mode = S_IFDIR | 0777;
      return 0;
    }
    unordered_map<string, bool>::const_iterator it(is_dir_.find(name));
    if (it == is_dir_.end()) {
      return -ENOENT;
    }

    if (it->second) {
      statbuf->st_mode = S_IFDIR | 0777; 
   } else {
      statbuf->st_nlink = 1;
      statbuf->st_mode = S_IFREG | 0666;
    }

    if (delay_usec > 0) {
      usleep(delay_usec);
    }
                         
    return 0;
  }
  
};

StatFs *global;
int global_getattr(const char *name, struct stat *statbuf) {
  return global->GetAttr(name, statbuf);
}

void StatFs::readFrom(const string& fn) {
  FILE *f = fopen(fn.c_str(), "r");

  char line[1024];
  while (char *s = fgets(line, sizeof(line), f)) {
    int l = strlen(s);
    if (line[l-1] == '\n') {
      line[l-1] = '\0';
      l--;
    }
    bool is_dir = line[l-1] == '/';
    if (is_dir) {
      line[l-1] = '\0';
    }
    is_dir_[line] = is_dir;
  }
  fclose(f);
}

int main(int argc, char *argv[])
{
  global = new StatFs;
  // don't want to know about fuselib's option handling
  char *in = getenv("STATFS_INPUT");
  if (!in || !*in) {
    fprintf(stderr, "pass file in $STATFS_INPUT\n");
    exit(2);
  }
  
  global->readFrom(in);
  in = getenv("STATFS_DELAY_USEC");
  if (in != NULL) {
    delay_usec = atoi(in);
  }
  
  struct fuse_operations statfs_oper  = {0};
  statfs_oper.getattr = &global_getattr;
  return fuse_main(argc, argv, &statfs_oper, NULL);
}