Example #1
0
int ndmfhdb_file_lookup(struct ndmfhdb* fhcb,
                        char* path,
                        ndmp9_file_stat* fstat)
{
  int rc, off;
  char* p;
  char key[2048];
  char linebuf[2048];

  snprintf(key, sizeof(key), "DHf ");
  p = NDMOS_API_STREND(key);

  ndmcstr_from_str(path, p, sizeof key - (p - key) - 10);

  strcat(p, " UNIX ");

  p = NDMOS_API_STREND(key);
  off = p - key;

  rc = ndmbstf_first(fhcb->fp, key, linebuf, sizeof linebuf);

  if (rc <= 0) { return rc; /* error or not found */ }

  rc = ndm_fstat_from_str(fstat, linebuf + off);
  if (rc < 0) { return rc; }

  return 1;
}
Example #2
0
int ndmfhdb_dir_lookup(struct ndmfhdb* fhcb,
                       uint64_t dir_node,
                       char* name,
                       uint64_t* node_p)
{
  int rc, off;
  char* p;
  char key[256 + 128];
  char linebuf[2048];

  snprintf(key, sizeof(key), "DHd %llu ", dir_node);
  p = NDMOS_API_STREND(key);

  ndmcstr_from_str(name, p, sizeof key - (p - key) - 10);

  strcat(p, " UNIX ");

  p = NDMOS_API_STREND(key);
  off = p - key;

  rc = ndmbstf_first(fhcb->fp, key, linebuf, sizeof linebuf);

  if (rc <= 0) { return rc; /* error or not found */ }

  *node_p = NDMOS_API_STRTOLL(linebuf + off, &p, 0);

  if (*p != 0) { return -10; }

  return 1;
}
Example #3
0
int
ndmfhdb_add_dir (struct ndmlog *ixlog, int tagc,
  char *raw_name, ndmp9_u_quad dir_node, ndmp9_u_quad node)
{
	char		prefix[8];
	char		namebuf[NDMOS_CONST_PATH_MAX];

	strcpy (prefix, "DHd");
	prefix[0] = tagc;

	ndmcstr_from_str (raw_name, namebuf, sizeof namebuf);

	ndmlogf (ixlog, prefix, 0, "%llu %s UNIX %llu",
		dir_node, namebuf, node);

	return 0;
}
Example #4
0
int
ndmfhdb_add_file (struct ndmlog *ixlog, int tagc,
  char *raw_name, ndmp9_file_stat *fstat)
{
	char		prefix[8];
	char		statbuf[100];
	char		namebuf[NDMOS_CONST_PATH_MAX];

	strcpy (prefix, "DHf");
	prefix[0] = tagc;

	ndm_fstat_to_str (fstat, statbuf);

	ndmcstr_from_str (raw_name, namebuf, sizeof namebuf);

	ndmlogf (ixlog, prefix, 0, "%s UNIX %s", namebuf, statbuf);

	return 0;
}