1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 only,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License version 2 for more details (a copy is included
16 * in the LICENSE file that accompanied this code).
18 * You should have received a copy of the GNU General Public License
19 * version 2 along with this program; If not, see
20 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * Copyright 2008 Sun Microsystems, Inc. All rights reserved
30 * Use is subject to license terms.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
36 * lustre/obdclass/obdo.c
38 * Object Devices Class Driver
39 * These are the only exported functions, they provide some generic
40 * infrastructure for managing object devices
43 #define DEBUG_SUBSYSTEM S_CLASS
45 # define EXPORT_SYMTAB
49 #include <liblustre.h>
51 #include <obd_class.h>
52 #include <lustre/lustre_idl.h>
55 void obdo_cpy_md(struct obdo *dst, struct obdo *src, obd_flag valid)
58 CDEBUG(D_INODE, "src obdo "LPX64" valid "LPX64", dst obdo "LPX64"\n",
59 src->o_id, src->o_valid, dst->o_id);
61 if (valid & OBD_MD_FLATIME)
62 dst->o_atime = src->o_atime;
63 if (valid & OBD_MD_FLMTIME)
64 dst->o_mtime = src->o_mtime;
65 if (valid & OBD_MD_FLCTIME)
66 dst->o_ctime = src->o_ctime;
67 if (valid & OBD_MD_FLSIZE)
68 dst->o_size = src->o_size;
69 if (valid & OBD_MD_FLBLOCKS) /* allocation of space */
70 dst->o_blocks = src->o_blocks;
71 if (valid & OBD_MD_FLBLKSZ)
72 dst->o_blksize = src->o_blksize;
73 if (valid & OBD_MD_FLTYPE)
74 dst->o_mode = (dst->o_mode & ~S_IFMT) | (src->o_mode & S_IFMT);
75 if (valid & OBD_MD_FLMODE)
76 dst->o_mode = (dst->o_mode & S_IFMT) | (src->o_mode & ~S_IFMT);
77 if (valid & OBD_MD_FLUID)
78 dst->o_uid = src->o_uid;
79 if (valid & OBD_MD_FLGID)
80 dst->o_gid = src->o_gid;
81 if (valid & OBD_MD_FLFLAGS)
82 dst->o_flags = src->o_flags;
83 if (valid & OBD_MD_FLGENER)
84 dst->o_generation = src->o_generation;
85 if (valid & OBD_MD_FLHANDLE)
86 dst->o_handle = src->o_handle;
87 if (valid & OBD_MD_FLCOOKIE)
88 dst->o_lcookie = src->o_lcookie;
90 dst->o_valid |= valid;
92 EXPORT_SYMBOL(obdo_cpy_md);
94 void obdo_to_ioobj(struct obdo *oa, struct obd_ioobj *ioobj)
96 ioobj->ioo_id = oa->o_id;
97 if (oa->o_valid & OBD_MD_FLGROUP)
98 ioobj->ioo_gr = oa->o_gr;
101 ioobj->ioo_type = oa->o_mode;
103 EXPORT_SYMBOL(obdo_to_ioobj);