summaryrefslogtreecommitdiff
path: root/minix/lib/libpuffs/utility.c
blob: 4c0a6bad8be1a61bbdcbec107fb5ef3d00e71210 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/* Created (MFS based):
 *   February 2010 (Evgeniy Ivanov)
 */

#include "fs.h"

#include <stdarg.h>

/*
 * Match by inode number in a puffs_pn_nodewalk call.  This should not exist.
 */
void *
find_inode_cb(struct puffs_usermount * __unused pu, struct puffs_node * pn,
	void * arg)
{

	if (pn->pn_va.va_fileid == *(ino_t *)arg)
		return pn;
	else
		return NULL;
}

/*===========================================================================*
 *				update_timens				     *
 *===========================================================================*/
int update_timens(struct puffs_node *pn, int flags, struct timespec *t)
{
  int r;
  struct vattr va;
  struct timespec new_time;
  PUFFS_MAKECRED(pcr, &global_kcred);

  if (!flags)
	return 0;

  if (global_pu->pu_ops.puffs_node_setattr == NULL)
	return EINVAL;

  if (t != NULL)
	new_time = *t;
  else
	(void)clock_time(&new_time);

  puffs_vattr_null(&va);
  /* librefuse modifies atime and mtime together,
   * so set old values to avoid setting either one
   * to PUFFS_VNOVAL (set by puffs_vattr_null).
   */
  va.va_atime = pn->pn_va.va_atime;
  va.va_mtime = pn->pn_va.va_mtime;

  if (flags & ATIME)
	va.va_atime = new_time;
  if (flags & MTIME)
	va.va_mtime = new_time;
  if (flags & CTIME)
	va.va_ctime = new_time;

  r = global_pu->pu_ops.puffs_node_setattr(global_pu, pn, &va, pcr);

  return(r);
}


/*===========================================================================*
 *				lpuffs_debug				     *
 *===========================================================================*/
void lpuffs_debug(const char *format, ...)
{
  char buffer[256];
  va_list args;
  va_start (args, format);
  vsprintf (buffer,format, args);
  printf("%s: %s", fs_name, buffer);
  va_end (args);
}