#define inter_module_get(n) cfs_symbol_get(n)
#define inter_module_put(n) cfs_symbol_put(n)
-static inline int request_module(char *name)
+static inline int request_module(const char *name, ...)
{
return (-EINVAL);
}
#define __init
#define __exit
-static inline int request_module(char *name)
+static inline int request_module(const char *name, ...)
{
return (-EINVAL);
}
extern struct module libcfs_global_module;
#define THIS_MODULE &libcfs_global_module
-#define request_module(x) (0)
+#define request_module(x, y) (0)
#define EXPORT_SYMBOL(s)
#define MODULE_AUTHOR(s)
#define MODULE_DESCRIPTION(s)
static void
print_trace_warning_symbol(void *data, char *msg, unsigned long symbol)
{
- printk(data);
+ printk("%s", (char *)data);
print_symbol(msg, symbol);
printk("\n");
}
#ifdef __KERNEL__
if (lnd == NULL) {
LNET_MUTEX_UP(&the_lnet.ln_lnd_mutex);
- rc = request_module(libcfs_lnd2modname(lnd_type));
+ rc = request_module("%s", libcfs_lnd2modname(lnd_type));
LNET_MUTEX_DOWN(&the_lnet.ln_lnd_mutex);
lnd = lnet_find_lnd_by_type(lnd_type);
void sfw_free_pages(srpc_server_rpc_t *rpc);
void sfw_add_bulk_page(srpc_bulk_t *bk, cfs_page_t *pg, int i);
int sfw_alloc_pages(srpc_server_rpc_t *rpc, int npages, int sink);
+int sfw_make_session (srpc_mksn_reqst_t *request, srpc_mksn_reply_t *reply);
srpc_client_rpc_t *
srpc_create_client_rpc(lnet_process_id_t peer, int service,
struct dbg_line *line = linev[i];
struct ptldebug_header *hdr = line->hdr;
char out[4097];
+ char *buf = out;
int bytes;
+ ssize_t bytes_written;
bytes = sprintf(out, "%08x:%08x:%u:%u.%06llu:%u:%u:%u:(%s:%u:%s()) %s",
hdr->ph_subsys, hdr->ph_mask, hdr->ph_cpu_id,
hdr->ph_sec, (unsigned long long)hdr->ph_usec,
hdr->ph_stack, hdr->ph_pid, hdr->ph_extern_pid,
line->file, hdr->ph_line_num, line->fn, line->text);
-
- write(fdout, out, bytes);
+ while (bytes > 0) {
+ bytes_written = write(fdout, buf, bytes);
+ if (bytes_written <= 0)
+ break;
+ bytes -= bytes_written;
+ buf += bytes_written;
+ }
free(line->hdr);
free(line);
}
return 1;
}
if (argc > 1) {
- fdout = open(argv[1], O_WRONLY|O_CREAT|O_TRUNC);
+ fdout = open(argv[1], O_WRONLY | O_CREAT | O_TRUNC,
+ S_IRUSR | S_IWUSR);
if (fdout < 0) {
fprintf(stderr, "fopen(%s) failed: %s\n", argv[1],
strerror(errno));
server_mode_flag = 1;
break;
default:
- fprintf(stderr, usage_string);
+ fprintf(stderr, "%s", usage_string);
return -1;
}
}
if (optind != argc || grp == NULL || ses == NULL) {
- fprintf(stderr, usage_string);
+ fprintf(stderr, "%s", usage_string);
return -1;
}
}
if (last == 0.0) {
- printf ("M %lu(%lu) E %lu S %lu/%llu R %lu/%llu F %lu/%llu D %lu/%llu\n",
+ printf ("M %lu(%lu) E %lu S %llu/%lu R %llu/%lu F %llu/%lu D %llu/%lu\n",
new_counter.msgs_alloc, new_counter.msgs_max,
new_counter.errors,
new_counter.send_length, new_counter.send_count,
* but it can't fix the situation that liblustre is mounted
* at "/".
*/
- chdir("/");
+ if (!chdir("/")) {}
#if 0
umount(lustre_path);
#endif
#include <fcntl.h>
#include <sys/queue.h>
#include <getopt.h>
+#include <sys/wait.h>
#include <sysio.h>
#include <mount.h>
sprintf(cmd, \
"%s %s \"echo %lu > /proc/sys/lustre/fail_loc\"", \
ssh_cmd, mds_server, drop_arr[drop_index].code); \
- if ((rc = system(cmd))) { \
+ if ((rc = system(cmd)) != 0) { \
+ rc = WEXITSTATUS(rc); \
printf("error excuting remote command: %d\n", rc); \
exit(rc); \
} \
if (drop_arr[drop_index].name) { \
sprintf(cmd, "%s %s \"echo 0 > /proc/sys/lustre/fail_loc\"", \
ssh_cmd, mds_server); \
- system(cmd); \
+ if (!system(cmd)) {} \
} \
} while (0)
}
if (statbuf.st_size != size) {
printf("size of %s: %lld != %lld\n", file,
- (long long)statbuf.st_size, size);
+ (long long)statbuf.st_size, (long long )size);
return(-1);
}
return 0;
int fd;
struct iovec iov[2];
char buf[100];
- ssize_t ret;
+ long ret;
ENTER("trap app's general bad pointer for file i/o");
snprintf(file, MAX_PATH_LENGTH, "%s/test_t20_file", lustre_path);
int fd;
char *str = "1234567890";
char buf[100];
- ssize_t ret;
+ long ret;
ENTER("make sure O_APPEND take effect");
snprintf(file, MAX_PATH_LENGTH, "%s/test_t22_file", lustre_path);
printf("st_atime=%s", ctime(&statbuf.st_atime));
atime = statbuf.st_atime;
for (i = 0; i < 3; i++) {
+ ssize_t num_read;
sleep(2);
- read(fd, buf, sizeof(buf));
+ /* should not ignore read(2)'s return value */
+ num_read = read(fd, buf, sizeof(buf));
+ if (num_read < 0 ) {
+ printf("read from %s: %s\n", file, strerror(errno));
+ return -1;
+ }
stat(file, &statbuf);
printf("st_atime=%s", ctime(&statbuf.st_atime));
diff = statbuf.st_atime - atime;
int fd;
size_t nbytes;
off_t basep = 0;
- ssize_t rc = 0;
+ long rc = 0;
cfs_dirent_t dir;
ENTER("getdirentries should fail if nbytes is too small");
snprintf(name, sizeof(name) - 1, "fsfilt_%s", type);
name[sizeof(name) - 1] = '\0';
- if (!(rc = request_module(name))) {
+ if (!(rc = request_module("%s", name))) {
fs_ops = fsfilt_search_type(type);
CDEBUG(D_INFO, "Loaded module '%s'\n", name);
if (!fs_ops)
struct lprocfs_static_vars lvars;
int rc;
- request_module("lquota");
+ request_module("%s", "lquota");
mds_quota_interface_ref = PORTAL_SYMBOL_GET(mds_quota_interface);
rc = lquota_init(mds_quota_interface_ref);
if (rc) {
struct blkcipher_desc desc;
unsigned int min;
int rc;
+ char alg[CRYPTO_MAX_ALG_NAME+1] = "aes";
ENTRY;
- tfm = ll_crypto_alloc_blkcipher("aes", 0, 0 );
+ /* passing "aes" in a variable instead of a constant string keeps gcc
+ * 4.3.2 happy */
+ tfm = ll_crypto_alloc_blkcipher(alg, 0, 0 );
if (tfm == NULL) {
CERROR("failed to load transform for aes\n");
RETURN(-EFAULT);
struct blkcipher_desc desc;
unsigned int min;
int rc;
+ char alg[CRYPTO_MAX_ALG_NAME+1] = "aes";
ENTRY;
- tfm = ll_crypto_alloc_blkcipher("aes", 0, 0 );
+ /* passing "aes" in a variable instead of a constant string keeps gcc
+ * 4.3.2 happy */
+ tfm = ll_crypto_alloc_blkcipher(alg, 0, 0 );
if (tfm == NULL) {
CERROR("failed to load transform for aes\n");
RETURN(-EFAULT);
#ifdef CONFIG_KMOD
if (!type) {
const char *modname = name;
- if (!request_module(modname)) {
+ if (!request_module("%s", modname)) {
CDEBUG(D_INFO, "Loaded module '%s'\n", modname);
type = class_search_type(name);
} else {
lprocfs_filter_init_vars(&lvars);
- request_module("lquota");
+ request_module("%s", "lquota");
OBD_ALLOC(obdfilter_created_scratchpad,
OBDFILTER_CREATED_SCRATCHPAD_ENTRIES *
sizeof(*obdfilter_created_scratchpad));
init_completion(&pc->pc_starting);
init_completion(&pc->pc_finishing);
spin_lock_init(&pc->pc_lock);
- snprintf(pc->pc_name, sizeof (pc->pc_name), "%s", name);
+ strncpy(pc->pc_name, name, sizeof(pc->pc_name) - 1);
pc->pc_set = ptlrpc_prep_set();
if (pc->pc_set == NULL)
GOTO(out, rc = -ENOMEM);
struct stat statbuf;
int fd = get_fd();
- ftruncate(fd, (off_t)0);
- ftruncate(fd, (off_t)100000);
+ /* should not ignore ftruncate(2)'s return value */
+ if (ftruncate(fd, (off_t)0) < 0) {
+ prterr("trunc_hack: ftruncate(0)");
+ exit(1);
+ }
+ if (ftruncate(fd, (off_t)100000) < 0) {
+ prterr("trunc_hack: ftruncate(100000)");
+ exit(1);
+ }
if (fstat(fd, &statbuf)) {
prterr("trunc_hack: fstat");
statbuf.st_size = -1;
prt("no extend on truncate! not posix!\n");
exit(130);
}
- ftruncate(fd, 0);
+ if (ftruncate(fd, 0) < 0) {
+ prterr("trunc_hack: ftruncate(0) (2nd call)");
+ exit(1);
+ }
}
static char *tf_buf = NULL;
perror(mmap_file);
return errno;
}
- ftruncate(fd, region);
+ if (ftruncate(fd, region) < 0) {
+ perror("ftruncate()");
+ rc = errno;
+ goto out_close;
+ }
ptr = mmap(NULL, region, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
if (ptr == MAP_FAILED) {
perror(mmap_file);
return errno;
}
- ftruncate(fd, page_size);
+ if (ftruncate(fd, page_size) < 0) {
+ perror("ftruncate()");
+ rc = errno;
+ goto out_close;
+ }
ptr = mmap(NULL, page_size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
if (ptr == MAP_FAILED) {
perror(mmap_file);
return errno;
}
- ftruncate(fd, region);
+ if (ftruncate(fd, region) < 0) {
+ perror("ftruncate()");
+ rc = errno;
+ goto out_close;
+ }
ptr = mmap(NULL, region, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
if (ptr == MAP_FAILED) {
perror(fileb);
return errno;
}
- ftruncate(fdr, region);
+ if (ftruncate(fdr, region) < 0) {
+ perror("ftruncate()");
+ rc = errno;
+ goto out_close;
+ }
fdw = open(filea, O_CREAT|O_RDWR, 0600);
if (fdw < 0) {
perror(filea);
rc = errno;
goto out_close;
}
- ftruncate(fdw, region);
+ if (ftruncate(fdw, region) < 0) {
+ perror("ftruncate()");
+ rc = errno;
+ goto out_close;
+ }
ptr = mmap(NULL, region, PROT_READ|PROT_WRITE, MAP_SHARED, fdr, 0);
if (ptr == MAP_FAILED) {
perror(mmap_file);
return errno;
}
- ftruncate(fd, region);
+ if (ftruncate(fd, region) < 0) {
+ perror("ftruncate()");
+ rc = errno;
+ goto out_close;
+ }
ptr = mmap(NULL, region, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
if (ptr == MAP_FAILED) {
perror(mmap_file);
return errno;
}
- ftruncate(fd, page_size);
+ if (ftruncate(fd, page_size) < 0) {
+ perror("ftruncate()");
+ rc = errno;
+ goto out;
+ }
fd2 = open(mmap_file2, O_RDWR, 0600);
if (fd2 < 0) {
}
}
- if (kdestroy)
- system("kdestroy > /dev/null");
+ if (kdestroy) {
+ int rc;
+ if ((rc = system("kdestroy > /dev/null")) != 0) {
+ rc = WEXITSTATUS(rc);
+ fprintf(stderr, "error destroying tickets: %d, continuing\n", rc);
+ }
+ }
if (optind >= argc) {
/* flush for all mounted lustre fs. */
struct changelog_private *cp;
struct changelog_show cs = {};
char mdtname[20];
- char pattern[100];
- char trigger[100];
+ char pattern[PATH_MAX];
+ char trigger[PATH_MAX];
int fd, rc, pid;
/* Find mdtname from path, fsname, mdtname, or mdtname_UUID */
if (!force && writeoption) {
printf("%s: permanently overwrite all data on %s (yes/no)? ",
progname, devname);
- scanf("%3s", yesno);
+ if (scanf("%3s", yesno) == EOF && ferror(stdin)) {
+ perror("reading from stdin");
+ return -1;
+ }
if (!(strcasecmp("yes", yesno) || strcasecmp("y", yesno))) {
printf("Not continuing due to '%s' response", yesno);
return 0;
lr_backup_log();
- fd = open(statuslog, O_WRONLY | O_CREAT | O_SYNC);
+ fd = open(statuslog, O_WRONLY | O_CREAT | O_SYNC,
+ S_IRUSR | S_IWUSR);
if (fd == -1) {
fprintf(stderr, "Error opening log file for writing (%s)\n",
statuslog);
fprintf(stderr, "%s: Warning: Can't resolve kernel "
"version, assuming 2.6\n", progname);
else {
- read(fd, release, 4);
+ if (read(fd, release, 4) < 0) {
+ fprintf(stderr, "reading from /proc/sys/kernel"
+ "/osrelease: %s\n", strerror(errno));
+ close(fd);
+ exit(-1);
+ }
close(fd);
}
if (strncmp(release, "2.4.", 4) == 0)
char *dev;
FILE *filep;
int ret = 0;
+ size_t num;
/* Mount this device temporarily in order to write these files */
if (!mkdtemp(mntpt)) {
progname, filepnm, strerror(errno));
goto out_umnt;
}
- fwrite(&mop->mo_ldd, sizeof(mop->mo_ldd), 1, filep);
+ num = fwrite(&mop->mo_ldd, sizeof(mop->mo_ldd), 1, filep);
+ if (num < 1 && ferror(filep)) {
+ fprintf(stderr, "%s: Unable to write to file (%s): %s\n",
+ progname, filepnm, strerror(errno));
+ goto out_umnt;
+ }
fclose(filep);
/* COMPAT_146 */
#ifdef TUNEFS
sprintf(filepnm, "%s/mountdata", tmpdir);
filep = fopen(filepnm, "r");
if (filep) {
+ size_t num_read;
vprint("Reading %s\n", MOUNT_DATA_FILE);
- fread(&mop->mo_ldd, sizeof(mop->mo_ldd), 1, filep);
+ num_read = fread(&mop->mo_ldd, sizeof(mop->mo_ldd), 1, filep);
+ if (num_read < 1 && ferror(filep)) {
+ fprintf(stderr, "%s: Unable to read from file (%s): %s\n",
+ progname, filepnm, strerror(errno));
+ goto out_close;
+ }
} else {
/* COMPAT_146 */
/* Try to read pre-1.6 config from last_rcvd */
if (fd == NULL)
return errno;
- fgets(buf, size, fd);
+ /* should not ignore fgets(3)'s return value */
+ if (!fgets(buf, size, fd)) {
+ fprintf(stderr, "reading from %s: %s", path, strerror(errno));
+ fclose(fd);
+ return 1;
+ }
fclose(fd);
return 0;
}
/* May as well try to clean up loop devs */
if (strncmp(usource, "/dev/loop", 9) == 0) {
char cmd[256];
+ int ret;
sprintf(cmd, "/sbin/losetup -d %s", usource);
- system(cmd);
+ if ((ret = system(cmd)) < 0)
+ rc = errno;
+ else if (ret > 0)
+ rc = WEXITSTATUS(ret);
}
} else if (!nomtab) {
sprintf(filepnm, "%s/mountdata", tmpdir);
filep = fopen(filepnm, "r");
if (filep) {
+ size_t num_read;
vprint("Reading %s\n", MOUNT_DATA_FILE);
- fread(mo_ldd, sizeof(*mo_ldd), 1, filep);
+ num_read = fread(mo_ldd, sizeof(*mo_ldd), 1, filep);
+ if (num_read < 1 && ferror(filep)) {
+ fprintf(stderr, "%s: Unable to read from file (%s): %s\n",
+ progname, filepnm, strerror(errno));
+ goto out_close;
+ }
} else {
verrprint("%s: Unable to read %d.%d config %s.\n",
progname, LUSTRE_MAJOR, LUSTRE_MINOR, filepnm);
goto fail;
got_one:
- fgets(buf, sizeof(buf), fp);
+ /* should not ignore fgets(3)'s return value */
+ if (!fgets(buf, sizeof(buf), fp)) {
+ fprintf(stderr, "reading from %s: %s", buf, strerror(errno));
+ fclose(fp);
+ return;
+ }
fclose(fp);
/* trim trailing newlines */