GOTO(out_req, rc);
}
- if (rc < 0) {
- if (rc == -ENODATA && (cmd == IOC_MDC_GETFILEINFO ||
- cmd == LL_IOC_MDC_GETINFO))
- GOTO(skip_lmm, rc = 0);
- else
- GOTO(out_req, rc);
- }
+ if (rc == -ENODATA && (cmd == IOC_MDC_GETFILEINFO ||
+ cmd == LL_IOC_MDC_GETINFO)) {
+ lmmsize = 0;
+ rc = 0;
+ }
+
+ if (rc < 0)
+ GOTO(out_req, rc);
if (cmd == IOC_MDC_GETFILESTRIPE ||
cmd == LL_IOC_LOV_GETSTRIPE ||
lmdp = (struct lov_user_mds_data __user *)arg;
lump = &lmdp->lmd_lmm;
}
- if (copy_to_user(lump, lmm, lmmsize)) {
+
+ if (lmmsize == 0) {
+ /* If the file has no striping then zero out *lump so
+ * that the caller isn't confused by garbage. */
+ if (clear_user(lump, sizeof(*lump)))
+ GOTO(out_req, rc = -EFAULT);
+ } else if (copy_to_user(lump, lmm, lmmsize)) {
if (copy_to_user(lump, lmm, sizeof(*lump)))
- GOTO(out_req, rc = -EFAULT);
- rc = -EOVERFLOW;
- }
- skip_lmm:
+ GOTO(out_req, rc = -EFAULT);
+ rc = -EOVERFLOW;
+ }
+
if (cmd == IOC_MDC_GETFILEINFO || cmd == LL_IOC_MDC_GETINFO) {
struct lov_user_mds_data __user *lmdp;
lstat_t st = { 0 };
}
run_test 184e "Recreate layout after stripeless layout swaps"
+test_184f() {
+ # Create a file with name longer than sizeof(struct stat) ==
+ # 144 to see if we can get chars from the file name to appear
+ # in the returned striping. Note that 'f' == 0x66.
+ local file=$(for ((i = 0; i < 200; i++)); do echo -n f; done)
+
+ mkdir -p $DIR/$tdir
+ mcreate $DIR/$tdir/$file
+ if lfs find --stripe-count 0x6666 $DIR/$tdir | grep $file; then
+ error "IOC_MDC_GETFILEINFO returned garbage striping"
+ fi
+}
+run_test 184f "IOC_MDC_GETFILEINFO for files with long names but no striping"
+
test_185() { # LU-2441
# LU-3553 - no volatile file support in old servers
[[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||