Lines Matching refs:fs

91 struct fs {  struct
103 static void fs__init_once(struct fs *fs); argument
104 static const char *fs__mountpoint(const struct fs *fs);
105 static const char *fs__mount(struct fs *fs);
108 static struct fs fs__##lower_name = { \
117 struct fs *fs = &fs__##lower_name; \
119 fs__init_once(fs); \
125 struct fs *fs = &fs__##lower_name; \
128 return fs__mountpoint(fs); \
134 struct fs *fs = &fs__##lower_name; \
139 return fs__mount(fs); \
154 static bool fs__read_mounts(struct fs *fs) in fs__read_mounts() argument
167 if (strcmp(type, fs->name) == 0) { in fs__read_mounts()
168 fs->path = strdup(path); in fs__read_mounts()
170 return fs->path != NULL; in fs__read_mounts()
177 static int fs__valid_mount(const char *fs, long magic) in fs__valid_mount() argument
181 if (statfs(fs, &st_fs) < 0) in fs__valid_mount()
189 static bool fs__check_mounts(struct fs *fs) in fs__check_mounts() argument
193 ptr = fs->mounts; in fs__check_mounts()
195 if (fs__valid_mount(*ptr, fs->magic) == 0) { in fs__check_mounts()
196 fs->path = strdup(*ptr); in fs__check_mounts()
197 if (!fs->path) in fs__check_mounts()
221 static bool fs__env_override(struct fs *fs) in fs__env_override() argument
224 size_t name_len = strlen(fs->name); in fs__env_override()
228 memcpy(upper_name, fs->name, name_len); in fs__env_override()
236 fs->path = strdup(override_path); in fs__env_override()
237 if (!fs->path) in fs__env_override()
242 static void fs__init_once(struct fs *fs) in fs__init_once() argument
244 if (!fs__env_override(fs) && in fs__init_once()
245 !fs__check_mounts(fs) && in fs__init_once()
246 !fs__read_mounts(fs)) { in fs__init_once()
247 assert(!fs->path); in fs__init_once()
249 assert(fs->path); in fs__init_once()
253 static const char *fs__mountpoint(const struct fs *fs) in fs__mountpoint() argument
255 return fs->path; in fs__mountpoint()
258 static const char *mount_overload(struct fs *fs) in mount_overload() argument
260 size_t name_len = strlen(fs->name); in mount_overload()
264 snprintf(upper_name, name_len, "PERF_%s_ENVIRONMENT", fs->name); in mount_overload()
267 return getenv(upper_name) ?: *fs->mounts; in mount_overload()
270 static const char *fs__mount(struct fs *fs) in fs__mount() argument
274 pthread_mutex_lock(&fs->mount_mutex); in fs__mount()
277 mountpoint = fs__mountpoint(fs); in fs__mount()
281 mountpoint = mount_overload(fs); in fs__mount()
283 if (mount(NULL, mountpoint, fs->name, 0, NULL) == 0 && in fs__mount()
284 fs__valid_mount(mountpoint, fs->magic) == 0) { in fs__mount()
285 fs->path = strdup(mountpoint); in fs__mount()
286 mountpoint = fs->path; in fs__mount()
289 pthread_mutex_unlock(&fs->mount_mutex); in fs__mount()