MCPcopy Create free account
hub / github.com/apache/trafficserver / init

Method init

src/iocore/cache/Store.cc:362–499  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

360}
361
362const char *
363Span::init(const char *path, int64_t size)
364{
365 struct stat sbuf;
366 struct statvfs vbuf;
367 span_error_t serr;
368 ink_device_geometry geometry;
369
370 ats_scoped_fd fd(safe_open(path, O_RDONLY));
371 if (fd < 0) {
372 serr = make_span_error(errno);
373 Warning("unable to open '%s': %s", path, strerror(errno));
374 goto fail;
375 }
376
377 if (fstat(fd, &sbuf) == -1) {
378 serr = make_span_error(errno);
379 Warning("unable to stat '%s': %s (%d)", path, strerror(errno), errno);
380 goto fail;
381 }
382
383 if (fstatvfs(fd, &vbuf) == -1) {
384 serr = make_span_error(errno);
385 Warning("unable to statvfs '%s': %s (%d)", path, strerror(errno), errno);
386 goto fail;
387 }
388
389 // Directories require an explicit size parameter. For device nodes and files, we use
390 // the existing size.
391 if (S_ISDIR(sbuf.st_mode)) {
392 if (size <= 0) {
393 Warning("cache %s '%s' requires a size > 0", span_file_typename(sbuf.st_mode), path);
394 serr = SPAN_ERROR_MISSING_SIZE;
395 goto fail;
396 }
397 }
398
399 // Should regular files use the IO size (vbuf.f_bsize), or the
400 // fundamental filesystem block size (vbuf.f_frsize)? That depends
401 // on whether we are using that block size for performance or for
402 // reliability.
403
404 switch (sbuf.st_mode & S_IFMT) {
405 case S_IFBLK:
406 case S_IFCHR:
407
408#if defined(__linux__)
409 if (major(sbuf.st_rdev) == RAW_MAJOR && minor(sbuf.st_rdev) == 0) {
410 Warning("cache %s '%s' is the raw device control interface", span_file_typename(sbuf.st_mode), path);
411 serr = SPAN_ERROR_UNSUPPORTED_DEVTYPE;
412 goto fail;
413 }
414#endif
415
416 if (!ink_file_get_geometry(fd, geometry)) {
417 serr = make_span_error(errno);
418
419 if (errno == ENOTSUP) {

Callers 5

cacheInitializedMethod · 0.45
openMethod · 0.45
test_RamCacheFunction · 0.45
read_configMethod · 0.45
testRunStartingMethod · 0.45

Calls 6

sizeMethod · 0.95
safe_openFunction · 0.85
make_span_errorFunction · 0.85
span_file_typenameFunction · 0.85
ink_file_get_geometryFunction · 0.85
getMethod · 0.45

Tested by 1

test_RamCacheFunction · 0.36