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) 2012, Whamcloud, Inc.
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 #include <lustre_disk.h>
41 #include <lustre_param.h>
43 extern char *progname;
47 #define vprint(fmt, arg...) if (verbose > 0) printf(fmt, ##arg)
48 #define verrprint(fmt, arg...) if (verbose >= 0) fprintf(stderr, fmt, ##arg)
51 #define MO_IS_LOOP 0x01
52 #define MO_FORCEFORMAT 0x02
53 #define MO_FAILOVER 0x04
54 #define MO_DRYRUN 0x08
56 #define MAX_LOOP_DEVICES 16
57 #define INDEX_UNASSIGNED 0xFFFF
59 /* used to describe the options to format the lustre disk, not persistent */
61 struct lustre_disk_data mo_ldd; /* to be written in MOUNT_DATA_FILE */
62 char mo_device[128]; /* disk device name */
63 char **mo_pool_vdevs; /* list of pool vdevs */
64 char mo_loopdev[128]; /* in case a loop dev is needed */
65 char mo_mkfsopts[512]; /* options to the backing-store mkfs */
66 __u64 mo_device_sz; /* in KB */
72 /* used to describe the options to mount the lustre disk */
74 struct lustre_disk_data mo_ldd;
75 char *mo_orig_options;
76 char *mo_usource; /* user-specified mount device */
77 char *mo_source; /* our mount device name */
78 char mo_target[PATH_MAX]; /* mount directory */
84 int mo_md_stripe_cache_size;
87 int get_mountdata(char *, struct lustre_disk_data *);
89 /* mkfs/mount helper functions */
91 int run_command_err(char *cmd, int cmdsz, char *error_msg);
92 int run_command(char *cmd, int cmdsz);
93 int add_param(char *buf, char *key, char *val);
94 int get_param(char *buf, char *key, char **val);
95 char *strscat(char *dst, char *src, int buflen);
96 char *strscpy(char *dst, char *src, int buflen);
97 int check_mtab_entry(char *spec1, char *spec2, char *mntpt, char *type);
98 int update_mtab_entry(char *spec, char *mtpt, char *type, char *opts,
99 int flags, int freq, int pass);
100 int check_mountfsoptions(char *mountopts, char *wanted_mountopts, int justwarn);
101 void trim_mountfsoptions(char *s);
102 __u64 get_device_size(char* device);
104 int is_block(char *devname);
105 void disp_old_e2fsprogs_msg(const char *feature, int make_backfs);
106 int make_lustre_backfs(struct mkfs_opts *mop);
107 int write_local_files(struct mkfs_opts *mop);
108 int read_local_files(struct mkfs_opts *mop);
109 int is_lustre_target(struct mkfs_opts *mop);
111 /* loopback helper functions */
112 int file_create(char *path, int size);
113 int loop_format(struct mkfs_opts *mop);
114 int loop_setup(struct mkfs_opts *mop);
115 int loop_cleanup(struct mkfs_opts *mop);
117 /* generic target support */
118 int osd_write_ldd(struct mkfs_opts *mop);
119 int osd_read_ldd(char *dev, struct lustre_disk_data *ldd);
120 int osd_is_lustre(char *dev, unsigned *mount_type);
121 int osd_make_lustre(struct mkfs_opts *mop);
122 int osd_prepare_lustre(struct mkfs_opts *mop,
123 char *default_mountopts, int default_len,
124 char *always_mountopts, int always_len);
128 int ldiskfs_write_ldd(struct mkfs_opts *mop);
129 int ldiskfs_read_ldd(char *dev, struct lustre_disk_data *ldd);
130 int ldiskfs_is_lustre(char *dev, unsigned *mount_type);
131 int ldiskfs_make_lustre(struct mkfs_opts *mop);
132 int ldiskfs_prepare_lustre(struct mkfs_opts *mop,
133 char *default_mountopts, int default_len,
134 char *always_mountopts, int always_len);
135 int ldiskfs_init(void);
136 void ldiskfs_fini(void);