libroot_debug: Merge guarded heap into libroot_debug.
[haiku.git] / src / system / libroot / os / fs_info.c
blobd9bb11d158fb1565953cdf99d6db68e0575e79b9
1 /*
2 ** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3 ** Distributed under the terms of the Haiku License.
4 */
7 #include <fs_info.h>
9 #include <stdlib.h>
10 #include <fcntl.h>
11 #include <errno.h>
13 #include <errno_private.h>
14 #include <syscalls.h>
17 #define RETURN_AND_SET_ERRNO(status) \
18 { \
19 if (status < 0) { \
20 __set_errno(status); \
21 return -1; \
22 } \
23 return status; \
27 dev_t
28 dev_for_path(const char *path)
30 struct stat stat;
31 int status = _kern_read_stat(-1, path, true, &stat, sizeof(struct stat));
32 if (status == B_OK)
33 return stat.st_dev;
35 RETURN_AND_SET_ERRNO(status);
39 dev_t
40 next_dev(int32 *_cookie)
42 return _kern_next_device(_cookie);
43 // For some reason, this one returns its error code directly
47 int
48 fs_stat_dev(dev_t device, fs_info *info)
50 status_t status = _kern_read_fs_info(device, info);
52 RETURN_AND_SET_ERRNO(status);