1media_findname(3VOLMGT)Volume Management Library Functionmsedia_findname(3VOLMGT)
2
3
4

NAME

6       media_findname - convert a supplied name into an absolute pathname that
7       can be used to access removable media
8

SYNOPSIS

10       cc [ flag ... ] file ... -lvolmgt [ library ... ]
11       #include <volmgt.h>
12
13
14
15       char *media_findname(char *start);
16
17

DESCRIPTION

19       This function is obsolete. The management of  removable  media  by  the
20       Volume  Management  feature, including vold, has been replaced by soft‐
21       ware that supports the Hardware Abstraction Layer  (HAL).  Programmatic
22       support  for  HAL  is through the HAL APIs, which are documented on the
23       HAL web site. See hal(5). The return value of this  function  is  unde‐
24       fined.
25
26
27       media_findname()  converts  the  supplied start string into an absolute
28       pathname that can then be used to access a particular piece of media.
29
30
31       The start parameter can be one of the  following  types  of  specifica‐
32       tions:
33
34       /dev/...          An    absolute    pathname    in    /dev,   such   as
35                         /dev/rdiskette0, in which case a copy of that  string
36                         is returned (see NOTES on this page).
37
38
39       volume_name       The volume name for a particular volume, such as fred
40                         (see fdformat(1) for a description of  how  to  label
41                         floppies).
42
43
44       volmgt_symname    The  symbolic  name  for a device, such as floppy0 or
45                         cdrom2.
46
47
48       media_type        The generic media type name.  For example, floppy  or
49                         cdrom.  In  this  case media_findname() looks for the
50                         first piece of media that matches  that  media  type,
51                         starting  at 0 (zero) and continuing on until a match
52                         is found (or some  fairly  large  maximum  number  is
53                         reached).   In this case, if a match is found, a copy
54                         of the pathname to the volume found is returned.
55
56

RETURN VALUES

58       The return from this function is undefined.
59

ERRORS

61       For cases where the supplied start parameter is an  absolute  pathname,
62       media_findname()  can  fail,  returning  a  null  string pointer, if an
63       lstat(2) of that supplied pathname fails. Also, if the  supplied  abso‐
64       lute  pathname is a symbolic link, media_findname() can fail if a read‐
65       link(2) of that symbolic link fails, or if a stat(2)  of  the  pathname
66       pointed  to  by that symbolic link fails, or if any of the following is
67       true:
68
69       ENXIO    The specified absolute pathname was not  a  character  special
70                device,  and  it  was not a directory with a character special
71                device in it.
72
73

EXAMPLES

75       Example 1 Sample programs of the media_findname() function.
76
77
78       The following example attempts to find what the pathname is to a  piece
79       of  media called fred.  Notice that a volmgt_check() is done first (see
80       the NOTES section on this page).
81
82
83         (void) volmgt_check(NULL);
84         if ((nm = media_findname("fred")) != NULL) {
85                 (void) printf("media named \"fred\" is at \"%s\"\n", nm);
86         } else {
87                (void) printf("media named \"fred\" not found\n");
88         }
89
90
91
92       This example looks for whatever volume is in the  first  floppy  drive,
93       letting  media_findname()  call volmgt_check() if and only if no floppy
94       is currently known to be the first floppy drive.
95
96
97         if ((nm = media_findname("floppy0")) != NULL) {
98                 (void) printf("path to floppy0 is \"%s\"\n", nm);
99         } else {
100                 (void) printf("nothing in floppy0\n");
101         }
102
103

ATTRIBUTES

105       See attributes(5) for descriptions of the following attributes:
106
107
108
109
110       ┌─────────────────────────────┬─────────────────────────────┐
111       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
112       ├─────────────────────────────┼─────────────────────────────┤
113       │MT-Level                     │MT-Unsafe                    │
114       ├─────────────────────────────┼─────────────────────────────┤
115       │Interface Stability          │Obsolete                     │
116       └─────────────────────────────┴─────────────────────────────┘
117

SEE ALSO

119       fdformat(1),  lstat(2),  readlink(2),  stat(2),  free(3C),  malloc(3C),
120       volmgt_check(3VOLMGT),   volmgt_inuse(3VOLMGT),   volmgt_root(3VOLMGT),
121       volmgt_running(3VOLMGT), volmgt_symname(3VOLMGT), attributes(5), hal(5)
122

NOTES

124       If media_findname() cannot find a match for the supplied name, it  per‐
125       forms  a volmgt_check(3VOLMGT) and tries again, so it can be more effi‐
126       cient to perform volmgt_check() before calling media_findname().
127
128
129       Upon success  media_findname() returns a pointer to  string  which  has
130       been  allocated;  this  should  be  freed  when  no  longer in use (see
131       free(3C)).
132
133
134
135SunOS 5.11                        2 Mar 2007           media_findname(3VOLMGT)
Impressum