1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Object Devices Class Driver
6 * Copyright (C) 2001-2003 Cluster File Systems, Inc.
8 * This file is part of the Lustre file system, http://www.lustre.org
9 * Lustre is a trademark of Cluster File Systems, Inc.
11 * You may have signed or agreed to another license before downloading
12 * this software. If so, you are bound by the terms and conditions
13 * of that agreement, and the following does not apply to you. See the
14 * LICENSE file included with this distribution for more information.
16 * If you did not agree to a different license, then this copy of Lustre
17 * is open source software; you can redistribute it and/or modify it
18 * under the terms of version 2 of the GNU General Public License as
19 * published by the Free Software Foundation.
21 * In either case, Lustre is distributed in the hope that it will be
22 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
23 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * license text for more details.
26 * These are the only exported functions, they provide some generic
27 * infrastructure for managing object devices
30 #define DEBUG_SUBSYSTEM S_CLASS
32 # define EXPORT_SYMTAB
36 #include <liblustre.h>
38 #include <obd_class.h>
39 #include <lustre/lustre_idl.h>
42 void obdo_cpy_md(struct obdo *dst, struct obdo *src, obd_flag valid)
45 CLASSERT(sizeof(struct lustre_handle) +
46 sizeof(struct llog_cookie) <= sizeof(src->o_inline));
48 CDEBUG(D_INODE, "src obdo "LPX64" valid "LPX64", dst obdo "LPX64"\n",
49 src->o_id, src->o_valid, dst->o_id);
51 if (valid & OBD_MD_FLATIME)
52 dst->o_atime = src->o_atime;
53 if (valid & OBD_MD_FLMTIME)
54 dst->o_mtime = src->o_mtime;
55 if (valid & OBD_MD_FLCTIME)
56 dst->o_ctime = src->o_ctime;
57 if (valid & OBD_MD_FLSIZE)
58 dst->o_size = src->o_size;
59 if (valid & OBD_MD_FLBLOCKS) /* allocation of space */
60 dst->o_blocks = src->o_blocks;
61 if (valid & OBD_MD_FLBLKSZ)
62 dst->o_blksize = src->o_blksize;
63 if (valid & OBD_MD_FLTYPE)
64 dst->o_mode = (dst->o_mode & ~S_IFMT) | (src->o_mode & S_IFMT);
65 if (valid & OBD_MD_FLMODE)
66 dst->o_mode = (dst->o_mode & S_IFMT) | (src->o_mode & ~S_IFMT);
67 if (valid & OBD_MD_FLUID)
68 dst->o_uid = src->o_uid;
69 if (valid & OBD_MD_FLGID)
70 dst->o_gid = src->o_gid;
71 if (valid & OBD_MD_FLFLAGS)
72 dst->o_flags = src->o_flags;
73 if (valid & OBD_MD_FLGENER)
74 dst->o_generation = src->o_generation;
75 if (valid & OBD_MD_FLINLINE)
76 memcpy(dst->o_inline, src->o_inline, sizeof(src->o_inline));
78 dst->o_valid |= valid;
80 EXPORT_SYMBOL(obdo_cpy_md);
82 void obdo_to_ioobj(struct obdo *oa, struct obd_ioobj *ioobj)
84 ioobj->ioo_id = oa->o_id;
85 if (oa->o_valid & OBD_MD_FLGROUP)
86 ioobj->ioo_gr = oa->o_gr;
89 ioobj->ioo_type = oa->o_mode;
91 EXPORT_SYMBOL(obdo_to_ioobj);