Lines Matching refs:fs

90 struct fs {  struct
102 static void fs__init_once(struct fs *fs); argument
103 static const char *fs__mountpoint(const struct fs *fs);
104 static const char *fs__mount(struct fs *fs);
107 static struct fs fs__##lower_name = { \
116 struct fs *fs = &fs__##lower_name; \
118 fs__init_once(fs); \
124 struct fs *fs = &fs__##lower_name; \
127 return fs__mountpoint(fs); \
133 struct fs *fs = &fs__##lower_name; \
138 return fs__mount(fs); \
153 static bool fs__read_mounts(struct fs *fs) in fs__read_mounts() argument
166 if (strcmp(type, fs->name) == 0) { in fs__read_mounts()
167 fs->path = strdup(path); in fs__read_mounts()
169 return fs->path != NULL; in fs__read_mounts()
176 static int fs__valid_mount(const char *fs, long magic) in fs__valid_mount() argument
180 if (statfs(fs, &st_fs) < 0) in fs__valid_mount()
188 static bool fs__check_mounts(struct fs *fs) in fs__check_mounts() argument
192 ptr = fs->mounts; in fs__check_mounts()
194 if (fs__valid_mount(*ptr, fs->magic) == 0) { in fs__check_mounts()
195 fs->path = strdup(*ptr); in fs__check_mounts()
196 if (!fs->path) in fs__check_mounts()
220 static bool fs__env_override(struct fs *fs) in fs__env_override() argument
223 size_t name_len = strlen(fs->name); in fs__env_override()
227 memcpy(upper_name, fs->name, name_len); in fs__env_override()
235 fs->path = strdup(override_path); in fs__env_override()
236 if (!fs->path) in fs__env_override()
241 static void fs__init_once(struct fs *fs) in fs__init_once() argument
243 if (!fs__env_override(fs) && in fs__init_once()
244 !fs__check_mounts(fs) && in fs__init_once()
245 !fs__read_mounts(fs)) { in fs__init_once()
246 assert(!fs->path); in fs__init_once()
248 assert(fs->path); in fs__init_once()
252 static const char *fs__mountpoint(const struct fs *fs) in fs__mountpoint() argument
254 return fs->path; in fs__mountpoint()
257 static const char *mount_overload(struct fs *fs) in mount_overload() argument
259 size_t name_len = strlen(fs->name); in mount_overload()
263 snprintf(upper_name, name_len, "PERF_%s_ENVIRONMENT", fs->name); in mount_overload()
266 return getenv(upper_name) ?: *fs->mounts; in mount_overload()
269 static const char *fs__mount(struct fs *fs) in fs__mount() argument
273 pthread_mutex_lock(&fs->mount_mutex); in fs__mount()
276 mountpoint = fs__mountpoint(fs); in fs__mount()
280 mountpoint = mount_overload(fs); in fs__mount()
282 if (mount(NULL, mountpoint, fs->name, 0, NULL) == 0 && in fs__mount()
283 fs__valid_mount(mountpoint, fs->magic) == 0) { in fs__mount()
284 fs->path = strdup(mountpoint); in fs__mount()
285 mountpoint = fs->path; in fs__mount()
288 pthread_mutex_unlock(&fs->mount_mutex); in fs__mount()