4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.gnu.org/licenses/gpl-2.0.html
23 * Copyright (c) 2021, DDN Storage Corporation.
26 * lustre/tests/lov_getstripe_old.c
28 * ll_getstripe_old <file>:
29 * - to verify if the striping information of composite layout files returned
30 * by llapi_file_get_stripe() is valid.
37 #include <lustre/lustreapi.h>
38 #define LOV_MAGIC_MAGIC 0x0BD0
39 #define LOV_MAGIC_MASK 0xFFFF
40 #define LOV_MAGIC_V1 (0x0BD10000 | LOV_MAGIC_MAGIC)
41 #define LOV_MAGIC_JOIN_V1 (0x0BD20000 | LOV_MAGIC_MAGIC)
42 #define LOV_MAGIC_V3 (0x0BD30000 | LOV_MAGIC_MAGIC)
43 static inline int maxint(int a, int b)
48 static void *alloc_lum()
52 v1 = sizeof(struct lov_user_md_v1) +
53 LOV_MAX_STRIPE_COUNT * sizeof(struct lov_user_ost_data_v1);
54 v3 = sizeof(struct lov_user_md_v3) +
55 LOV_MAX_STRIPE_COUNT * sizeof(struct lov_user_ost_data_v1);
57 return malloc(maxint(v1, v3));
60 int main(int argc, char **argv)
62 struct lov_user_md *lum_file = NULL;
66 fprintf(stderr, "Usage: %s <filename>\n", argv[0]);
69 lum_file = alloc_lum();
70 if (lum_file == NULL) {
75 rc = llapi_file_get_stripe(argv[1], lum_file);
80 /* stripe_size stripe_count */
81 if (lum_file->lmm_magic == LOV_MAGIC_V1)
82 printf("lmm_magic: v1\n");
83 else if (lum_file->lmm_magic == LOV_MAGIC_V3)
84 printf("lmm_magic: v3\n");
85 else if (lum_file->lmm_magic == (0x0BD60000 | LOV_MAGIC_MAGIC))
86 printf("lmm_magic: LOV_MAGIC component\n");
88 printf("stripe_count: %d\nstripe_size: %d\n",
89 lum_file->lmm_stripe_count, lum_file->lmm_stripe_size);