1media_getattr(3VOLMGT)Volume Management Library Functionsmedia_getattr(3VOLMGT)
2
3
4
6 media_getattr, media_setattr - get and set media attributes
7
9 cc [ flag ... ] file ... -lvolmgt [ library ... ]
10 #include <volmgt.h>
11
12
13
14 char *media_getattr(char *vol_path, char *attr);
15
16
17 int media_setattr(char *vol_path, char *attr, char *value);
18
19
21 This function is obsolete. The management of removable media by the
22 Volume Management feature, including vold, has been replaced by soft‐
23 ware that supports the Hardware Abstraction Layer (HAL). Programmatic
24 support for HAL is through the HAL APIs, which are documented on the
25 HAL web site. See hal(5). The return value of this function is unde‐
26 fined.
27
28
29 media_setattr() and media_getattr() respectively set and get attribute-
30 value pairs (called properties) on a per-volume basis.
31
32
33 Volume management supports system properties and user properties. Sys‐
34 tem properties are ones that volume management predefines. Some of
35 these system properties are writable, but only by the user that owns
36 the volume being specified, and some system properties are read only:
37
38
39
40
41 Attribute Writable Value Description
42 ──────────────────────────────────────────────────────────────────────────────────────────────────────
43 s-access RO "seq", "rand" sequential or random access
44 s-density RO "low", "medium", "high" media density
45 s-parts RO comma separated list of slice numbers list of partitions on this volume
46 s-location RO pathname volume management pathname to media
47 s-mejectable RO "true", "false" whether or not media is manually
48 ejectable
49 s-rmoneject R/W "true", "false" should media access points be
50 removed from database upon ejection
51 s-enxio R/W "true", "false" if set return ENXIO when media
52 access attempted
53
54
55
56 Properties can also be defined by the user. In this case the value can
57 be any string the user wishes.
58
60 The return from this function is undefined.
61
63 Both media_getattr() and media_setattr() can fail returning a null
64 pointer if an open(2) of the specified vol_path fails, if an fstat(2)
65 of that pathname fails, or if that pathname is not a block or character
66 special device.
67
68
69 media_getattr() can also fail if the specified attribute was not found,
70 and media_setattr() can also fail if the caller doesn't have permission
71 to set the attribute, either because it's is a system attribute, or
72 because the caller doesn't own the specified volume.
73
75 Example 1 Using media_getattr()
76
77
78 The following example checks to see if the volume called fred that vol‐
79 ume management is managing can be ejected by means of software, or if
80 it can only be manually ejected:
81
82
83 if (media_getattr("/rdsk/fred", "s-mejectable") != NULL) {
84 (void) printf("\"fred\" must be manually ejected\n");
85 } else {
86 (void) printf("software can eject \"fred\"\n");
87 }
88
89
90
91 This example shows setting the s-enxio property for the floppy volume
92 currently in the first floppy drive:
93
94
95 int res;
96 if ((res = media_setattr("/dev/aliases/floppy0", "s-enxio",
97 "true")) == 0) {
98 (void) printf("can't set s-enxio flag for floppy0\n");
99 }
100
101
103 See attributes(5) for descriptions of the following attributes:
104
105
106
107
108 ┌─────────────────────────────┬─────────────────────────────┐
109 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
110 ├─────────────────────────────┼─────────────────────────────┤
111 │MT-Level │MT-Safe │
112 ├─────────────────────────────┼─────────────────────────────┤
113 │Interface Stability │Obsolete │
114 └─────────────────────────────┴─────────────────────────────┘
115
117 lstat(2), open(2), readlink(2), stat(2), free(3C), malloc(3C),
118 media_findname(3VOLMGT), volmgt_check(3VOLMGT), volmgt_inuse(3VOLMGT),
119 volmgt_root(3VOLMGT), volmgt_running(3VOLMGT), volmgt_symname(3VOLMGT),
120 attributes(5), hal(5)
121
122
123
124SunOS 5.11 8 Mar 2007 media_getattr(3VOLMGT)