chiark / gitweb /
fsckd: the error code is actually returned in 'fd'
[elogind.git] / src / test / test-btrfs.c
index 4a08c72fbb5c9ed5b69459f7f1b7d62d77834ff9..c49b83217963f9f66e021d9174ad05277bf1e45d 100644 (file)
@@ -19,7 +19,6 @@
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
-#include <stdlib.h>
 #include <fcntl.h>
 
 #include "log.h"
 
 int main(int argc, char *argv[]) {
         int r;
-        BtrfsSubvolInfo info;
-        char ts[FORMAT_TIMESTAMP_MAX];
         int fd;
 
         fd = open("/", O_RDONLY|O_CLOEXEC|O_DIRECTORY);
         if (fd < 0)
                 log_error_errno(errno, "Failed to open root directory: %m");
         else {
+                BtrfsSubvolInfo info;
+                BtrfsQuotaInfo quota;
+                char ts[FORMAT_TIMESTAMP_MAX], bs[FORMAT_BYTES_MAX];
+
                 r = btrfs_subvol_get_info_fd(fd, &info);
                 if (r < 0)
                         log_error_errno(r, "Failed to get subvolume info: %m");
                 else {
                         log_info("otime: %s", format_timestamp(ts, sizeof(ts), info.otime));
-                        log_info("read-only: %s", yes_no(info.read_only));
+                        log_info("read-only (search): %s", yes_no(info.read_only));
+                }
+
+                r = btrfs_subvol_get_quota_fd(fd, &quota);
+                if (r < 0)
+                        log_error_errno(r, "Failed to get quota info: %m");
+                else {
+                        log_info("referred: %s", strna(format_bytes(bs, sizeof(bs), quota.referred)));
+                        log_info("exclusive: %s", strna(format_bytes(bs, sizeof(bs), quota.exclusive)));
+                        log_info("referred_max: %s", strna(format_bytes(bs, sizeof(bs), quota.referred_max)));
+                        log_info("exclusive_max: %s", strna(format_bytes(bs, sizeof(bs), quota.exclusive_max)));
                 }
 
                 r = btrfs_subvol_get_read_only_fd(fd);
-                assert_se(r >= 0);
+                if (r < 0)
+                        log_error_errno(r, "Failed to get read only flag: %m");
+                else
+                        log_info("read-only (ioctl): %s", yes_no(r));
 
-                log_info("read-only: %s", yes_no(r));
+                safe_close(fd);
         }
 
         r = btrfs_subvol_make("/xxxtest");