1 /***********************************************************************
3 * This software is part of the ast package *
4 * Copyright (c) 1985-2010 AT&T Intellectual Property *
5 * and is licensed under the *
6 * Common Public License, Version 1.0 *
7 * by AT&T Intellectual Property *
9 * A copy of the License is available at *
10 * http://www.opensource.org/licenses/cpl1.0.txt *
11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
13 * Information and Software Systems Research *
17 * Glenn Fowler <gsf@research.att.com> *
18 * David Korn <dgk@research.att.com> *
19 * Phong Vo <kpv@research.att.com> *
21 ***********************************************************************/
24 * local device pathname for portable tape unit specification is returned
25 * if e is non-null then it is set to the next unused char in s
27 * <unit><density>[<no-rewind>]
34 strtape(register const char* s
, register char** e
)
41 static char tapefile
[sizeof("/dev/Xrmt/123456789")];
43 mtrewind
[0] = mtrewind
[1] = mtbehavior
[0] = mtbehavior
[1] = 0;
76 if (!access("/dev/rmt/.", F_OK
))
82 if (!mtdensity
) mtdensity
= 'm';
83 sfsprintf(tapefile
, sizeof(tapefile
), "/dev/rmt/ctape%c%s", mtunit
, mtrewind
);
84 if (!access(tapefile
, F_OK
)) return(tapefile
);
87 sfsprintf(tapefile
, sizeof(tapefile
), "/dev/rmt/%c%c%s%s", mtunit
, mtdensity
, mtbehavior
, mtrewind
);
88 if (!access(tapefile
, F_OK
)) return(tapefile
);
89 if (!mtbehavior
[0]) break;
93 else if (!access("/dev/nst0", F_OK
))
99 sfsprintf(tapefile
, sizeof(tapefile
), "/dev/%sst%c", mtrewind
, mtunit
);
101 else if (!access("/dev/nrmt0", F_OK
))
119 sfsprintf(tapefile
, sizeof(tapefile
), "/dev/%srmt%c", mtrewind
, mtunit
);
145 sfsprintf(tapefile
, sizeof(tapefile
), "/dev/rmt%d", mtunit
);