/*
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
- * Copyright (c) 2012 Whamcloud, Inc.
+ * Copyright (c) 2012, 2013, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
# include "config.h"
#endif /* HAVE_CONFIG_H */
+#include "mount_utils.h"
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <lustre_ver.h>
#include <sys/stat.h>
#include <sys/utsname.h>
-#include "mount_utils.h"
extern char *progname;
extern int verbose;
continue;
if (ret) {
fprintf(stderr, "%s: error %d on losetup: %s\n",
- progname, ret, strerror(ret));
+ progname, ret,
+ ret >= 0 ? strerror(ret) : "");
return ret;
}
strscpy(mop->mo_loopdev, l_device,
return size >> 10;
}
-int file_create(char *path, int size)
+int file_create(char *path, __u64 size)
{
+ __u64 size_max;
int ret;
int fd;
+ /*
+ * Since "size" is in KB, the file offset it represents could overflow
+ * off_t.
+ */
+ size_max = (off_t)1 << (_FILE_OFFSET_BITS - 1 - 10);
+ if (size >= size_max) {
+ fprintf(stderr, "%s: "LPU64" KB: Backing store size must be "
+ "smaller than "LPU64" KB\n", progname, size, size_max);
+ return EFBIG;
+ }
+
ret = access(path, F_OK);
if (ret == 0) {
ret = unlink(path);