minix/lib/libpuffs/utility.c
Thomas Veerman 490e0de548 Import librefuse and libpuffs
Import libpuffs and our port of libpuffs. The port was done as part of
GSoC 2011 FUSE project, done by Evgeniy Ivanov. The librefuse import
did not require any porting efforts. Libpuffs has been modified to
understand our VFS-FS protocol and translate between that and PUFFS. As
an example that it works, fuse-ntfs-3g from pkgsrc can be compiled and
used to mount ntfs partitions:
mount -t ntfs-3g <device> <mountpoint>

FUSE only works with the asynchronous version of VFS. See <docs/UPDATING> on
how to run AVFS.

This patch further includes some changes to mount(1) and mount(2) so it's
possible to use file systems provided by pkgsrc (note: manual modifications
to /etc/system.conf are still needed. There has been made an exception for
fuse-ntfs-3g, so it already as an entry).
2011-11-14 11:53:05 +00:00

114 lines
3.1 KiB
C

/* Created (MFS based):
* February 2010 (Evgeniy Ivanov)
*/
#include "fs.h"
#include <stdarg.h>
#include "puffs.h"
#include "puffs_priv.h"
/*===========================================================================*
* no_sys *
*===========================================================================*/
PUBLIC int no_sys()
{
/* Somebody has used an illegal system call number */
lpuffs_debug("no_sys: invalid call %d\n", req_nr);
return(EINVAL);
}
/*===========================================================================*
* mfs_nul *
*===========================================================================*/
PUBLIC void mfs_nul_f(char *file, int line, char *str, unsigned int len,
unsigned int maxlen)
{
if (len < maxlen && str[len-1] != '\0') {
lpuffs_debug("%s:%d string (length %d,maxlen %d) not null-terminated\n",
file, line, len, maxlen);
}
}
/*===========================================================================*
* clock_time *
*===========================================================================*/
PUBLIC time_t clock_time()
{
/* This routine returns the time in seconds since 1.1.1970. MINIX is an
* astrophysically naive system that assumes the earth rotates at a constant
* rate and that such things as leap seconds do not exist.
*/
register int k;
clock_t uptime;
time_t boottime;
if ((k=getuptime2(&uptime, &boottime)) != OK)
panic("clock_time: getuptme2 failed: %d", k);
return( (time_t) (boottime + (uptime/sys_hz())));
}
/*===========================================================================*
* update_times *
*===========================================================================*/
PUBLIC int update_times(struct puffs_node *pn, int flags, time_t t)
{
int r;
struct vattr va;
time_t new_time;
PUFFS_MAKECRED(pcr, &global_kcred);
if (!flags)
return 0;
if (global_pu->pu_ops.puffs_node_setattr == NULL)
return EINVAL;
new_time = t != 0 ? t : clock_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.tv_sec = pn->pn_va.va_atime.tv_sec;
va.va_mtime.tv_sec = pn->pn_va.va_mtime.tv_sec;
if (flags & ATIME) {
va.va_atime.tv_sec = new_time;
va.va_atime.tv_nsec = 0;
}
if (flags & MTIME) {
va.va_mtime.tv_sec = new_time;
va.va_mtime.tv_nsec = 0;
}
if (flags & CTIME) {
va.va_ctime.tv_sec = new_time;
va.va_ctime.tv_nsec = 0;
}
r = global_pu->pu_ops.puffs_node_setattr(global_pu, pn, &va, pcr);
return(r);
}
/*===========================================================================*
* lpuffs_debug *
*===========================================================================*/
PUBLIC void lpuffs_debug(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);
}