Example #1
0
int main (int argc, char *argv[])
{
	int	i;
	int	id = DEFAULT_ID;

	if (argc == 1)
		PrintUsage;

	if (*argv[1] == '-')
	{
		if ((0 != STRNCMP_LIT(argv[1], ID_PREFIX)) || ('\0' == argv[1][SIZEOF(ID_PREFIX) - 1]))
			PrintUsage;

		errno = 0;
		if (((id = ATOI(argv[1] + SIZEOF(ID_PREFIX) - 1)) == 0 && errno != 0) || id <= 0)
		{
			FPRINTF(stderr, "Invalid id %s specified, using default id %d\n", \
					argv[1] + SIZEOF(ID_PREFIX) - 1, DEFAULT_ID);
			id = DEFAULT_ID;
		}
		i = 2;
	} else
		i = 1;

	PRINTF("\n");

	for ( ; i < argc; i++)
	{
		PRINTF("%20s  ::  %d  [ 0x%x ]\n", argv[i], FTOK(argv[i], id), FTOK(argv[i], id));
	}
	PRINTF("\n");
	return 0;
}
Example #2
0
/* Work around Linux kernel issues on BTRFS and EXT4 before 2.6.39.
   FIXME: remove in 2013, or whenever we're pretty confident
   that the offending, unpatched kernels are no longer in use.  */
static bool
extent_need_sync (void)
{
    /* For now always return true, to be on the safe side.
       If/when FIEMAP semantics are well defined (before SEEK_HOLE support
       is usable) and kernels implementing them are in use, we may relax
       this once again.  */
    return true;

#if FIEMAP_BEHAVIOR_IS_DEFINED_AND_USABLE
    static int need_sync = -1;

    if (need_sync == -1)
    {
        struct utsname name;
        need_sync = 0; /* No workaround by default.  */

# ifdef __linux__
        if (uname (&name) != -1 && STRNCMP_LIT (name.release, "2.6.") == 0)
        {
            unsigned long val;
            if (xstrtoul (name.release + 4, NULL, 10, &val, NULL) == LONGINT_OK)
            {
                if (val < 39)
                    need_sync = 1;
            }
        }
# endif
    }

    return need_sync;
#endif
}