"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "stress-link.c" between
stress-ng-0.13.04.tar.xz and stress-ng-0.13.05.tar.xz

About: stress-ng will stress test a computer system in various selectable ways. It was designed to exercise various physical subsystems of a computer as well as the various operating system kernel interfaces.

stress-link.c  (stress-ng-0.13.04.tar.xz):stress-link.c  (stress-ng-0.13.05.tar.xz)
skipping to change at line 61 skipping to change at line 61
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
char path[PATH_MAX]; char path[PATH_MAX];
(void)stress_temp_filename_args(args, (void)stress_temp_filename_args(args,
path, sizeof(path), i); path, sizeof(path), i);
(void)unlink(path); (void)unlink(path);
} }
(void)sync(); (void)sync();
} }
static inline int random_mount(const int mounts_max) static inline size_t random_mount(const int mounts_max)
{ {
return (int)stress_mwc32() % mounts_max; return (size_t)stress_mwc32() % mounts_max;
} }
/* /*
* stress_link_generic * stress_link_generic
* stress links, generic case * stress links, generic case
*/ */
static int stress_link_generic( static int stress_link_generic(
const stress_args_t *args, const stress_args_t *args,
int (*linkfunc)(const char *oldpath, const char *newpath), int (*linkfunc)(const char *oldpath, const char *newpath),
const char *funcname) const char *funcname)
{ {
int rc, ret, fd, mounts_max; int rc, ret, fd, mounts_max;
char oldpath[PATH_MAX], tmp_newpath[PATH_MAX]; char oldpath[PATH_MAX], tmp_newpath[PATH_MAX];
size_t oldpathlen; size_t oldpathlen;
bool symlink_func = (linkfunc == symlink); bool symlink_func = (linkfunc == symlink);
char *mnts[MOUNTS_MAX]; char *mnts[MOUNTS_MAX];
memset(tmp_newpath, 0, sizeof(tmp_newpath));
(void)snprintf(tmp_newpath, sizeof(tmp_newpath), (void)snprintf(tmp_newpath, sizeof(tmp_newpath),
"/tmp/stress-ng-%s-%d-%" PRIu64 "-link", "/tmp/stress-ng-%s-%d-%" PRIu64 "-link",
args->name, (int)getpid(), stress_mwc64()); args->name, (int)getpid(), stress_mwc64());
ret = stress_temp_dir_mk_args(args); ret = stress_temp_dir_mk_args(args);
if (ret < 0) if (ret < 0)
return exit_status(-ret); return exit_status(-ret);
(void)stress_temp_filename_args(args, oldpath, sizeof(oldpath), ~0UL); (void)stress_temp_filename_args(args, oldpath, sizeof(oldpath), ~0UL);
if ((fd = open(oldpath, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR)) < 0) { if ((fd = open(oldpath, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR)) < 0) {
if ((errno == ENFILE) || (errno == ENOMEM) || (errno == ENOSPC)) if ((errno == ENFILE) || (errno == ENOMEM) || (errno == ENOSPC))
skipping to change at line 187 skipping to change at line 189
args->name, (size_t)rret, oldpathlen); args->name, (size_t)rret, oldpathlen);
else else
if (strncmp(oldpath, buf, (size_t )rret)) if (strncmp(oldpath, buf, (size_t )rret))
pr_fail("%s: readlink pat h error, got %s, expected %s\n", pr_fail("%s: readlink pat h error, got %s, expected %s\n",
args->name, buf, oldpath); args->name, buf, oldpath);
} }
} else { } else {
/* Hard link, exercise illegal cross device link, EXDEV error */ /* Hard link, exercise illegal cross device link, EXDEV error */
if (mounts_max > 0) { if (mounts_max > 0) {
/* Try hard link on differet random mount point */ /* Try hard link on differet random mount point */
ret = linkfunc(mnts[random_mount(mounts_m ax)], tmp_newpath); ret = linkfunc(mnts[random_mount((size_t) mounts_max)], tmp_newpath);
if (ret == 0) if (ret == 0)
(void)unlink(tmp_newpath); (void)unlink(tmp_newpath);
} }
} }
if (lstat(newpath, &stbuf) < 0) { if (lstat(newpath, &stbuf) < 0) {
rc = exit_status(errno); rc = exit_status(errno);
pr_fail("%s: lstat failed, errno=%d (%s)\n", pr_fail("%s: lstat failed, errno=%d (%s)\n",
args->name, errno, strerror(errno)); args->name, errno, strerror(errno));
} }
} }
 End of changes. 4 change blocks. 
3 lines changed or deleted 5 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)