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.sun.com/software/products/lustre/docs/GPLv2.pdf
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
27 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
30 * Copyright (c) 2011, 2012, Intel Corporation.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
37 #ifndef _MOUNT_UTILS_H_
38 #define _MOUNT_UTILS_H_
40 /* Some of the userland headers for libzfs also require
41 * zfs/spl linux kernel headers, but including these pull
42 * in linux kernel headers which conflicts with the
43 * userland version of libcfs. So the solution is tell the
44 * libzfs user land headrs that the zfs/spl kernel headers
45 * are already included even if this is not the case.
51 #include <lustre_disk.h>
52 #include <lustre_param.h>
54 extern char *progname;
58 #define vprint(fmt, arg...) if (verbose > 0) printf(fmt, ##arg)
59 #define verrprint(fmt, arg...) if (verbose >= 0) fprintf(stderr, fmt, ##arg)
62 #define MO_IS_LOOP 0x01
63 #define MO_FORCEFORMAT 0x02
64 #define MO_FAILOVER 0x04
65 #define MO_DRYRUN 0x08
68 #define MAX_LOOP_DEVICES 16
69 #define INDEX_UNASSIGNED 0xFFFF
71 /* used to describe the options to format the lustre disk, not persistent */
73 struct lustre_disk_data mo_ldd; /* to be written in MOUNT_DATA_FILE */
74 char mo_device[128]; /* disk device name */
75 char **mo_pool_vdevs; /* list of pool vdevs */
76 char mo_loopdev[128]; /* in case a loop dev is needed */
77 char mo_mkfsopts[512]; /* options to the backing-store mkfs */
78 __u64 mo_device_sz; /* in KB */
84 /* used to describe the options to mount the lustre disk */
86 struct lustre_disk_data mo_ldd;
87 char *mo_orig_options;
88 char *mo_usource; /* user-specified mount device */
89 char *mo_source; /* our mount device name */
90 char mo_target[PATH_MAX]; /* mount directory */
96 int mo_md_stripe_cache_size;
100 int get_mountdata(char *, struct lustre_disk_data *);
102 #define MT_STR(data) mt_str((data)->ldd_mount_type)
105 #define IS_MDT(data) ((data)->ldd_flags & LDD_F_SV_TYPE_MDT)
107 #define IS_OST(data) ((data)->ldd_flags & LDD_F_SV_TYPE_OST)
109 #define IS_MGS(data) ((data)->ldd_flags & LDD_F_SV_TYPE_MGS)
111 /* mkfs/mount helper functions */
113 int run_command_err(char *cmd, int cmdsz, char *error_msg);
114 int run_command(char *cmd, int cmdsz);
115 int add_param(char *buf, char *key, char *val);
116 int get_param(char *buf, char *key, char **val);
117 char *strscat(char *dst, char *src, int buflen);
118 char *strscpy(char *dst, char *src, int buflen);
119 int check_mtab_entry(char *spec1, char *spec2, char *mntpt, char *type);
120 int update_mtab_entry(char *spec, char *mtpt, char *type, char *opts,
121 int flags, int freq, int pass);
122 int check_mountfsoptions(char *mountopts, char *wanted_mountopts, int justwarn);
123 void trim_mountfsoptions(char *s);
124 __u64 get_device_size(char* device);
126 int is_block(char *devname);
127 void disp_old_e2fsprogs_msg(const char *feature, int make_backfs);
128 int make_lustre_backfs(struct mkfs_opts *mop);
129 int write_local_files(struct mkfs_opts *mop);
130 int read_local_files(struct mkfs_opts *mop);
131 int is_lustre_target(struct mkfs_opts *mop);
133 /* loopback helper functions */
134 int file_create(char *path, int size);
135 int loop_format(struct mkfs_opts *mop);
136 int loop_setup(struct mkfs_opts *mop);
137 int loop_cleanup(struct mkfs_opts *mop);
139 /* generic target support */
140 int osd_write_ldd(struct mkfs_opts *mop);
141 int osd_read_ldd(char *dev, struct lustre_disk_data *ldd);
142 int osd_is_lustre(char *dev, unsigned *mount_type);
143 int osd_make_lustre(struct mkfs_opts *mop);
144 int osd_prepare_lustre(struct mkfs_opts *mop,
145 char *default_mountopts, int default_len,
146 char *always_mountopts, int always_len);
147 int osd_tune_lustre(char *dev, struct mount_opts *mop);
148 int osd_label_lustre(struct mount_opts *mop);
149 int osd_enable_quota(struct mkfs_opts *mop);
153 int ldiskfs_write_ldd(struct mkfs_opts *mop);
154 int ldiskfs_read_ldd(char *dev, struct lustre_disk_data *ldd);
155 int ldiskfs_is_lustre(char *dev, unsigned *mount_type);
156 int ldiskfs_make_lustre(struct mkfs_opts *mop);
157 int ldiskfs_prepare_lustre(struct mkfs_opts *mop,
158 char *default_mountopts, int default_len,
159 char *always_mountopts, int always_len);
160 int ldiskfs_tune_lustre(char *dev, struct mount_opts *mop);
161 int ldiskfs_label_lustre(struct mount_opts *mop);
162 int ldiskfs_enable_quota(struct mkfs_opts *mop);
163 int ldiskfs_init(void);
164 void ldiskfs_fini(void);
167 int zfs_write_ldd(struct mkfs_opts *mop);
168 int zfs_read_ldd(char *ds, struct lustre_disk_data *ldd);
169 int zfs_is_lustre(char *dev, unsigned *mount_type);
170 int zfs_make_lustre(struct mkfs_opts *mop);
171 int zfs_prepare_lustre(struct mkfs_opts *mop,
172 char *default_mountopts, int default_len,
173 char *always_mountopts, int always_len);
174 int zfs_tune_lustre(char *dev, struct mount_opts *mop);
175 int zfs_label_lustre(struct mount_opts *mop);