dm-ioctl.c (86a3238c7b9b759cb864f4f768ab2e24687dc0e6) | dm-ioctl.c (a4a82ce3d24d4409143a7b7b980072ada6e20b2a) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Copyright (C) 2001, 2002 Sistina Software (UK) Limited. 4 * Copyright (C) 2004 - 2006 Red Hat, Inc. All rights reserved. 5 * 6 * This file is released under the GPL. 7 */ 8 --- 21 unchanged lines hidden (view full) --- 30struct dm_file { 31 /* 32 * poll will wait until the global event number is greater than 33 * this value. 34 */ 35 volatile unsigned int global_event_nr; 36}; 37 | 1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Copyright (C) 2001, 2002 Sistina Software (UK) Limited. 4 * Copyright (C) 2004 - 2006 Red Hat, Inc. All rights reserved. 5 * 6 * This file is released under the GPL. 7 */ 8 --- 21 unchanged lines hidden (view full) --- 30struct dm_file { 31 /* 32 * poll will wait until the global event number is greater than 33 * this value. 34 */ 35 volatile unsigned int global_event_nr; 36}; 37 |
38/*----------------------------------------------------------------- | 38/* 39 *--------------------------------------------------------------- |
39 * The ioctl interface needs to be able to look up devices by 40 * name or uuid. | 40 * The ioctl interface needs to be able to look up devices by 41 * name or uuid. |
41 *---------------------------------------------------------------*/ | 42 *--------------------------------------------------------------- 43 */ |
42struct hash_cell { 43 struct rb_node name_node; 44 struct rb_node uuid_node; 45 bool name_set; 46 bool uuid_set; 47 48 char *name; 49 char *uuid; --- 24 unchanged lines hidden (view full) --- 74 */ 75static DEFINE_MUTEX(dm_hash_cells_mutex); 76 77static void dm_hash_exit(void) 78{ 79 dm_hash_remove_all(false, false, false); 80} 81 | 44struct hash_cell { 45 struct rb_node name_node; 46 struct rb_node uuid_node; 47 bool name_set; 48 bool uuid_set; 49 50 char *name; 51 char *uuid; --- 24 unchanged lines hidden (view full) --- 76 */ 77static DEFINE_MUTEX(dm_hash_cells_mutex); 78 79static void dm_hash_exit(void) 80{ 81 dm_hash_remove_all(false, false, false); 82} 83 |
82/*----------------------------------------------------------------- | 84/* 85 *--------------------------------------------------------------- |
83 * Code for looking up a device by name | 86 * Code for looking up a device by name |
84 *---------------------------------------------------------------*/ | 87 *--------------------------------------------------------------- 88 */ |
85static struct hash_cell *__get_name_cell(const char *str) 86{ 87 struct rb_node *n = name_rb_tree.rb_node; 88 89 while (n) { 90 struct hash_cell *hc = container_of(n, struct hash_cell, name_node); 91 int c = strcmp(hc->name, str); 92 if (!c) { --- 98 unchanged lines hidden (view full) --- 191 if (!hc) { 192 dm_put(md); 193 return NULL; 194 } 195 196 return hc; 197} 198 | 89static struct hash_cell *__get_name_cell(const char *str) 90{ 91 struct rb_node *n = name_rb_tree.rb_node; 92 93 while (n) { 94 struct hash_cell *hc = container_of(n, struct hash_cell, name_node); 95 int c = strcmp(hc->name, str); 96 if (!c) { --- 98 unchanged lines hidden (view full) --- 195 if (!hc) { 196 dm_put(md); 197 return NULL; 198 } 199 200 return hc; 201} 202 |
199/*----------------------------------------------------------------- | 203/* 204 *--------------------------------------------------------------- |
200 * Inserting, removing and renaming a device. | 205 * Inserting, removing and renaming a device. |
201 *---------------------------------------------------------------*/ | 206 *--------------------------------------------------------------- 207 */ |
202static struct hash_cell *alloc_cell(const char *name, const char *uuid, 203 struct mapped_device *md) 204{ 205 struct hash_cell *hc; 206 207 hc = kmalloc(sizeof(*hc), GFP_KERNEL); 208 if (!hc) 209 return NULL; --- 286 unchanged lines hidden (view full) --- 496 return md; 497} 498 499void dm_deferred_remove(void) 500{ 501 dm_hash_remove_all(true, false, true); 502} 503 | 208static struct hash_cell *alloc_cell(const char *name, const char *uuid, 209 struct mapped_device *md) 210{ 211 struct hash_cell *hc; 212 213 hc = kmalloc(sizeof(*hc), GFP_KERNEL); 214 if (!hc) 215 return NULL; --- 286 unchanged lines hidden (view full) --- 502 return md; 503} 504 505void dm_deferred_remove(void) 506{ 507 dm_hash_remove_all(true, false, true); 508} 509 |
504/*----------------------------------------------------------------- | 510/* 511 *--------------------------------------------------------------- |
505 * Implementation of the ioctl commands | 512 * Implementation of the ioctl commands |
506 *---------------------------------------------------------------*/ | 513 *--------------------------------------------------------------- 514 */ |
507/* 508 * All the ioctl commands get dispatched to functions with this 509 * prototype. 510 */ 511typedef int (*ioctl_fn)(struct file *filp, struct dm_ioctl *param, size_t param_size); 512 513static int remove_all(struct file *filp, struct dm_ioctl *param, size_t param_size) 514{ --- 1244 unchanged lines hidden (view full) --- 1759 * The ioctl parameter block consists of two parts, a dm_ioctl struct 1760 * followed by a data buffer. This flag is set if the second part, 1761 * which has a variable size, is not used by the function processing 1762 * the ioctl. 1763 */ 1764#define IOCTL_FLAGS_NO_PARAMS 1 1765#define IOCTL_FLAGS_ISSUE_GLOBAL_EVENT 2 1766 | 515/* 516 * All the ioctl commands get dispatched to functions with this 517 * prototype. 518 */ 519typedef int (*ioctl_fn)(struct file *filp, struct dm_ioctl *param, size_t param_size); 520 521static int remove_all(struct file *filp, struct dm_ioctl *param, size_t param_size) 522{ --- 1244 unchanged lines hidden (view full) --- 1767 * The ioctl parameter block consists of two parts, a dm_ioctl struct 1768 * followed by a data buffer. This flag is set if the second part, 1769 * which has a variable size, is not used by the function processing 1770 * the ioctl. 1771 */ 1772#define IOCTL_FLAGS_NO_PARAMS 1 1773#define IOCTL_FLAGS_ISSUE_GLOBAL_EVENT 2 1774 |
1767/*----------------------------------------------------------------- 1768 * Implementation of open/close/ioctl on the special char 1769 * device. 1770 *---------------------------------------------------------------*/ | 1775/* 1776 *--------------------------------------------------------------- 1777 * Implementation of open/close/ioctl on the special char device. 1778 *--------------------------------------------------------------- 1779 */ |
1771static ioctl_fn lookup_ioctl(unsigned int cmd, int *ioctl_flags) 1772{ 1773 static const struct { 1774 int cmd; 1775 int flags; 1776 ioctl_fn fn; 1777 } _ioctls[] = { 1778 {DM_VERSION_CMD, 0, NULL}, /* version is dealt with elsewhere */ --- 480 unchanged lines hidden --- | 1780static ioctl_fn lookup_ioctl(unsigned int cmd, int *ioctl_flags) 1781{ 1782 static const struct { 1783 int cmd; 1784 int flags; 1785 ioctl_fn fn; 1786 } _ioctls[] = { 1787 {DM_VERSION_CMD, 0, NULL}, /* version is dealt with elsewhere */ --- 480 unchanged lines hidden --- |