2 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #include "err_protos.h"
29 #include <sys/resource.h>
31 static pthread_key_t dirbuf_key
;
32 static pthread_key_t dir_freemap_key
;
33 static pthread_key_t attr_freemap_key
;
36 ts_alloc(pthread_key_t key
, unsigned n
, size_t size
)
39 voidp
= malloc((n
)*(size
));
41 do_error(_("ts_alloc: cannot allocate thread specific storage\n"));
45 pthread_setspecific(key
, voidp
);
51 /* create thread specific keys */
52 pthread_key_create(&dirbuf_key
, NULL
);
53 pthread_key_create(&dir_freemap_key
, NULL
);
54 pthread_key_create(&attr_freemap_key
, NULL
);
61 /* allocate thread specific storage */
62 ts_alloc(dirbuf_key
, 1, ts_dirbuf_size
);
63 ts_alloc(dir_freemap_key
, 1, ts_dir_freemap_size
);
64 ts_alloc(attr_freemap_key
, 1, ts_attr_freemap_size
);
70 return pthread_getspecific(dirbuf_key
);
76 return pthread_getspecific(dir_freemap_key
);
82 return pthread_getspecific(attr_freemap_key
);
91 if (getrlimit(RLIMIT_FSIZE
, &rl
) == -1) {
93 fprintf(stderr
, _("getrlimit(RLIMIT_FSIZE) failed!\n"));
96 if (rl
.rlim_cur
!= RLIM_INFINITY
) {
97 rl
.rlim_max
= rl
.rlim_cur
= RLIM_INFINITY
;
98 if (setrlimit(RLIMIT_FSIZE
, &rl
) == -1) {
101 _("setrlimit failed - current: %lld, max: %lld\n"),
102 (unsigned long long)rl
.rlim_cur
,
103 (unsigned long long)rl
.rlim_max
);
110 xfs_init(libxfs_init_t
*args
)
112 memset(args
, 0, sizeof(libxfs_init_t
));
116 args
->dname
= fs_name
;
117 args
->volname
= NULL
;
120 args
->volname
= fs_name
;
124 if (log_spec
) { /* External log specified */
125 args
->logname
= log_name
;
126 args
->lisfile
= (isa_file
?1:0);
127 /* XXX assume data file also means log file */
128 /* REVISIT: Need to do fs sanity / log validity checking */
131 if (rt_spec
) { /* RT device specified */
132 args
->rtname
= rt_name
;
133 args
->risfile
= (isa_file
?1:0);
134 /* XXX assume data file also means rt file */
137 args
->usebuflock
= do_prefetch
;
138 args
->setblksize
= !dangerously
;
139 args
->isdirect
= LIBXFS_DIRECT
;
141 args
->isreadonly
= (LIBXFS_ISREADONLY
| LIBXFS_ISINACTIVE
);
142 else if (dangerously
)
143 args
->isreadonly
= (LIBXFS_ISINACTIVE
| LIBXFS_DANGEROUSLY
);
145 args
->isreadonly
= LIBXFS_EXCLUSIVELY
;
147 if (!libxfs_init(args
))
148 do_error(_("couldn't initialize XFS library\n"));