1 /* Created (MFS based):
2 * February 2010 (Evgeniy Ivanov)
3 */
4
5 #include "fs.h"
6
7 #include <stdarg.h>
8
9 /*
10 * Match by inode number in a puffs_pn_nodewalk call. This should not exist.
11 */
12 void *
find_inode_cb(struct puffs_usermount * __unused pu,struct puffs_node * pn,void * arg)13 find_inode_cb(struct puffs_usermount * __unused pu, struct puffs_node * pn,
14 void * arg)
15 {
16
17 if (pn->pn_va.va_fileid == *(ino_t *)arg)
18 return pn;
19 else
20 return NULL;
21 }
22
23 /*===========================================================================*
24 * update_timens *
25 *===========================================================================*/
update_timens(struct puffs_node * pn,int flags,struct timespec * t)26 int update_timens(struct puffs_node *pn, int flags, struct timespec *t)
27 {
28 int r;
29 struct vattr va;
30 struct timespec new_time;
31 PUFFS_MAKECRED(pcr, &global_kcred);
32
33 if (!flags)
34 return 0;
35
36 if (global_pu->pu_ops.puffs_node_setattr == NULL)
37 return EINVAL;
38
39 if (t != NULL)
40 new_time = *t;
41 else
42 (void)clock_time(&new_time);
43
44 puffs_vattr_null(&va);
45 /* librefuse modifies atime and mtime together,
46 * so set old values to avoid setting either one
47 * to PUFFS_VNOVAL (set by puffs_vattr_null).
48 */
49 va.va_atime = pn->pn_va.va_atime;
50 va.va_mtime = pn->pn_va.va_mtime;
51
52 if (flags & ATIME)
53 va.va_atime = new_time;
54 if (flags & MTIME)
55 va.va_mtime = new_time;
56 if (flags & CTIME)
57 va.va_ctime = new_time;
58
59 r = global_pu->pu_ops.puffs_node_setattr(global_pu, pn, &va, pcr);
60
61 return(r);
62 }
63
64
65 /*===========================================================================*
66 * lpuffs_debug *
67 *===========================================================================*/
lpuffs_debug(const char * format,...)68 void lpuffs_debug(const char *format, ...)
69 {
70 char buffer[256];
71 va_list args;
72 va_start (args, format);
73 vsprintf (buffer,format, args);
74 printf("%s: %s", fs_name, buffer);
75 va_end (args);
76 }
77