The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/contrib/openzfs/tests/zfs-tests/cmd/getversion.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * This file and its contents are supplied under the terms of the
    3  * Common Development and Distribution License ("CDDL"), version 1.0.
    4  * You may only use this file in accordance with the terms of version
    5  * 1.0 of the CDDL.
    6  *
    7  * A full copy of the text of the CDDL should have accompanied this
    8  * source.  A copy of the CDDL is also available via the Internet at
    9  * http://www.illumos.org/license/CDDL.
   10  */
   11 
   12 /*
   13  * Copyright 2021 iXsystems, Inc.
   14  */
   15 
   16 /*
   17  * FreeBSD and macOS expose file generation number through stat(2) and stat(1).
   18  * Linux exposes it instead through an ioctl.
   19  */
   20 
   21 #include <sys/ioctl.h>
   22 #include <sys/fcntl.h>
   23 #include <linux/fs.h>
   24 #include <err.h>
   25 #include <stdio.h>
   26 #include <stdlib.h>
   27 #include <unistd.h>
   28 
   29 int
   30 main(int argc, const char * const argv[])
   31 {
   32         if (argc != 2)
   33                 errx(EXIT_FAILURE, "usage: %s filename", argv[0]);
   34 
   35         int fd = open(argv[1], O_RDONLY);
   36         if (fd == -1)
   37                 err(EXIT_FAILURE, "failed to open %s", argv[1]);
   38 
   39         int gen = 0;
   40         if (ioctl(fd, FS_IOC_GETVERSION, &gen) == -1)
   41                 err(EXIT_FAILURE, "FS_IOC_GETVERSION failed");
   42 
   43         (void) close(fd);
   44 
   45         (void) printf("%d\n", gen);
   46 
   47         return (EXIT_SUCCESS);
   48 }

Cache object: e12a291df2711f74555c3d16843fecb8


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.