EXTRA_DIST = \
bitmap.h \
- byteorder.h \
curproc.h \
libcfs.h \
libcfs_cpu.h \
+++ /dev/null
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program 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 version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.gnu.org/licenses/gpl-2.0.html
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2014, 2015, Intel Corporation.
- * Author: John L. Hammond <john.hammond@intel.com>
- */
-#ifndef _LIBCFS_BYTEORDER_H
-#define _LIBCFS_BYTERODER_H
-
-#ifdef __KERNEL__
-# include <asm/byteorder.h>
-#else /* __KERNEL__ */
-
-# ifdef HAVE_ENDIAN_H
-# include <endian.h>
-# endif
-# include <byteswap.h>
-
-# define __swab16(x) bswap_16(x)
-# define __swab32(x) bswap_32(x)
-# define __swab64(x) bswap_64(x)
-# define __swab16s(x) \
- do { \
- *(x) = bswap_16(*(x)); \
- } while (0)
-# define __swab32s(x) \
- do { \
- *(x) = bswap_32(*(x)); \
- } while (0)
-# define __swab64s(x) \
- do { \
- *(x) = bswap_64(*(x)); \
- } while (0)
-# if __BYTE_ORDER == __LITTLE_ENDIAN
-# define le16_to_cpu(x) (x)
-# define cpu_to_le16(x) (x)
-# define le32_to_cpu(x) (x)
-# define cpu_to_le32(x) (x)
-# define le64_to_cpu(x) (x)
-# define cpu_to_le64(x) (x)
-
-# define be16_to_cpu(x) bswap_16(x)
-# define cpu_to_be16(x) bswap_16(x)
-# define be32_to_cpu(x) bswap_32(x)
-# define cpu_to_be32(x) bswap_32(x)
-# define be64_to_cpu(x) ((__u64)bswap_64(x))
-# define cpu_to_be64(x) ((__u64)bswap_64(x))
-# elif __BYTE_ORDER == __BIG_ENDIAN
-# define le16_to_cpu(x) bswap_16(x)
-# define cpu_to_le16(x) bswap_16(x)
-# define le32_to_cpu(x) bswap_32(x)
-# define cpu_to_le32(x) bswap_32(x)
-# define le64_to_cpu(x) ((__u64)bswap_64(x))
-# define cpu_to_le64(x) ((__u64)bswap_64(x))
-
-# define be16_to_cpu(x) (x)
-# define cpu_to_be16(x) (x)
-# define be32_to_cpu(x) (x)
-# define cpu_to_be32(x) (x)
-# define be64_to_cpu(x) (x)
-# define cpu_to_be64(x) (x)
-# else /* __BYTE_ORDER == __BIG_ENDIAN */
-# error "Unknown byte order"
-# endif /* __BYTE_ORDER != __BIG_ENDIAN */
-
-#endif /* !__KERNEL__ */
-
-#endif /* _LIBCFS_BYTEORDER_H */
void cfs_get_random_bytes(void *buf, int size);
#endif /* __KERNEL__ */
-#include <libcfs/byteorder.h>
#include <libcfs/libcfs_debug.h>
#include <libcfs/libcfs_private.h>
#ifdef __KERNEL__
#ifndef _LUSTRE_IDL_H_
#define _LUSTRE_IDL_H_
+#include <asm/byteorder.h>
#include <linux/types.h>
+
#include <libcfs/libcfs.h>
#include <lnet/types.h>
#include <lustre/lustre_user.h> /* Defn's shared with user-space. */
*/
static inline void fid_cpu_to_le(struct lu_fid *dst, const struct lu_fid *src)
{
- dst->f_seq = cpu_to_le64(fid_seq(src));
- dst->f_oid = cpu_to_le32(fid_oid(src));
- dst->f_ver = cpu_to_le32(fid_ver(src));
+ dst->f_seq = __cpu_to_le64(fid_seq(src));
+ dst->f_oid = __cpu_to_le32(fid_oid(src));
+ dst->f_ver = __cpu_to_le32(fid_ver(src));
}
static inline void fid_le_to_cpu(struct lu_fid *dst, const struct lu_fid *src)
{
- dst->f_seq = le64_to_cpu(fid_seq(src));
- dst->f_oid = le32_to_cpu(fid_oid(src));
- dst->f_ver = le32_to_cpu(fid_ver(src));
+ dst->f_seq = __le64_to_cpu(fid_seq(src));
+ dst->f_oid = __le32_to_cpu(fid_oid(src));
+ dst->f_ver = __le32_to_cpu(fid_ver(src));
}
static inline void fid_cpu_to_be(struct lu_fid *dst, const struct lu_fid *src)
{
- dst->f_seq = cpu_to_be64(fid_seq(src));
- dst->f_oid = cpu_to_be32(fid_oid(src));
- dst->f_ver = cpu_to_be32(fid_ver(src));
+ dst->f_seq = __cpu_to_be64(fid_seq(src));
+ dst->f_oid = __cpu_to_be32(fid_oid(src));
+ dst->f_ver = __cpu_to_be32(fid_ver(src));
}
static inline void fid_be_to_cpu(struct lu_fid *dst, const struct lu_fid *src)
{
- dst->f_seq = be64_to_cpu(fid_seq(src));
- dst->f_oid = be32_to_cpu(fid_oid(src));
- dst->f_ver = be32_to_cpu(fid_ver(src));
+ dst->f_seq = __be64_to_cpu(fid_seq(src));
+ dst->f_oid = __be32_to_cpu(fid_oid(src));
+ dst->f_ver = __be32_to_cpu(fid_ver(src));
}
static inline bool fid_is_sane(const struct lu_fid *fid)
struct ost_id *dst_oi)
{
if (fid_seq_is_mdt0(src_oi->oi.oi_seq)) {
- dst_oi->oi.oi_id = cpu_to_le64(src_oi->oi.oi_id);
- dst_oi->oi.oi_seq = cpu_to_le64(src_oi->oi.oi_seq);
+ dst_oi->oi.oi_id = __cpu_to_le64(src_oi->oi.oi_id);
+ dst_oi->oi.oi_seq = __cpu_to_le64(src_oi->oi.oi_seq);
} else {
fid_cpu_to_le(&dst_oi->oi_fid, &src_oi->oi_fid);
}
struct ost_id *dst_oi)
{
if (fid_seq_is_mdt0(src_oi->oi.oi_seq)) {
- dst_oi->oi.oi_id = le64_to_cpu(src_oi->oi.oi_id);
- dst_oi->oi.oi_seq = le64_to_cpu(src_oi->oi.oi_seq);
+ dst_oi->oi.oi_id = __le64_to_cpu(src_oi->oi.oi_id);
+ dst_oi->oi.oi_seq = __le64_to_cpu(src_oi->oi.oi_seq);
} else {
fid_le_to_cpu(&dst_oi->oi_fid, &src_oi->oi_fid);
}
static inline struct lu_dirent *lu_dirent_start(struct lu_dirpage *dp)
{
- if (le32_to_cpu(dp->ldp_flags) & LDF_EMPTY)
- return NULL;
- else
- return dp->ldp_entries;
+ if (__le32_to_cpu(dp->ldp_flags) & LDF_EMPTY)
+ return NULL;
+ else
+ return dp->ldp_entries;
}
static inline struct lu_dirent *lu_dirent_next(struct lu_dirent *ent)
{
- struct lu_dirent *next;
+ struct lu_dirent *next;
- if (le16_to_cpu(ent->lde_reclen) != 0)
- next = ((void *)ent) + le16_to_cpu(ent->lde_reclen);
- else
- next = NULL;
+ if (__le16_to_cpu(ent->lde_reclen) != 0)
+ next = ((void *)ent) + __le16_to_cpu(ent->lde_reclen);
+ else
+ next = NULL;
- return next;
+ return next;
}
static inline size_t lu_dirent_calc_size(size_t namelen, __u16 attr)
static inline void lmm_oi_le_to_cpu(struct ost_id *dst_oi,
const struct ost_id *src_oi)
{
- dst_oi->oi.oi_id = le64_to_cpu(src_oi->oi.oi_id);
- dst_oi->oi.oi_seq = le64_to_cpu(src_oi->oi.oi_seq);
+ dst_oi->oi.oi_id = __le64_to_cpu(src_oi->oi.oi_id);
+ dst_oi->oi.oi_seq = __le64_to_cpu(src_oi->oi.oi_seq);
}
static inline void lmm_oi_cpu_to_le(struct ost_id *dst_oi,
const struct ost_id *src_oi)
{
- dst_oi->oi.oi_id = cpu_to_le64(src_oi->oi.oi_id);
- dst_oi->oi.oi_seq = cpu_to_le64(src_oi->oi.oi_seq);
+ dst_oi->oi.oi_id = __cpu_to_le64(src_oi->oi.oi_id);
+ dst_oi->oi.oi_seq = __cpu_to_le64(src_oi->oi.oi_seq);
}
#define MAX_MD_SIZE (sizeof(struct lov_mds_md) + 4 * sizeof(struct lov_ost_data))
static inline int lmv_mds_md_stripe_count_get(const union lmv_mds_md *lmm)
{
- switch (le32_to_cpu(lmm->lmv_magic)) {
+ switch (__le32_to_cpu(lmm->lmv_magic)) {
case LMV_MAGIC_V1:
- return le32_to_cpu(lmm->lmv_md_v1.lmv_stripe_count);
+ return __le32_to_cpu(lmm->lmv_md_v1.lmv_stripe_count);
case LMV_USER_MAGIC:
- return le32_to_cpu(lmm->lmv_user_md.lum_stripe_count);
+ return __le32_to_cpu(lmm->lmv_user_md.lum_stripe_count);
default:
return -EINVAL;
}
*
* @{
*/
-
+#include <asm/byteorder.h>
#include <linux/types.h>
#include <libcfs/libcfs.h>
#ifdef __KERNEL__
{
int i;
memcpy(lsd->lsd_uuid, buf->lsd_uuid, sizeof(lsd->lsd_uuid));
- lsd->lsd_last_transno = le64_to_cpu(buf->lsd_last_transno);
- lsd->lsd_compat14 = le64_to_cpu(buf->lsd_compat14);
- lsd->lsd_mount_count = le64_to_cpu(buf->lsd_mount_count);
- lsd->lsd_feature_compat = le32_to_cpu(buf->lsd_feature_compat);
- lsd->lsd_feature_rocompat = le32_to_cpu(buf->lsd_feature_rocompat);
- lsd->lsd_feature_incompat = le32_to_cpu(buf->lsd_feature_incompat);
- lsd->lsd_server_size = le32_to_cpu(buf->lsd_server_size);
- lsd->lsd_client_start = le32_to_cpu(buf->lsd_client_start);
- lsd->lsd_client_size = le16_to_cpu(buf->lsd_client_size);
- lsd->lsd_subdir_count = le16_to_cpu(buf->lsd_subdir_count);
- lsd->lsd_catalog_oid = le64_to_cpu(buf->lsd_catalog_oid);
- lsd->lsd_catalog_ogen = le32_to_cpu(buf->lsd_catalog_ogen);
+ lsd->lsd_last_transno = __le64_to_cpu(buf->lsd_last_transno);
+ lsd->lsd_compat14 = __le64_to_cpu(buf->lsd_compat14);
+ lsd->lsd_mount_count = __le64_to_cpu(buf->lsd_mount_count);
+ lsd->lsd_feature_compat = __le32_to_cpu(buf->lsd_feature_compat);
+ lsd->lsd_feature_rocompat = __le32_to_cpu(buf->lsd_feature_rocompat);
+ lsd->lsd_feature_incompat = __le32_to_cpu(buf->lsd_feature_incompat);
+ lsd->lsd_server_size = __le32_to_cpu(buf->lsd_server_size);
+ lsd->lsd_client_start = __le32_to_cpu(buf->lsd_client_start);
+ lsd->lsd_client_size = __le16_to_cpu(buf->lsd_client_size);
+ lsd->lsd_subdir_count = __le16_to_cpu(buf->lsd_subdir_count);
+ lsd->lsd_catalog_oid = __le64_to_cpu(buf->lsd_catalog_oid);
+ lsd->lsd_catalog_ogen = __le32_to_cpu(buf->lsd_catalog_ogen);
memcpy(lsd->lsd_peeruuid, buf->lsd_peeruuid, sizeof(lsd->lsd_peeruuid));
- lsd->lsd_osd_index = le32_to_cpu(buf->lsd_osd_index);
- lsd->lsd_padding1 = le32_to_cpu(buf->lsd_padding1);
- lsd->lsd_start_epoch = le32_to_cpu(buf->lsd_start_epoch);
+ lsd->lsd_osd_index = __le32_to_cpu(buf->lsd_osd_index);
+ lsd->lsd_padding1 = __le32_to_cpu(buf->lsd_padding1);
+ lsd->lsd_start_epoch = __le32_to_cpu(buf->lsd_start_epoch);
for (i = 0; i < LR_EXPIRE_INTERVALS; i++)
- lsd->lsd_trans_table[i] = le64_to_cpu(buf->lsd_trans_table[i]);
- lsd->lsd_trans_table_time = le32_to_cpu(buf->lsd_trans_table_time);
- lsd->lsd_expire_intervals = le32_to_cpu(buf->lsd_expire_intervals);
+ lsd->lsd_trans_table[i] = __le64_to_cpu(buf->lsd_trans_table[i]);
+ lsd->lsd_trans_table_time = __le32_to_cpu(buf->lsd_trans_table_time);
+ lsd->lsd_expire_intervals = __le32_to_cpu(buf->lsd_expire_intervals);
}
static inline void lsd_cpu_to_le(struct lr_server_data *lsd,
{
int i;
memcpy(buf->lsd_uuid, lsd->lsd_uuid, sizeof(buf->lsd_uuid));
- buf->lsd_last_transno = cpu_to_le64(lsd->lsd_last_transno);
- buf->lsd_compat14 = cpu_to_le64(lsd->lsd_compat14);
- buf->lsd_mount_count = cpu_to_le64(lsd->lsd_mount_count);
- buf->lsd_feature_compat = cpu_to_le32(lsd->lsd_feature_compat);
- buf->lsd_feature_rocompat = cpu_to_le32(lsd->lsd_feature_rocompat);
- buf->lsd_feature_incompat = cpu_to_le32(lsd->lsd_feature_incompat);
- buf->lsd_server_size = cpu_to_le32(lsd->lsd_server_size);
- buf->lsd_client_start = cpu_to_le32(lsd->lsd_client_start);
- buf->lsd_client_size = cpu_to_le16(lsd->lsd_client_size);
- buf->lsd_subdir_count = cpu_to_le16(lsd->lsd_subdir_count);
- buf->lsd_catalog_oid = cpu_to_le64(lsd->lsd_catalog_oid);
- buf->lsd_catalog_ogen = cpu_to_le32(lsd->lsd_catalog_ogen);
+ buf->lsd_last_transno = __cpu_to_le64(lsd->lsd_last_transno);
+ buf->lsd_compat14 = __cpu_to_le64(lsd->lsd_compat14);
+ buf->lsd_mount_count = __cpu_to_le64(lsd->lsd_mount_count);
+ buf->lsd_feature_compat = __cpu_to_le32(lsd->lsd_feature_compat);
+ buf->lsd_feature_rocompat = __cpu_to_le32(lsd->lsd_feature_rocompat);
+ buf->lsd_feature_incompat = __cpu_to_le32(lsd->lsd_feature_incompat);
+ buf->lsd_server_size = __cpu_to_le32(lsd->lsd_server_size);
+ buf->lsd_client_start = __cpu_to_le32(lsd->lsd_client_start);
+ buf->lsd_client_size = __cpu_to_le16(lsd->lsd_client_size);
+ buf->lsd_subdir_count = __cpu_to_le16(lsd->lsd_subdir_count);
+ buf->lsd_catalog_oid = __cpu_to_le64(lsd->lsd_catalog_oid);
+ buf->lsd_catalog_ogen = __cpu_to_le32(lsd->lsd_catalog_ogen);
memcpy(buf->lsd_peeruuid, lsd->lsd_peeruuid, sizeof(buf->lsd_peeruuid));
- buf->lsd_osd_index = cpu_to_le32(lsd->lsd_osd_index);
- buf->lsd_padding1 = cpu_to_le32(lsd->lsd_padding1);
- buf->lsd_start_epoch = cpu_to_le32(lsd->lsd_start_epoch);
+ buf->lsd_osd_index = __cpu_to_le32(lsd->lsd_osd_index);
+ buf->lsd_padding1 = __cpu_to_le32(lsd->lsd_padding1);
+ buf->lsd_start_epoch = __cpu_to_le32(lsd->lsd_start_epoch);
for (i = 0; i < LR_EXPIRE_INTERVALS; i++)
- buf->lsd_trans_table[i] = cpu_to_le64(lsd->lsd_trans_table[i]);
- buf->lsd_trans_table_time = cpu_to_le32(lsd->lsd_trans_table_time);
- buf->lsd_expire_intervals = cpu_to_le32(lsd->lsd_expire_intervals);
+ buf->lsd_trans_table[i] = __cpu_to_le64(lsd->lsd_trans_table[i]);
+ buf->lsd_trans_table_time = __cpu_to_le32(lsd->lsd_trans_table_time);
+ buf->lsd_expire_intervals = __cpu_to_le32(lsd->lsd_expire_intervals);
}
static inline void lcd_le_to_cpu(struct lsd_client_data *buf,
struct lsd_client_data *lcd)
{
memcpy(lcd->lcd_uuid, buf->lcd_uuid, sizeof (lcd->lcd_uuid));
- lcd->lcd_last_transno = le64_to_cpu(buf->lcd_last_transno);
- lcd->lcd_last_xid = le64_to_cpu(buf->lcd_last_xid);
- lcd->lcd_last_result = le32_to_cpu(buf->lcd_last_result);
- lcd->lcd_last_data = le32_to_cpu(buf->lcd_last_data);
- lcd->lcd_last_close_transno = le64_to_cpu(buf->lcd_last_close_transno);
- lcd->lcd_last_close_xid = le64_to_cpu(buf->lcd_last_close_xid);
- lcd->lcd_last_close_result = le32_to_cpu(buf->lcd_last_close_result);
- lcd->lcd_last_close_data = le32_to_cpu(buf->lcd_last_close_data);
- lcd->lcd_pre_versions[0] = le64_to_cpu(buf->lcd_pre_versions[0]);
- lcd->lcd_pre_versions[1] = le64_to_cpu(buf->lcd_pre_versions[1]);
- lcd->lcd_pre_versions[2] = le64_to_cpu(buf->lcd_pre_versions[2]);
- lcd->lcd_pre_versions[3] = le64_to_cpu(buf->lcd_pre_versions[3]);
- lcd->lcd_last_epoch = le32_to_cpu(buf->lcd_last_epoch);
- lcd->lcd_generation = le32_to_cpu(buf->lcd_generation);
+ lcd->lcd_last_transno = __le64_to_cpu(buf->lcd_last_transno);
+ lcd->lcd_last_xid = __le64_to_cpu(buf->lcd_last_xid);
+ lcd->lcd_last_result = __le32_to_cpu(buf->lcd_last_result);
+ lcd->lcd_last_data = __le32_to_cpu(buf->lcd_last_data);
+ lcd->lcd_last_close_transno = __le64_to_cpu(buf->lcd_last_close_transno);
+ lcd->lcd_last_close_xid = __le64_to_cpu(buf->lcd_last_close_xid);
+ lcd->lcd_last_close_result = __le32_to_cpu(buf->lcd_last_close_result);
+ lcd->lcd_last_close_data = __le32_to_cpu(buf->lcd_last_close_data);
+ lcd->lcd_pre_versions[0] = __le64_to_cpu(buf->lcd_pre_versions[0]);
+ lcd->lcd_pre_versions[1] = __le64_to_cpu(buf->lcd_pre_versions[1]);
+ lcd->lcd_pre_versions[2] = __le64_to_cpu(buf->lcd_pre_versions[2]);
+ lcd->lcd_pre_versions[3] = __le64_to_cpu(buf->lcd_pre_versions[3]);
+ lcd->lcd_last_epoch = __le32_to_cpu(buf->lcd_last_epoch);
+ lcd->lcd_generation = __le32_to_cpu(buf->lcd_generation);
}
static inline void lcd_cpu_to_le(struct lsd_client_data *lcd,
struct lsd_client_data *buf)
{
memcpy(buf->lcd_uuid, lcd->lcd_uuid, sizeof (lcd->lcd_uuid));
- buf->lcd_last_transno = cpu_to_le64(lcd->lcd_last_transno);
- buf->lcd_last_xid = cpu_to_le64(lcd->lcd_last_xid);
- buf->lcd_last_result = cpu_to_le32(lcd->lcd_last_result);
- buf->lcd_last_data = cpu_to_le32(lcd->lcd_last_data);
- buf->lcd_last_close_transno = cpu_to_le64(lcd->lcd_last_close_transno);
- buf->lcd_last_close_xid = cpu_to_le64(lcd->lcd_last_close_xid);
- buf->lcd_last_close_result = cpu_to_le32(lcd->lcd_last_close_result);
- buf->lcd_last_close_data = cpu_to_le32(lcd->lcd_last_close_data);
- buf->lcd_pre_versions[0] = cpu_to_le64(lcd->lcd_pre_versions[0]);
- buf->lcd_pre_versions[1] = cpu_to_le64(lcd->lcd_pre_versions[1]);
- buf->lcd_pre_versions[2] = cpu_to_le64(lcd->lcd_pre_versions[2]);
- buf->lcd_pre_versions[3] = cpu_to_le64(lcd->lcd_pre_versions[3]);
- buf->lcd_last_epoch = cpu_to_le32(lcd->lcd_last_epoch);
- buf->lcd_generation = cpu_to_le32(lcd->lcd_generation);
+ buf->lcd_last_transno = __cpu_to_le64(lcd->lcd_last_transno);
+ buf->lcd_last_xid = __cpu_to_le64(lcd->lcd_last_xid);
+ buf->lcd_last_result = __cpu_to_le32(lcd->lcd_last_result);
+ buf->lcd_last_data = __cpu_to_le32(lcd->lcd_last_data);
+ buf->lcd_last_close_transno = __cpu_to_le64(lcd->lcd_last_close_transno);
+ buf->lcd_last_close_xid = __cpu_to_le64(lcd->lcd_last_close_xid);
+ buf->lcd_last_close_result = __cpu_to_le32(lcd->lcd_last_close_result);
+ buf->lcd_last_close_data = __cpu_to_le32(lcd->lcd_last_close_data);
+ buf->lcd_pre_versions[0] = __cpu_to_le64(lcd->lcd_pre_versions[0]);
+ buf->lcd_pre_versions[1] = __cpu_to_le64(lcd->lcd_pre_versions[1]);
+ buf->lcd_pre_versions[2] = __cpu_to_le64(lcd->lcd_pre_versions[2]);
+ buf->lcd_pre_versions[3] = __cpu_to_le64(lcd->lcd_pre_versions[3]);
+ buf->lcd_last_epoch = __cpu_to_le32(lcd->lcd_last_epoch);
+ buf->lcd_generation = __cpu_to_le32(lcd->lcd_generation);
}
static inline __u64 lcd_last_transno(struct lsd_client_data *lcd)
#include <sys/stat.h>
#include <linux/types.h>
-#include <libcfs/byteorder.h>
-
#define READ 1
#define WRITE 2
-#define LPDS sizeof(__u64)
-int block_debug_setup(void *addr, int len, __u64 off, __u64 id)
+#define LPDS sizeof(uint64_t)
+int block_debug_setup(void *addr, int len, uint64_t off, uint64_t id)
{
- off = cpu_to_le64(off);
- id = cpu_to_le64(id);
+ off = htole64(off);
+ id = htole64(id);
memcpy(addr, (char *)&off, LPDS);
memcpy(addr + LPDS, (char *)&id, LPDS);
uint64_t ne_off;
int err = 0;
- ne_off = le64_to_cpu(off);
- id = le64_to_cpu(id);
+ ne_off = le64toh(off);
+ id = le64toh(id);
if (memcmp(addr, (char *)&ne_off, LPDS)) {
fprintf(stderr, "%s: for offset %"PRIu64" off: %"PRIx64" != %"PRIx64"\n",
who, off, *(uint64_t *)addr, ne_off);
{
int fd;
char *buf;
- long long count, last, offset;
+ long long count, last;
long pg_vec, len;
- uint64_t objid;
+ uint64_t objid, offset;
struct stat st;
int flags = 0;
int cmd = 0;
}
for (offset = 0; offset < last && cmd & WRITE; offset += len) {
- int i;
+ unsigned int i;
for (i = 0; i < len; i += st.st_blksize)
- block_debug_setup(buf + i, st.st_blksize,
+ block_debug_setup(buf + i, st.st_blksize,
offset + i, objid);
rc = write(fd, buf, len);
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
+#include <endian.h>
#include <errno.h>
#include <sys/types.h>
-#ifdef HAVE_ENDIAN_H
-#include <endian.h>
-#endif
-
void usage(void)
{
printf("usage: create_iam "
#include <string.h>
#include <time.h>
-#include <libcfs/byteorder.h>
#include "lgss_utils.h"
static int lgss_null_prepare_cred(struct lgss_cred *cred)
tmp |= cred->lc_root_flags;
/* big-endian for the wire */
- tmp = cpu_to_be64(tmp);
+ tmp = htobe64(tmp);
memcpy(cred->lc_mech_token.value, &tmp, cred->lc_mech_token.length);
return 0;
bufs[4] = skc->sc_nodemap_hash;
/* big endian flags for the wire */
- flags = cpu_to_be32(skc->sc_flags);
+ flags = htobe64(skc->sc_flags);
bufs[5].value = &flags;
bufs[5].length = sizeof(flags);
if (!config)
return;
- config->skc_version = be32_to_cpu(config->skc_version);
- config->skc_hmac_alg = be16_to_cpu(config->skc_hmac_alg);
- config->skc_crypt_alg = be16_to_cpu(config->skc_crypt_alg);
- config->skc_expire = be32_to_cpu(config->skc_expire);
- config->skc_shared_keylen = be32_to_cpu(config->skc_shared_keylen);
- config->skc_session_keylen = be32_to_cpu(config->skc_session_keylen);
+ config->skc_version = htobe32(config->skc_version);
+ config->skc_hmac_alg = htobe16(config->skc_hmac_alg);
+ config->skc_crypt_alg = htobe16(config->skc_crypt_alg);
+ config->skc_expire = htobe32(config->skc_expire);
+ config->skc_shared_keylen = htobe32(config->skc_shared_keylen);
+ config->skc_session_keylen = htobe32(config->skc_session_keylen);
for (i = 0; i < MAX_MGSNIDS; i++)
- config->skc_mgsnids[i] = be64_to_cpu(config->skc_mgsnids[i]);
+ config->skc_mgsnids[i] = htobe64(config->skc_mgsnids[i]);
return;
}
if (!config)
return;
- config->skc_version = cpu_to_be32(config->skc_version);
- config->skc_hmac_alg = cpu_to_be16(config->skc_hmac_alg);
- config->skc_crypt_alg = cpu_to_be16(config->skc_crypt_alg);
- config->skc_expire = cpu_to_be32(config->skc_expire);
- config->skc_shared_keylen = cpu_to_be32(config->skc_shared_keylen);
- config->skc_session_keylen = cpu_to_be32(config->skc_session_keylen);
+ config->skc_version = be32toh(config->skc_version);
+ config->skc_hmac_alg = be16toh(config->skc_hmac_alg);
+ config->skc_crypt_alg = be16toh(config->skc_crypt_alg);
+ config->skc_expire = be32toh(config->skc_expire);
+ config->skc_shared_keylen = be32toh(config->skc_shared_keylen);
+ config->skc_session_keylen = be32toh(config->skc_session_keylen);
for (i = 0; i < MAX_MGSNIDS; i++)
- config->skc_mgsnids[i] = cpu_to_be64(config->skc_mgsnids[i]);
+ config->skc_mgsnids[i] = be64toh(config->skc_mgsnids[i]);
return;
}
skp = session_key->value;
i = 0;
while (remain > 0) {
- counter = cpu_to_be32(i++);
+ counter = be32toh(i++);
rc = sk_sign_bufs(&kctx->skc_shared_key, bufs, 4,
sk_hash_to_evp_md(kctx->skc_hmac_alg), &tmp_hash);
if (rc) {
}
memcpy(&flags, bufs[5].value, sizeof(flags));
- skc = sk_create_cred(target, snd->nm_name, be32_to_cpu(flags));
+ skc = sk_create_cred(target, snd->nm_name, be32toh(flags));
if (!skc) {
printerr(0, "Failed to create sk credentials\n");
for (i = 0; i < numbufs; i++)
snd->maj_stat = GSS_S_COMPLETE;
memcpy(&tmp, snd->in_tok.value, sizeof(tmp));
- tmp = be64_to_cpu(tmp);
+ tmp = be64toh(tmp);
flags = (uint32_t)(tmp & 0x00000000ffffffff);
memset(&cred, 0, sizeof(cred));
cred.cr_mapped_uid = -1;
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
+#include <endian.h>
#include <errno.h>
#include <assert.h>
#include <sys/ioctl.h>
#include <sys/types.h>
-#include <libcfs/byteorder.h>
#include <libcfs/util/string.h>
#include <lustre/libiam.h>
root = buf;
*root = (typeof(*root)) {
- .ilr_magic = cpu_to_le64(IAM_LFIX_ROOT_MAGIC),
- .ilr_keysize = cpu_to_le16(keysize),
- .ilr_recsize = cpu_to_le16(recsize),
- .ilr_ptrsize = cpu_to_le16(ptrsize),
+ .ilr_magic = htole64(IAM_LFIX_ROOT_MAGIC),
+ .ilr_keysize = htole16(keysize),
+ .ilr_recsize = htole16(recsize),
+ .ilr_ptrsize = htole16(ptrsize),
.ilr_indirect_levels = 0
};
/*
* limit itself + one pointer to the leaf.
*/
- .count = cpu_to_le16(2),
+ .count = htole16(2),
.limit = lfix_root_limit(blocksize, keysize + ptrsize)
};
entry += keysize;
/* now @entry points to <ptr> */
if (ptrsize == 4)
- STORE_UNALIGNED(cpu_to_le32(1), (u_int32_t *)entry);
+ STORE_UNALIGNED(htole32(1), (u_int32_t *)entry);
else
- STORE_UNALIGNED(cpu_to_le64(1), (u_int64_t *)entry);
+ STORE_UNALIGNED(htole64(1), (u_int64_t *)entry);
}
static void lfix_leaf(void *buf,
/* form leaf */
head = buf;
*head = (typeof(*head)) {
- .ill_magic = cpu_to_le16(IAM_LEAF_HEADER_MAGIC),
+ .ill_magic = htole16(IAM_LEAF_HEADER_MAGIC),
/*
* Leaf contains an entry with the smallest possible key
* (created by zeroing).
*/
- .ill_count = cpu_to_le16(1),
+ .ill_count = htole16(1),
};
}
isize = sizeof(lvar_hash_t) + ptrsize;
root = buf;
*root = (typeof(*root)) {
- .vr_magic = cpu_to_le32(IAM_LVAR_ROOT_MAGIC),
- .vr_recsize = cpu_to_le16(recsize),
- .vr_ptrsize = cpu_to_le16(ptrsize),
+ .vr_magic = htole32(IAM_LVAR_ROOT_MAGIC),
+ .vr_recsize = htole16(recsize),
+ .vr_ptrsize = htole16(ptrsize),
.vr_indirect_levels = 0
};
/*
* limit itself + one pointer to the leaf.
*/
- .count = cpu_to_le16(2),
+ .count = htole16(2),
.limit = lvar_root_limit(blocksize, keysize + ptrsize)
};
entry += sizeof(lvar_hash_t);
/* now @entry points to <ptr> */
if (ptrsize == 4)
- STORE_UNALIGNED(cpu_to_le32(1), (u_int32_t *)entry);
+ STORE_UNALIGNED(htole32(1), (u_int32_t *)entry);
else
- STORE_UNALIGNED(cpu_to_le64(1), (u_int64_t *)entry);
+ STORE_UNALIGNED(htole64(1), (u_int64_t *)entry);
}
static int lvar_esize(int namelen, int recsize)
/* form leaf */
head = buf;
*head = (typeof(*head)) {
- .vlh_magic = cpu_to_le16(IAM_LVAR_LEAF_MAGIC),
- .vlh_used = cpu_to_le16(sizeof *head + lvar_esize(0, recsize))
+ .vlh_magic = htole16(IAM_LVAR_LEAF_MAGIC),
+ .vlh_used = htole16(sizeof *head + lvar_esize(0, recsize))
};
rec = (void *)(head + 1);
rec[offsetof(struct lvar_leaf_entry, vle_key)] = recsize;
#include <errno.h>
#include <sys/types.h>
#include <sys/xattr.h>
-#include <libcfs/byteorder.h>
+#include <asm/byteorder.h>
#include <lustre/lustre_user.h>
int main(int argc, char *argv[])
/* old filter_fid */
printf("%s: objid=%llu seq=%llu parent="DFID
" stripe=%u\n", argv[i],
- (unsigned long long)le64_to_cpu(ffo->ff_objid),
- (unsigned long long)le64_to_cpu(ffo->ff_seq),
- (unsigned long long)le64_to_cpu(ffo->ff_parent.f_seq),
- le32_to_cpu(ffo->ff_parent.f_oid), 0 /* ver */,
+ (unsigned long long)__le64_to_cpu(ffo->ff_objid),
+ (unsigned long long)__le64_to_cpu(ffo->ff_seq),
+ (unsigned long long)__le64_to_cpu(ffo->ff_parent.f_seq),
+ le32toh(ffo->ff_parent.f_oid), 0 /* ver */,
/* this is stripe_nr actually */
- le32_to_cpu(ffo->ff_parent.f_stripe_idx));
+ le32toh(ffo->ff_parent.f_stripe_idx));
} else {
printf("%s: parent="DFID" stripe=%u\n", argv[i],
- (unsigned long long)le64_to_cpu(ff->ff_parent.f_seq),
- le32_to_cpu(ff->ff_parent.f_oid), 0, /* ver */
+ (unsigned long long)__le64_to_cpu(ff->ff_parent.f_seq),
+ __le32_to_cpu(ff->ff_parent.f_oid), 0, /* ver */
/* this is stripe_nr actually */
- le32_to_cpu(ff->ff_parent.f_stripe_idx));
+ __le32_to_cpu(ff->ff_parent.f_stripe_idx));
}
}
}
/* the llog header not countable here.*/
- recs_num = le32_to_cpu((*llog)->llh_count) - 1;
+ recs_num = __le32_to_cpu((*llog)->llh_count) - 1;
recs_buf = malloc(recs_num * sizeof(**recs_pr));
if (recs_buf == NULL) {
}
recs_pr = (struct llog_rec_hdr **)recs_buf;
- ptr = file_buf + le32_to_cpu((*llog)->llh_hdr.lrh_len);
+ ptr = file_buf + __le32_to_cpu((*llog)->llh_hdr.lrh_len);
i = 0;
while (ptr < (file_buf + file_size)) {
}
cur_rec = (struct llog_rec_hdr *)ptr;
- idx = le32_to_cpu(cur_rec->lrh_index);
+ idx = __le32_to_cpu(cur_rec->lrh_index);
recs_pr[i] = cur_rec;
offset = (unsigned long)ptr - (unsigned long)file_buf;
if (cur_rec->lrh_len == 0 ||
i--;
}
- ptr += le32_to_cpu(cur_rec->lrh_len);
+ ptr += __le32_to_cpu(cur_rec->lrh_len);
if ((ptr - file_buf) > file_size) {
printf("The log is corrupt (too big at %d)\n", i);
rc = -EINVAL;
void print_llog_header(struct llog_log_hdr *llog_buf)
{
- time_t t;
+ time_t t;
- printf("Header size : %u\n",
- le32_to_cpu(llog_buf->llh_hdr.lrh_len));
+ printf("Header size : %u\n",
+ __le32_to_cpu(llog_buf->llh_hdr.lrh_len));
- t = le64_to_cpu(llog_buf->llh_timestamp);
- printf("Time : %s", ctime(&t));
+ t = __le64_to_cpu(llog_buf->llh_timestamp);
+ printf("Time : %s", ctime(&t));
- printf("Number of records: %u\n",
- le32_to_cpu(llog_buf->llh_count)-1);
+ printf("Number of records: %u\n",
+ __le32_to_cpu(llog_buf->llh_count)-1);
- printf("Target uuid : %s \n",
- (char *)(&llog_buf->llh_tgtuuid));
+ printf("Target uuid : %s\n",
+ (char *)(&llog_buf->llh_tgtuuid));
- /* Add the other info you want to view here */
+ /* Add the other info you want to view here */
- printf("-----------------------\n");
- return;
+ printf("-----------------------\n");
+ return;
}
static void print_1_cfg(struct lustre_cfg *lcfg)
void print_lustre_cfg(struct lustre_cfg *lcfg, int *skip)
{
- enum lcfg_command_type cmd = le32_to_cpu(lcfg->lcfg_command);
+ enum lcfg_command_type cmd = __le32_to_cpu(lcfg->lcfg_command);
if (*skip > 0)
printf("SKIP ");
void print_changelog_rec(struct llog_changelog_rec *rec)
{
printf("changelog record id:0x%x cr_flags:0x%x cr_type:%s(0x%x)\n",
- le32_to_cpu(rec->cr_hdr.lrh_id),
- le32_to_cpu(rec->cr.cr_flags),
- changelog_type2str(le32_to_cpu(rec->cr.cr_type)),
- le32_to_cpu(rec->cr.cr_type));
+ __le32_to_cpu(rec->cr_hdr.lrh_id),
+ __le32_to_cpu(rec->cr.cr_flags),
+ changelog_type2str(__le32_to_cpu(rec->cr.cr_type)),
+ __le32_to_cpu(rec->cr.cr_type));
}
static void print_records(struct llog_rec_hdr **recs,
int i, skip = 0;
for (i = 0; i < rec_number; i++) {
- printf("#%.2d (%.3d)", le32_to_cpu(recs[i]->lrh_index),
- le32_to_cpu(recs[i]->lrh_len));
+ printf("#%.2d (%.3d)", __le32_to_cpu(recs[i]->lrh_index),
+ __le32_to_cpu(recs[i]->lrh_len));
- lopt = le32_to_cpu(recs[i]->lrh_type);
+ lopt = __le32_to_cpu(recs[i]->lrh_type);
if (recs[i]->lrh_id == CANCELLED)
printf("NOT SET ");
break;
case CHANGELOG_USER_REC:
printf("changelog_user record id:0x%x\n",
- le32_to_cpu(recs[i]->lrh_id));
+ __le32_to_cpu(recs[i]->lrh_id));
break;
default:
printf("unknown type %x\n", lopt);
}
/* swab structure fields of interest */
- lsd.lsd_feature_compat = le32_to_cpu(lsd.lsd_feature_compat);
- lsd.lsd_feature_incompat = le32_to_cpu(lsd.lsd_feature_incompat);
- lsd.lsd_feature_rocompat = le32_to_cpu(lsd.lsd_feature_rocompat);
- lsd.lsd_last_transno = le64_to_cpu(lsd.lsd_last_transno);
- lsd.lsd_osd_index = le32_to_cpu(lsd.lsd_osd_index);
- lsd.lsd_mount_count = le64_to_cpu(lsd.lsd_mount_count);
+ lsd.lsd_feature_compat = __le32_to_cpu(lsd.lsd_feature_compat);
+ lsd.lsd_feature_incompat = __le32_to_cpu(lsd.lsd_feature_incompat);
+ lsd.lsd_feature_rocompat = __le32_to_cpu(lsd.lsd_feature_rocompat);
+ lsd.lsd_last_transno = __le64_to_cpu(lsd.lsd_last_transno);
+ lsd.lsd_osd_index = __le32_to_cpu(lsd.lsd_osd_index);
+ lsd.lsd_mount_count = __le64_to_cpu(lsd.lsd_mount_count);
/* display */
printf(" uuid: %.40s\n", lsd.lsd_uuid);
/* read client information */
if (opt_client) {
- lsd.lsd_client_start = le32_to_cpu(lsd.lsd_client_start);
- lsd.lsd_client_size = le16_to_cpu(lsd.lsd_client_size);
+ lsd.lsd_client_start = __le32_to_cpu(lsd.lsd_client_start);
+ lsd.lsd_client_size = __le16_to_cpu(lsd.lsd_client_size);
printf(" client_area_start: %u\n", lsd.lsd_client_start);
printf(" client_area_size: %hu\n", lsd.lsd_client_size);
/* swab structure fields */
lcd.lcd_last_transno =
- le64_to_cpu(lcd.lcd_last_transno);
- lcd.lcd_last_xid = le64_to_cpu(lcd.lcd_last_xid);
- lcd.lcd_last_result = le32_to_cpu(lcd.lcd_last_result);
- lcd.lcd_last_data = le32_to_cpu(lcd.lcd_last_data);
- lcd.lcd_generation = le32_to_cpu(lcd.lcd_generation);
+ __le64_to_cpu(lcd.lcd_last_transno);
+ lcd.lcd_last_xid = __le64_to_cpu(lcd.lcd_last_xid);
+ lcd.lcd_last_result = __le32_to_cpu(lcd.lcd_last_result);
+ lcd.lcd_last_data = __le32_to_cpu(lcd.lcd_last_data);
+ lcd.lcd_generation = __le32_to_cpu(lcd.lcd_generation);
/* display per-client data area */
printf("\n %.40s:\n", lcd.lcd_uuid);
if (lcd.lcd_last_close_transno != 0 &&
lcd.lcd_last_close_xid != 0) {
lcd.lcd_last_close_transno =
- le64_to_cpu(lcd.lcd_last_close_transno);
+ __le64_to_cpu(lcd.lcd_last_close_transno);
lcd.lcd_last_close_xid =
- le64_to_cpu(lcd.lcd_last_close_xid);
+ __le64_to_cpu(lcd.lcd_last_close_xid);
lcd.lcd_last_close_result =
- le32_to_cpu(lcd.lcd_last_close_result);
+ __le32_to_cpu(lcd.lcd_last_close_result);
lcd.lcd_last_close_data =
- le32_to_cpu(lcd.lcd_last_close_data);
+ __le32_to_cpu(lcd.lcd_last_close_data);
printf(" last_close_transation: %llu\n",
lcd.lcd_last_close_transno);
printf(" last_close_xid: %llu\n",
}
/* check header */
- lrh.lrh_magic = le32_to_cpu(lrh.lrh_magic);
- lrh.lrh_header_size = le32_to_cpu(lrh.lrh_header_size);
- lrh.lrh_reply_size = le32_to_cpu(lrh.lrh_reply_size);
+ lrh.lrh_magic = __le32_to_cpu(lrh.lrh_magic);
+ lrh.lrh_header_size = __le32_to_cpu(lrh.lrh_header_size);
+ lrh.lrh_reply_size = __le32_to_cpu(lrh.lrh_reply_size);
if (lrh.lrh_magic != LRH_MAGIC) {
fprintf(stderr, "%s: invalid %s header: "
"lrh_magic=%08x expected %08x\n",
}
/* display reply data */
- lrd.lrd_transno = le64_to_cpu(lrd.lrd_transno);
- lrd.lrd_xid = le64_to_cpu(lrd.lrd_xid);
- lrd.lrd_data = le64_to_cpu(lrd.lrd_data);
- lrd.lrd_result = le32_to_cpu(lrd.lrd_result);
- lrd.lrd_client_gen = le32_to_cpu(lrd.lrd_client_gen);
+ lrd.lrd_transno = __le64_to_cpu(lrd.lrd_transno);
+ lrd.lrd_xid = __le64_to_cpu(lrd.lrd_xid);
+ lrd.lrd_data = __le64_to_cpu(lrd.lrd_data);
+ lrd.lrd_result = __le32_to_cpu(lrd.lrd_result);
+ lrd.lrd_client_gen = __le32_to_cpu(lrd.lrd_client_gen);
printf(" %lld:\n", slot);
printf(" client_generation: %u\n",