Fix stat results to be consistent between smbc_stat and smbc_fstat.
[ira/wip.git] / source3 / libsmb / libsmbclient.c
index f266c16c97e3dc43b415c0104ad7f8a2a39253b5..077970647d993dc5c67a7a899e80e0065e0858ad 100644 (file)
@@ -2263,6 +2263,9 @@ smbc_setup_stat(SMBCCTX *context,
 #endif
 #ifdef HAVE_STAT_ST_BLOCKS
        st->st_blocks = (size+511)/512;
+#endif
+#ifdef HAVE_STRUCT_STAT_ST_RDEV
+       st->st_rdev = 0;
 #endif
        st->st_uid = getuid();
        st->st_gid = getgid();
@@ -2367,7 +2370,7 @@ smbc_stat_ctx(SMBCCTX *context,
 
        st->st_ino = ino;
 
-       smbc_setup_stat(context, st, path, size, mode);
+       smbc_setup_stat(context, st, (char *) fname, size, mode);
 
        set_atimespec(st, access_time_ts);
        set_ctimespec(st, change_time_ts);
@@ -6279,6 +6282,7 @@ smbc_listxattr_ctx(SMBCCTX *context,
          * the complete set of attribute names, always, rather than only those
          * attribute names which actually exist for a file.  Hmmm...
          */
+        size_t retsize;
         const char supported_old[] =
                 "system.*\0"
                 "system.*+\0"
@@ -6322,22 +6326,24 @@ smbc_listxattr_ctx(SMBCCTX *context,
 
         if (context->internal->_full_time_names) {
                 supported = supported_new;
+                retsize = sizeof(supported_new);
         } else {
                 supported = supported_old;
+                retsize = sizeof(supported_old);
         }
 
         if (size == 0) {
-                return sizeof(supported);
+                return retsize;
         }
 
-        if (sizeof(supported) > size) {
+        if (retsize > size) {
                 errno = ERANGE;
                 return -1;
         }
 
         /* this can't be strcpy() because there are embedded null characters */
-        memcpy(list, supported, sizeof(supported));
-        return sizeof(supported);
+        memcpy(list, supported, retsize);
+        return retsize;
 }