|
|
1.1 root 1: #define _POSIX_SOURCE
2: #include <stddef.h>
3: #include <stdlib.h>
4: #include <unistd.h>
5: #include <stdio.h>
6: #include <string.h>
7: #include <errno.h>
8: #include <time.h>
9: #include "jukeface.h"
10: #include "jukebox.h"
11:
12: allocate(Jukebox *j, char *vol_id, char *buf)
13: {
14: int drive, sh;
15: char nbuf[512];
16:
17: if(j_rdshelves(j, buf)) /* read in shelf names */
18: return(-1);
19: if(j_shstatus(j, buf)) /* get the jukebox status */
20: return(-1);
21: sh = j_shelfof(j, vol_id);
22: if(sh >= 0){
23: sprintf(buf, "there is an existing '%s' on shelf %d", vol_id, sh);
24: return(-1);
25: }
26: sh = j_shelfof(j, UNALLOCATED);
27: if(sh < 0){
28: sprintf(buf, "no unallocated disks");
29: return(-1);
30: }
31: printf("using unallocated disk from shelf %d\n", sh);
32: drive = j->nluns-1;
33: if(j_sh_to_dr(sh, SIDEB, drive, buf) < 0)
34: return(-1);
35: sprintf(nbuf, "%sb", vol_id);
36: if(j_wvolid(drive, nbuf, buf))
37: return(-1);
38: j_wrshelf = 1;
39: j->names[sh] = strdup(vol_id);
40: j->shelves[sh] = 1;
41: if(j_dr_to_sh(drive, sh, SIDEB, buf) < 0)
42: return(-1);
43: if(j_sh_to_dr(sh, SIDEA, drive, buf) < 0)
44: return(-1);
45: sprintf(nbuf, "%sa", vol_id);
46: if(j_wvolid(drive, nbuf, buf))
47: return(-1);
48: if(j_dr_to_sh(drive, sh, SIDEA, buf) < 0)
49: return(-1);
50: return(0);
51: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.