Commit 48c8438c authored by Peter Braam's avatar Peter Braam Committed by Linus Torvalds

[PATCH] intermezzo update

Relatively straightforward fixes for intermezzo problems in 2.5.50.  I
think all of them related to:
 - two missing headers
 - use of timespec instead of time_t.
parent 8b0e2342
...@@ -342,7 +342,7 @@ int presto_setattr(struct dentry *de, struct iattr *iattr) ...@@ -342,7 +342,7 @@ int presto_setattr(struct dentry *de, struct iattr *iattr)
int error; int error;
struct presto_cache *cache; struct presto_cache *cache;
struct presto_file_set *fset; struct presto_file_set *fset;
struct lento_vfs_context info = { 0, 0, 0 }; struct lento_vfs_context info = { 0, {0}, 0 };
ENTRY; ENTRY;
...@@ -358,8 +358,8 @@ int presto_setattr(struct dentry *de, struct iattr *iattr) ...@@ -358,8 +358,8 @@ int presto_setattr(struct dentry *de, struct iattr *iattr)
CDEBUG(D_INODE, "valid %#x, mode %#o, uid %u, gid %u, size %Lu, " CDEBUG(D_INODE, "valid %#x, mode %#o, uid %u, gid %u, size %Lu, "
"atime %lu mtime %lu ctime %lu flags %d\n", "atime %lu mtime %lu ctime %lu flags %d\n",
iattr->ia_valid, iattr->ia_mode, iattr->ia_uid, iattr->ia_gid, iattr->ia_valid, iattr->ia_mode, iattr->ia_uid, iattr->ia_gid,
iattr->ia_size, iattr->ia_atime, iattr->ia_mtime, iattr->ia_size, iattr->ia_atime.tv_sec, iattr->ia_mtime.tv_sec,
iattr->ia_ctime, iattr->ia_attr_flags); iattr->ia_ctime.tv_sec, iattr->ia_attr_flags);
if ( presto_get_permit(de->d_inode) < 0 ) { if ( presto_get_permit(de->d_inode) < 0 ) {
EXIT; EXIT;
......
...@@ -61,7 +61,7 @@ extern int presto_permission(struct inode *inode, int mask); ...@@ -61,7 +61,7 @@ extern int presto_permission(struct inode *inode, int mask);
static int presto_open_upcall(int minor, struct dentry *de) static int presto_open_upcall(int minor, struct dentry *de)
{ {
int rc; int rc = 0;
char *path, *buffer; char *path, *buffer;
struct presto_file_set *fset; struct presto_file_set *fset;
int pathlen; int pathlen;
......
...@@ -363,8 +363,10 @@ static inline char *log_dentry_version(char *buf, struct dentry *dentry) ...@@ -363,8 +363,10 @@ static inline char *log_dentry_version(char *buf, struct dentry *dentry)
presto_getversion(&version, dentry->d_inode); presto_getversion(&version, dentry->d_inode);
version.pv_mtime = HTON__u64(version.pv_mtime); version.pv_mtime_sec = HTON__u32(version.pv_mtime_sec);
version.pv_ctime = HTON__u64(version.pv_ctime); version.pv_ctime_sec = HTON__u32(version.pv_ctime_sec);
version.pv_mtime_nsec = HTON__u32(version.pv_mtime_nsec);
version.pv_ctime_nsec = HTON__u32(version.pv_ctime_nsec);
version.pv_size = HTON__u64(version.pv_size); version.pv_size = HTON__u64(version.pv_size);
return logit(buf, &version, sizeof(version)); return logit(buf, &version, sizeof(version));
...@@ -376,8 +378,10 @@ static inline char *log_version(char *buf, struct presto_version *pv) ...@@ -376,8 +378,10 @@ static inline char *log_version(char *buf, struct presto_version *pv)
memcpy(&version, pv, sizeof(version)); memcpy(&version, pv, sizeof(version));
version.pv_mtime = HTON__u64(version.pv_mtime); version.pv_mtime_sec = HTON__u32(version.pv_mtime_sec);
version.pv_ctime = HTON__u64(version.pv_ctime); version.pv_mtime_nsec = HTON__u32(version.pv_mtime_nsec);
version.pv_ctime_sec = HTON__u32(version.pv_ctime_sec);
version.pv_ctime_nsec = HTON__u32(version.pv_ctime_nsec);
version.pv_size = HTON__u64(version.pv_size); version.pv_size = HTON__u64(version.pv_size);
return logit(buf, &version, sizeof(version)); return logit(buf, &version, sizeof(version));
......
...@@ -100,7 +100,8 @@ static inline int version_equal(struct presto_version *a, struct inode *inode) ...@@ -100,7 +100,8 @@ static inline int version_equal(struct presto_version *a, struct inode *inode)
return 0; return 0;
} }
if (inode->i_mtime == a->pv_mtime && if (inode->i_mtime.tv_sec == a->pv_mtime_sec &&
inode->i_mtime.tv_nsec == a->pv_mtime_nsec &&
(S_ISDIR(inode->i_mode) || inode->i_size == a->pv_size)) (S_ISDIR(inode->i_mode) || inode->i_size == a->pv_size))
return 1; return 1;
...@@ -126,8 +127,10 @@ static int reint_close(struct kml_rec *rec, struct file *file, ...@@ -126,8 +127,10 @@ static int reint_close(struct kml_rec *rec, struct file *file,
struct iattr iattr; struct iattr iattr;
iattr.ia_valid = ATTR_CTIME | ATTR_MTIME | ATTR_SIZE; iattr.ia_valid = ATTR_CTIME | ATTR_MTIME | ATTR_SIZE;
iattr.ia_mtime = (time_t)rec->new_objectv->pv_mtime; iattr.ia_mtime.tv_sec = (time_t)rec->new_objectv->pv_mtime_sec;
iattr.ia_ctime = (time_t)rec->new_objectv->pv_ctime; iattr.ia_mtime.tv_nsec = (time_t)rec->new_objectv->pv_mtime_nsec;
iattr.ia_ctime.tv_sec = (time_t)rec->new_objectv->pv_ctime_sec;
iattr.ia_ctime.tv_nsec = (time_t)rec->new_objectv->pv_ctime_nsec;
iattr.ia_size = (time_t)rec->new_objectv->pv_size; iattr.ia_size = (time_t)rec->new_objectv->pv_size;
/* no kml record, but update last rcvd */ /* no kml record, but update last rcvd */
...@@ -144,7 +147,8 @@ static int reint_close(struct kml_rec *rec, struct file *file, ...@@ -144,7 +147,8 @@ static int reint_close(struct kml_rec *rec, struct file *file,
} else { } else {
int minor = presto_f2m(fset); int minor = presto_f2m(fset);
info.updated_time = rec->new_objectv->pv_mtime; info.updated_time.tv_sec = rec->new_objectv->pv_mtime_sec;
info.updated_time.tv_nsec = rec->new_objectv->pv_mtime_nsec;
memcpy(&info.remote_version, rec->old_objectv, memcpy(&info.remote_version, rec->old_objectv,
sizeof(*rec->old_objectv)); sizeof(*rec->old_objectv));
info.remote_ino = rec->ino; info.remote_ino = rec->ino;
...@@ -180,7 +184,8 @@ static int reint_create(struct kml_rec *rec, struct file *dir, ...@@ -180,7 +184,8 @@ static int reint_create(struct kml_rec *rec, struct file *dir,
int error; ENTRY; int error; ENTRY;
CDEBUG (D_KML, "=====REINT_CREATE::%s\n", rec->path); CDEBUG (D_KML, "=====REINT_CREATE::%s\n", rec->path);
info->updated_time = rec->new_objectv->pv_ctime; info->updated_time.tv_sec = rec->new_objectv->pv_ctime_sec;
info->updated_time.tv_nsec = rec->new_objectv->pv_ctime_nsec;
kmlreint_pre_secure(rec, dir, &saved_ctxt); kmlreint_pre_secure(rec, dir, &saved_ctxt);
error = lento_create(rec->path, rec->mode, info); error = lento_create(rec->path, rec->mode, info);
pop_ctxt(&saved_ctxt); pop_ctxt(&saved_ctxt);
...@@ -198,7 +203,8 @@ static int reint_link(struct kml_rec *rec, struct file *dir, ...@@ -198,7 +203,8 @@ static int reint_link(struct kml_rec *rec, struct file *dir,
ENTRY; ENTRY;
CDEBUG (D_KML, "=====REINT_LINK::%s -> %s\n", rec->path, rec->target); CDEBUG (D_KML, "=====REINT_LINK::%s -> %s\n", rec->path, rec->target);
info->updated_time = rec->new_objectv->pv_mtime; info->updated_time.tv_sec = rec->new_objectv->pv_mtime_sec;
info->updated_time.tv_nsec = rec->new_objectv->pv_mtime_nsec;
kmlreint_pre_secure(rec, dir, &saved_ctxt); kmlreint_pre_secure(rec, dir, &saved_ctxt);
error = lento_link(rec->path, rec->target, info); error = lento_link(rec->path, rec->target, info);
pop_ctxt(&saved_ctxt); pop_ctxt(&saved_ctxt);
...@@ -216,7 +222,8 @@ static int reint_mkdir(struct kml_rec *rec, struct file *dir, ...@@ -216,7 +222,8 @@ static int reint_mkdir(struct kml_rec *rec, struct file *dir,
ENTRY; ENTRY;
CDEBUG (D_KML, "=====REINT_MKDIR::%s\n", rec->path); CDEBUG (D_KML, "=====REINT_MKDIR::%s\n", rec->path);
info->updated_time = rec->new_objectv->pv_ctime; info->updated_time.tv_sec = rec->new_objectv->pv_ctime_sec;
info->updated_time.tv_nsec = rec->new_objectv->pv_ctime_nsec;
kmlreint_pre_secure(rec, dir, &saved_ctxt); kmlreint_pre_secure(rec, dir, &saved_ctxt);
error = lento_mkdir(rec->path, rec->mode, info); error = lento_mkdir(rec->path, rec->mode, info);
pop_ctxt(&saved_ctxt); pop_ctxt(&saved_ctxt);
...@@ -234,7 +241,8 @@ static int reint_mknod(struct kml_rec *rec, struct file *dir, ...@@ -234,7 +241,8 @@ static int reint_mknod(struct kml_rec *rec, struct file *dir,
ENTRY; ENTRY;
CDEBUG (D_KML, "=====REINT_MKNOD::%s\n", rec->path); CDEBUG (D_KML, "=====REINT_MKNOD::%s\n", rec->path);
info->updated_time = rec->new_objectv->pv_ctime; info->updated_time.tv_sec = rec->new_objectv->pv_ctime_sec;
info->updated_time.tv_nsec = rec->new_objectv->pv_ctime_nsec;
kmlreint_pre_secure(rec, dir, &saved_ctxt); kmlreint_pre_secure(rec, dir, &saved_ctxt);
dev = rec->rdev ?: MKDEV(rec->major, rec->minor); dev = rec->rdev ?: MKDEV(rec->major, rec->minor);
...@@ -262,7 +270,8 @@ static int reint_rename(struct kml_rec *rec, struct file *dir, ...@@ -262,7 +270,8 @@ static int reint_rename(struct kml_rec *rec, struct file *dir,
ENTRY; ENTRY;
CDEBUG (D_KML, "=====REINT_RENAME::%s -> %s\n", rec->path, rec->target); CDEBUG (D_KML, "=====REINT_RENAME::%s -> %s\n", rec->path, rec->target);
info->updated_time = rec->new_objectv->pv_mtime; info->updated_time.tv_sec = rec->new_objectv->pv_mtime_sec;
info->updated_time.tv_nsec = rec->new_objectv->pv_mtime_nsec;
kmlreint_pre_secure(rec, dir, &saved_ctxt); kmlreint_pre_secure(rec, dir, &saved_ctxt);
error = lento_rename(rec->path, rec->target, info); error = lento_rename(rec->path, rec->target, info);
pop_ctxt(&saved_ctxt); pop_ctxt(&saved_ctxt);
...@@ -287,7 +296,8 @@ static int reint_rmdir(struct kml_rec *rec, struct file *dir, ...@@ -287,7 +296,8 @@ static int reint_rmdir(struct kml_rec *rec, struct file *dir,
} }
CDEBUG (D_KML, "=====REINT_RMDIR::%s\n", path); CDEBUG (D_KML, "=====REINT_RMDIR::%s\n", path);
info->updated_time = rec->new_parentv->pv_mtime; info->updated_time.tv_sec = rec->new_parentv->pv_mtime_sec;
info->updated_time.tv_nsec = rec->new_parentv->pv_mtime_nsec;
kmlreint_pre_secure(rec, dir, &saved_ctxt); kmlreint_pre_secure(rec, dir, &saved_ctxt);
error = lento_rmdir(path, info); error = lento_rmdir(path, info);
pop_ctxt(&saved_ctxt); pop_ctxt(&saved_ctxt);
...@@ -311,8 +321,10 @@ static int reint_setattr(struct kml_rec *rec, struct file *dir, ...@@ -311,8 +321,10 @@ static int reint_setattr(struct kml_rec *rec, struct file *dir,
iattr.ia_uid = (uid_t)rec->uid; iattr.ia_uid = (uid_t)rec->uid;
iattr.ia_gid = (gid_t)rec->gid; iattr.ia_gid = (gid_t)rec->gid;
iattr.ia_size = (off_t)rec->size; iattr.ia_size = (off_t)rec->size;
iattr.ia_ctime = (time_t)rec->ctime; iattr.ia_ctime.tv_sec = rec->ctime_sec;
iattr.ia_mtime = (time_t)rec->mtime; iattr.ia_ctime.tv_nsec = rec->ctime_nsec;
iattr.ia_mtime.tv_sec = rec->mtime_sec;
iattr.ia_mtime.tv_nsec = rec->mtime_nsec;
iattr.ia_atime = iattr.ia_mtime; /* We don't track atimes. */ iattr.ia_atime = iattr.ia_mtime; /* We don't track atimes. */
iattr.ia_attr_flags = rec->flags; iattr.ia_attr_flags = rec->flags;
...@@ -334,7 +346,8 @@ static int reint_symlink(struct kml_rec *rec, struct file *dir, ...@@ -334,7 +346,8 @@ static int reint_symlink(struct kml_rec *rec, struct file *dir,
ENTRY; ENTRY;
CDEBUG (D_KML, "=====REINT_SYMLINK::%s -> %s\n", rec->path, rec->target); CDEBUG (D_KML, "=====REINT_SYMLINK::%s -> %s\n", rec->path, rec->target);
info->updated_time = rec->new_objectv->pv_ctime; info->updated_time.tv_sec = rec->new_objectv->pv_ctime_sec;
info->updated_time.tv_nsec = rec->new_objectv->pv_ctime_nsec;
kmlreint_pre_secure(rec, dir, &saved_ctxt); kmlreint_pre_secure(rec, dir, &saved_ctxt);
error = lento_symlink(rec->target, rec->path, info); error = lento_symlink(rec->target, rec->path, info);
pop_ctxt(&saved_ctxt); pop_ctxt(&saved_ctxt);
...@@ -359,7 +372,8 @@ static int reint_unlink(struct kml_rec *rec, struct file *dir, ...@@ -359,7 +372,8 @@ static int reint_unlink(struct kml_rec *rec, struct file *dir,
} }
CDEBUG (D_KML, "=====REINT_UNLINK::%s\n", path); CDEBUG (D_KML, "=====REINT_UNLINK::%s\n", path);
info->updated_time = rec->new_parentv->pv_mtime; info->updated_time.tv_sec = rec->new_parentv->pv_mtime_sec;
info->updated_time.tv_nsec = rec->new_parentv->pv_mtime_nsec;
kmlreint_pre_secure(rec, dir, &saved_ctxt); kmlreint_pre_secure(rec, dir, &saved_ctxt);
error = lento_unlink(path, info); error = lento_unlink(path, info);
pop_ctxt(&saved_ctxt); pop_ctxt(&saved_ctxt);
......
...@@ -67,8 +67,10 @@ int kml_unpack_version(struct presto_version **ver, char **buf, char *end) ...@@ -67,8 +67,10 @@ int kml_unpack_version(struct presto_version **ver, char **buf, char *end)
UNLOGP(*ver, struct presto_version, ptr, end); UNLOGP(*ver, struct presto_version, ptr, end);
pv = *ver; pv = *ver;
pv->pv_mtime = NTOH__u64(pv->pv_mtime); pv->pv_mtime_sec = NTOH__u32(pv->pv_mtime_sec);
pv->pv_ctime = NTOH__u64(pv->pv_ctime); pv->pv_mtime_nsec = NTOH__u32(pv->pv_mtime_nsec);
pv->pv_ctime_sec = NTOH__u32(pv->pv_ctime_sec);
pv->pv_ctime_nsec = NTOH__u32(pv->pv_ctime_nsec);
pv->pv_size = NTOH__u64(pv->pv_size); pv->pv_size = NTOH__u64(pv->pv_size);
*buf = ptr; *buf = ptr;
...@@ -247,8 +249,10 @@ static int kml_unpack_setattr(struct kml_rec *rec, char **buf, char *end) ...@@ -247,8 +249,10 @@ static int kml_unpack_setattr(struct kml_rec *rec, char **buf, char *end)
LUNLOGV(rec->uid, __u32, ptr, end); LUNLOGV(rec->uid, __u32, ptr, end);
LUNLOGV(rec->gid, __u32, ptr, end); LUNLOGV(rec->gid, __u32, ptr, end);
LUNLOGV(rec->size, __u64, ptr, end); LUNLOGV(rec->size, __u64, ptr, end);
LUNLOGV(rec->mtime, __u64, ptr, end); LUNLOGV(rec->mtime_sec, __u32, ptr, end);
LUNLOGV(rec->ctime, __u64, ptr, end); LUNLOGV(rec->mtime_nsec, __u32, ptr, end);
LUNLOGV(rec->ctime_sec, __u32, ptr, end);
LUNLOGV(rec->ctime_nsec, __u32, ptr, end);
LUNLOGV(rec->flags, __u32, ptr, end); LUNLOGV(rec->flags, __u32, ptr, end);
LUNLOGV(rec->old_mode, __u32, ptr, end); LUNLOGV(rec->old_mode, __u32, ptr, end);
LUNLOGV(rec->old_rdev, __u32, ptr, end); LUNLOGV(rec->old_rdev, __u32, ptr, end);
......
...@@ -627,8 +627,10 @@ int presto_put_permit(struct inode * inode) ...@@ -627,8 +627,10 @@ int presto_put_permit(struct inode * inode)
void presto_getversion(struct presto_version * presto_version, void presto_getversion(struct presto_version * presto_version,
struct inode * inode) struct inode * inode)
{ {
presto_version->pv_mtime = (__u64)inode->i_mtime; presto_version->pv_mtime_sec = inode->i_mtime.tv_sec;
presto_version->pv_ctime = (__u64)inode->i_ctime; presto_version->pv_mtime_nsec = inode->i_mtime.tv_nsec;
presto_version->pv_ctime_sec = inode->i_ctime.tv_sec;
presto_version->pv_ctime_nsec = inode->i_ctime.tv_nsec;
presto_version->pv_size = (__u64)inode->i_size; presto_version->pv_size = (__u64)inode->i_size;
} }
......
...@@ -29,7 +29,8 @@ ...@@ -29,7 +29,8 @@
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/fs.h>
#include <linux/fsfilter.h>
#include <linux/intermezzo_fs.h> #include <linux/intermezzo_fs.h>
/* /*
......
...@@ -186,7 +186,7 @@ inline void presto_debug_fail_blkdev(struct presto_file_set *fset, ...@@ -186,7 +186,7 @@ inline void presto_debug_fail_blkdev(struct presto_file_set *fset,
if (errorval && errorval == (long)value && !is_read_only(dev)) { if (errorval && errorval == (long)value && !is_read_only(dev)) {
CDEBUG(D_SUPER, "setting device %s read only\n", kdevname(dev)); CDEBUG(D_SUPER, "setting device %s read only\n", kdevname(dev));
BLKDEV_FAIL(dev, 1); BLKDEV_FAIL(kdev_val(dev), 1);
izo_channels[minor].uc_errorval = -kdev_val(dev); izo_channels[minor].uc_errorval = -kdev_val(dev);
} }
} }
...@@ -475,7 +475,7 @@ int lento_setattr(const char *name, struct iattr *iattr, ...@@ -475,7 +475,7 @@ int lento_setattr(const char *name, struct iattr *iattr,
name, iattr->ia_valid, iattr->ia_mode, iattr->ia_uid, name, iattr->ia_valid, iattr->ia_mode, iattr->ia_uid,
iattr->ia_gid, iattr->ia_size); iattr->ia_gid, iattr->ia_size);
CDEBUG(D_PIOCTL, "atime %#lx, mtime %#lx, ctime %#lx, attr_flags %#x\n", CDEBUG(D_PIOCTL, "atime %#lx, mtime %#lx, ctime %#lx, attr_flags %#x\n",
iattr->ia_atime, iattr->ia_mtime.tv_sec, iattr->ia_ctime.tv_sec, iattr->ia_atime.tv_sec, iattr->ia_mtime.tv_sec, iattr->ia_ctime.tv_sec,
iattr->ia_attr_flags); iattr->ia_attr_flags);
CDEBUG(D_PIOCTL, "offset %d, recno %d, flags %#x\n", CDEBUG(D_PIOCTL, "offset %d, recno %d, flags %#x\n",
info->slot_offset, info->recno, info->flags); info->slot_offset, info->recno, info->flags);
......
...@@ -39,7 +39,7 @@ typedef __u8 uuid_t[16]; ...@@ -39,7 +39,7 @@ typedef __u8 uuid_t[16];
struct lento_vfs_context { struct lento_vfs_context {
__u64 kml_offset; __u64 kml_offset;
__u64 updated_time; struct timespec updated_time;
__u64 remote_ino; __u64 remote_ino;
__u64 remote_generation; __u64 remote_generation;
__u32 slot_offset; __u32 slot_offset;
......
This diff is collapsed.
/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
* vim:expandtab:shiftwidth=8:tabstop=8:
*
* Copyright (C) 2001 Cluster File Systems, Inc. <braam@clusterfs.com>
*
* This file is part of InterMezzo, http://www.inter-mezzo.org.
*
* InterMezzo is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
* License as published by the Free Software Foundation.
*
* InterMezzo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with InterMezzo; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Data structures unpacking/packing macros & inlines
*
*/
#ifndef _INTERMEZZO_LIB_H
#define _INTERMEZZO_LIB_H
#ifdef __KERNEL__
# include <linux/types.h>
#else
# include <string.h>
# include <sys/types.h>
#endif
#undef MIN
#define MIN(a,b) (((a)<(b)) ? (a): (b))
#undef MAX
#define MAX(a,b) (((a)>(b)) ? (a): (b))
#define MKSTR(ptr) ((ptr))? (ptr) : ""
static inline int size_round (int val)
{
return (val + 3) & (~0x3);
}
static inline int size_round0(int val)
{
if (!val)
return 0;
return (val + 1 + 3) & (~0x3);
}
static inline size_t round_strlen(char *fset)
{
return size_round(strlen(fset) + 1);
}
#ifdef __KERNEL__
# define NTOH__u32(var) le32_to_cpu(var)
# define NTOH__u64(var) le64_to_cpu(var)
# define HTON__u32(var) cpu_to_le32(var)
# define HTON__u64(var) cpu_to_le64(var)
#else
# include <glib.h>
# define NTOH__u32(var) GUINT32_FROM_LE(var)
# define NTOH__u64(var) GUINT64_FROM_LE(var)
# define HTON__u32(var) GUINT32_TO_LE(var)
# define HTON__u64(var) GUINT64_TO_LE(var)
#endif
/*
* copy sizeof(type) bytes from pointer to var and move ptr forward.
* return EFAULT if pointer goes beyond end
*/
#define UNLOGV(var,type,ptr,end) \
do { \
var = *(type *)ptr; \
ptr += sizeof(type); \
if (ptr > end ) \
return -EFAULT; \
} while (0)
/* the following two macros convert to little endian */
/* type MUST be __u32 or __u64 */
#define LUNLOGV(var,type,ptr,end) \
do { \
var = NTOH##type(*(type *)ptr); \
ptr += sizeof(type); \
if (ptr > end ) \
return -EFAULT; \
} while (0)
/* now log values */
#define LOGV(var,type,ptr) \
do { \
*((type *)ptr) = var; \
ptr += sizeof(type); \
} while (0)
/* and in network order */
#define LLOGV(var,type,ptr) \
do { \
*((type *)ptr) = HTON##type(var); \
ptr += sizeof(type); \
} while (0)
/*
* set var to point at (type *)ptr, move ptr forward with sizeof(type)
* return from function with EFAULT if ptr goes beyond end
*/
#define UNLOGP(var,type,ptr,end) \
do { \
var = (type *)ptr; \
ptr += sizeof(type); \
if (ptr > end ) \
return -EFAULT; \
} while (0)
#define LOGP(var,type,ptr) \
do { \
memcpy(ptr, var, sizeof(type)); \
ptr += sizeof(type); \
} while (0)
/*
* set var to point at (char *)ptr, move ptr forward by size_round(len);
* return from function with EFAULT if ptr goes beyond end
*/
#define UNLOGL(var,type,len,ptr,end) \
do { \
if (len == 0) \
var = (type *)0; \
else { \
var = (type *)ptr; \
ptr += size_round(len * sizeof(type)); \
} \
if (ptr > end ) \
return -EFAULT; \
} while (0)
#define UNLOGL0(var,type,len,ptr,end) \
do { \
UNLOGL(var,type,len+1,ptr,end); \
if ( *((char *)ptr - size_round(len+1) + len) != '\0') \
return -EFAULT; \
} while (0)
#define LOGL(var,len,ptr) \
do { \
size_t __fill = size_round(len); \
/* Prevent data leakage. */ \
if (__fill > 0) \
memset((char *)ptr, 0, __fill); \
memcpy((char *)ptr, (const char *)var, len); \
ptr += __fill; \
} while (0)
#define LOGL0(var,len,ptr) \
do { \
if (!len) break; \
memcpy((char *)ptr, (const char *)var, len); \
*((char *)(ptr) + len) = 0; \
ptr += size_round(len + 1); \
} while (0)
#endif /* _INTERMEZZO_LIB_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment