Lines Matching refs:fs

16 #include "fs.h"
84 "/sys/fs/bpf",
88 struct fs {
110 static struct fs fs__entries[] = {
149 static bool fs__read_mounts(struct fs *fs)
161 fs->path, type) == 2) {
163 if (strcmp(type, fs->name) == 0)
168 fs->checked = true;
169 return fs->found = found;
172 static int fs__valid_mount(const char *fs, long magic)
176 if (statfs(fs, &st_fs) < 0)
184 static bool fs__check_mounts(struct fs *fs)
188 ptr = fs->mounts;
190 if (fs__valid_mount(*ptr, fs->magic) == 0) {
191 fs->found = true;
192 strcpy(fs->path, *ptr);
211 * Check for "NAME_PATH" environment variable to override fs location (for
215 static bool fs__env_override(struct fs *fs)
218 size_t name_len = strlen(fs->name);
222 memcpy(upper_name, fs->name, name_len);
230 fs->found = true;
231 fs->checked = true;
232 strncpy(fs->path, override_path, sizeof(fs->path) - 1);
233 fs->path[sizeof(fs->path) - 1] = '\0';
237 static const char *fs__get_mountpoint(struct fs *fs)
239 if (fs__env_override(fs))
240 return fs->path;
242 if (fs__check_mounts(fs))
243 return fs->path;
245 if (fs__read_mounts(fs))
246 return fs->path;
253 struct fs *fs = &fs__entries[idx];
255 if (fs->found)
256 return (const char *)fs->path;
263 if (fs->checked)
266 return fs__get_mountpoint(fs);
269 static const char *mount_overload(struct fs *fs)
271 size_t name_len = strlen(fs->name);
275 snprintf(upper_name, name_len, "PERF_%s_ENVIRONMENT", fs->name);
278 return getenv(upper_name) ?: *fs->mounts;
283 struct fs *fs = &fs__entries[idx];
287 return (const char *)fs->path;
289 mountpoint = mount_overload(fs);
291 if (mount(NULL, mountpoint, fs->name, 0, NULL) < 0)
294 return fs__check_mounts(fs) ? fs->path : NULL;