/*
 * SPDX-FileCopyrightText: 2026 Didier Kryn <kryn@in2p3.fr>
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 */
/*    Function to obtain the type of filesystem installed in a block device    */
/*                       needs library libblkid                                */
/*-----------------------------------------------------------------------------*/
/*    We absolutely need the filesystem type, because mount() requires it, and */
/* some mount options depend on it.  Additionnaly we are interested to know if */
/* if there is a label, which we can use to build the name of the mount point. */
/*-----------------------------------------------------------------------------*/

#include <stdio.h>
#include <string.h>
#include <blkid/blkid.h>
#include "strLcpy.h"

int fsinfo(blkid_cache cache, const char *device,
           char **fstype, char **fslabel)
{
  static char type[80], label[80];
  const char *result;
  result = blkid_get_tag_value(cache, "TYPE", device);
  if(!result) return -1;
  strLcpy(type, result, sizeof(type));
  result = blkid_get_tag_value(cache, "LABEL", device);
  if(!result) label[0] = 0;
  else strLcpy(label, result, sizeof(label));
  *fstype = type;
  *fslabel = label;
  return 0;
}

  
