Sync usage with man page.
[netbsd-mini2440.git] / external / gpl2 / lvm2 / dist / lib / device / device.h
blob27bca06c3ef028ad91f653d6e75fa5373a701cf1
1 /* $NetBSD$ */
3 /*
4 * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
5 * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
7 * This file is part of LVM2.
9 * This copyrighted material is made available to anyone wishing to use,
10 * modify, copy, or redistribute it subject to the terms and conditions
11 * of the GNU Lesser General Public License v.2.1.
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program; if not, write to the Free Software Foundation,
15 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 #ifndef _LVM_DEVICE_H
19 #define _LVM_DEVICE_H
21 #include "uuid.h"
23 #include <fcntl.h>
25 #define DEV_ACCESSED_W 0x00000001 /* Device written to? */
26 #define DEV_REGULAR 0x00000002 /* Regular file? */
27 #define DEV_ALLOCED 0x00000004 /* dm_malloc used */
28 #define DEV_OPENED_RW 0x00000008 /* Opened RW */
29 #define DEV_OPENED_EXCL 0x00000010 /* Opened EXCL */
30 #define DEV_O_DIRECT 0x00000020 /* Use O_DIRECT */
31 #define DEV_O_DIRECT_TESTED 0x00000040 /* DEV_O_DIRECT is reliable */
34 * All devices in LVM will be represented by one of these.
35 * pointer comparisons are valid.
37 struct device {
38 struct dm_list aliases; /* struct str_list from lvm-types.h */
39 dev_t dev;
41 /* private */
42 int fd;
43 int open_count;
44 int block_size;
45 int read_ahead;
46 uint32_t flags;
47 uint64_t end;
48 struct dm_list open_list;
50 char pvid[ID_LEN + 1];
51 char _padding[7];
54 struct device_list {
55 struct dm_list list;
56 struct device *dev;
59 struct device_area {
60 struct device *dev;
61 uint64_t start; /* Bytes */
62 uint64_t size; /* Bytes */
66 * All io should use these routines.
68 int dev_get_size(const struct device *dev, uint64_t *size);
69 int dev_get_sectsize(struct device *dev, uint32_t *size);
70 int dev_get_read_ahead(struct device *dev, uint32_t *read_ahead);
72 /* Use quiet version if device number could change e.g. when opening LV */
73 int dev_open(struct device *dev);
74 int dev_open_quiet(struct device *dev);
75 int dev_open_flags(struct device *dev, int flags, int direct, int quiet);
76 int dev_close(struct device *dev);
77 int dev_close_immediate(struct device *dev);
78 void dev_close_all(void);
79 int dev_test_excl(struct device *dev);
81 int dev_fd(struct device *dev);
82 const char *dev_name(const struct device *dev);
84 int dev_read(struct device *dev, uint64_t offset, size_t len, void *buffer);
85 int dev_read_circular(struct device *dev, uint64_t offset, size_t len,
86 uint64_t offset2, size_t len2, void *buf);
87 int dev_write(struct device *dev, uint64_t offset, size_t len, void *buffer);
88 int dev_append(struct device *dev, size_t len, void *buffer);
89 int dev_set(struct device *dev, uint64_t offset, size_t len, int value);
90 void dev_flush(struct device *dev);
92 struct device *dev_create_file(const char *filename, struct device *dev,
93 struct str_list *alias, int use_malloc);
95 /* Return a valid device name from the alias list; NULL otherwise */
96 const char *dev_name_confirmed(struct device *dev, int quiet);
98 /* Does device contain md superblock? If so, where? */
99 int dev_is_md(struct device *dev, uint64_t *sb);
100 int dev_is_swap(struct device *dev, uint64_t *signature);
101 unsigned long dev_md_stripe_width(const char *sysfs_dir, struct device *dev);
103 int is_partitioned_dev(struct device *dev);
105 int get_primary_dev(const char *sysfs_dir,
106 struct device *dev, dev_t *result);
108 unsigned long dev_alignment_offset(const char *sysfs_dir,
109 struct device *dev);
111 unsigned long dev_minimum_io_size(const char *sysfs_dir,
112 struct device *dev);
114 unsigned long dev_optimal_io_size(const char *sysfs_dir,
115 struct device *dev);
117 #endif