< prev index next >

src/java.base/unix/native/libjava/TimeZone_md.c

Print this page

        

*** 42,51 **** --- 42,57 ---- #include "jvm.h" #include "TimeZone_md.h" #define SKIP_SPACE(p) while (*p == ' ' || *p == '\t') p++; + #define RESTARTABLE(_cmd, _result) do { \ + do { \ + _result = _cmd; \ + } while((_result == -1) && (errno == EINTR)); \ + } while(0) + #if defined(_ALLBSD_SOURCE) #define dirent64 dirent #define readdir64_r readdir_r #endif
*** 119,128 **** --- 125,135 ---- struct dirent64 *entry = NULL; char *pathname = NULL; int fd = -1; char *dbuf = NULL; char *tz = NULL; + int res; dirp = opendir(dir); if (dirp == NULL) { return NULL; }
*** 159,169 **** pathname = getPathName(dir, dp->d_name); if (pathname == NULL) { break; } ! if (stat(pathname, &statbuf) == -1) { break; } if (S_ISDIR(statbuf.st_mode)) { tz = findZoneinfoFile(buf, size, pathname); --- 166,177 ---- pathname = getPathName(dir, dp->d_name); if (pathname == NULL) { break; } ! RESTARTABLE(stat(pathname, &statbuf), res); ! if (res == -1) { break; } if (S_ISDIR(statbuf.st_mode)) { tz = findZoneinfoFile(buf, size, pathname);
*** 173,186 **** } else if (S_ISREG(statbuf.st_mode) && (size_t)statbuf.st_size == size) { dbuf = (char *) malloc(size); if (dbuf == NULL) { break; } ! if ((fd = open(pathname, O_RDONLY)) == -1) { break; } ! if (read(fd, dbuf, size) != (ssize_t) size) { break; } if (memcmp(buf, dbuf, size) == 0) { tz = getZoneName(pathname); if (tz != NULL) { --- 181,196 ---- } else if (S_ISREG(statbuf.st_mode) && (size_t)statbuf.st_size == size) { dbuf = (char *) malloc(size); if (dbuf == NULL) { break; } ! RESTARTABLE(open(pathname, O_RDONLY), fd); ! if (fd == -1) { break; } ! RESTARTABLE(read(fd, dbuf, size), res); ! if (res != (ssize_t) size) { break; } if (memcmp(buf, dbuf, size) == 0) { tz = getZoneName(pathname); if (tz != NULL) {
*** 228,237 **** --- 238,248 ---- char *tz = NULL; FILE *fp; int fd; char *buf; size_t size; + int res; #if defined(__linux__) /* * Try reading the /etc/timezone file for Debian distros. There's * no spec of the file format available. This parsing assumes that
*** 258,268 **** #endif /* defined(__linux__) */ /* * Next, try /etc/localtime to find the zone ID. */ ! if (lstat(DEFAULT_ZONEINFO_FILE, &statbuf) == -1) { return NULL; } /* * If it's a symlink, get the link name and its zone ID part. (The --- 269,280 ---- #endif /* defined(__linux__) */ /* * Next, try /etc/localtime to find the zone ID. */ ! RESTARTABLE(lstat(DEFAULT_ZONEINFO_FILE, &statbuf), res); ! if (res == -1) { return NULL; } /* * If it's a symlink, get the link name and its zone ID part. (The
*** 292,316 **** * If it's a regular file, we need to find out the same zoneinfo file * that has been copied as /etc/localtime. * If initial symbolic link resolution failed, we should treat target * file as a regular file. */ ! if ((fd = open(DEFAULT_ZONEINFO_FILE, O_RDONLY)) == -1) { return NULL; } ! if (fstat(fd, &statbuf) == -1) { (void) close(fd); return NULL; } size = (size_t) statbuf.st_size; buf = (char *) malloc(size); if (buf == NULL) { (void) close(fd); return NULL; } ! if (read(fd, buf, size) != (ssize_t) size) { (void) close(fd); free((void *) buf); return NULL; } (void) close(fd); --- 304,332 ---- * If it's a regular file, we need to find out the same zoneinfo file * that has been copied as /etc/localtime. * If initial symbolic link resolution failed, we should treat target * file as a regular file. */ ! RESTARTABLE(open(DEFAULT_ZONEINFO_FILE, O_RDONLY), fd); ! if (fd == -1) { return NULL; } ! ! RESTARTABLE(fstat(fd, &statbuf), res); ! if (res == -1) { (void) close(fd); return NULL; } size = (size_t) statbuf.st_size; buf = (char *) malloc(size); if (buf == NULL) { (void) close(fd); return NULL; } ! RESTARTABLE(read(fd, buf, size), res); ! if (res != (ssize_t) size) { (void) close(fd); free((void *) buf); return NULL; } (void) close(fd);
*** 370,380 **** } /* * It assumes read open. */ ! if ((fd = open(fname, O_RDONLY)) == -1) { return NULL; } /* * Allocate struct iobuffer and its buffer --- 386,397 ---- } /* * It assumes read open. */ ! RESTARTABLE(open(fname, O_RDONLY), fd); ! if (fd == -1) { return NULL; } /* * Allocate struct iobuffer and its buffer
*** 418,428 **** char c; if (iop->ptr == iop->endptr) { ssize_t len; ! if ((len = read(iop->fd, (void *)iop->buffer, BUFFER_SIZE)) == -1) { return NULL; } if (len == 0) { *p = 0; if (s == p) { --- 435,446 ---- char c; if (iop->ptr == iop->endptr) { ssize_t len; ! RESTARTABLE(read(iop->fd, (void *)iop->buffer, BUFFER_SIZE), len); ! if (len == -1) { return NULL; } if (len == 0) { *p = 0; if (s == p) {
*** 556,565 **** --- 574,584 ---- char *tz = NULL; struct stat statbuf; size_t size; char *buf; int fd; + int res; /* scf specific variables */ scf_handle_t *h = NULL; scf_snapshot_t *snap = NULL; scf_instance_t *inst = NULL; scf_propertygroup_t *pg = NULL;
*** 591,614 **** } } } cleanupScf(h, snap, inst, pg, prop, val, tz); ! if (stat(DEFAULT_ZONEINFO_FILE, &statbuf) == -1) { return NULL; } size = (size_t) statbuf.st_size; buf = malloc(size); if (buf == NULL) { return NULL; } ! if ((fd = open(DEFAULT_ZONEINFO_FILE, O_RDONLY)) == -1) { free((void *) buf); return NULL; } ! if (read(fd, buf, size) != (ssize_t) size) { (void) close(fd); free((void *) buf); return NULL; } (void) close(fd); --- 610,636 ---- } } } cleanupScf(h, snap, inst, pg, prop, val, tz); ! RESTARTABLE(stat(DEFAULT_ZONEINFO_FILE, &statbuf), res); ! if (res == -1) { return NULL; } size = (size_t) statbuf.st_size; buf = malloc(size); if (buf == NULL) { return NULL; } ! RESTARTABLE(open(DEFAULT_ZONEINFO_FILE, O_RDONLY), fd); ! if (fd == -1) { free((void *) buf); return NULL; } ! RESTARTABLE(read(fd, buf, size), res); ! if (res != (ssize_t) size) { (void) close(fd); free((void *) buf); return NULL; } (void) close(fd);
< prev index next >