1 /* Created (MFS based):
2 * February 2010 (Evgeniy Ivanov)
11 #include "puffs_priv.h"
14 /*===========================================================================*
16 *===========================================================================*/
19 /* Somebody has used an illegal system call number */
20 lpuffs_debug("no_sys: invalid call %d\n", req_nr
);
25 /*===========================================================================*
27 *===========================================================================*/
28 void mfs_nul_f(const char *file
, int line
, char *str
, unsigned int len
,
31 if (len
< maxlen
&& str
[len
-1] != '\0') {
32 lpuffs_debug("%s:%d string (length %d,maxlen %d) not null-terminated\n",
33 file
, line
, len
, maxlen
);
38 /*===========================================================================*
40 *===========================================================================*/
41 struct timespec
clock_timespec()
43 /* This routine returns the time in seconds since 1.1.1970. MINIX is an
44 * astrophysically naive system that assumes the earth rotates at a constant
45 * rate and that such things as leap seconds do not exist.
47 static long system_hz
= 0;
55 if (system_hz
== 0) system_hz
= sys_hz();
56 if ((k
=getuptime(&uptime
, &realtime
, &boottime
)) != OK
)
57 panic("clock_timespec: getuptime failed: %d", k
);
59 tv
.tv_sec
= (time_t) (boottime
+ (realtime
/system_hz
));
60 /* We do not want to overflow, and system_hz can be as high as 50kHz */
61 assert(system_hz
< LONG_MAX
/40000);
62 tv
.tv_nsec
= (realtime
%system_hz
) * 40000 / system_hz
* 25000;
67 /*===========================================================================*
69 *===========================================================================*/
70 int update_timens(struct puffs_node
*pn
, int flags
, struct timespec
*t
)
74 struct timespec new_time
;
75 PUFFS_MAKECRED(pcr
, &global_kcred
);
80 if (global_pu
->pu_ops
.puffs_node_setattr
== NULL
)
83 new_time
= t
!= NULL
? *t
: clock_timespec();
85 puffs_vattr_null(&va
);
86 /* librefuse modifies atime and mtime together,
87 * so set old values to avoid setting either one
88 * to PUFFS_VNOVAL (set by puffs_vattr_null).
90 va
.va_atime
= pn
->pn_va
.va_atime
;
91 va
.va_mtime
= pn
->pn_va
.va_mtime
;
94 va
.va_atime
= new_time
;
96 va
.va_mtime
= new_time
;
98 va
.va_ctime
= new_time
;
100 r
= global_pu
->pu_ops
.puffs_node_setattr(global_pu
, pn
, &va
, pcr
);
106 /*===========================================================================*
108 *===========================================================================*/
109 void lpuffs_debug(const char *format
, ...)
113 va_start (args
, format
);
114 vsprintf (buffer
,format
, args
);
115 printf("%s: %s", fs_name
, buffer
);