Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 300364
b: refs/heads/master
c: 8529f61
h: refs/heads/master
v: v3
  • Loading branch information
Linus Torvalds committed May 7, 2012
1 parent da0c84a commit 71794f8
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a52dd971f947893bc7735396c74cfa591f0a7558
refs/heads/master: 8529f613b6945f4b5bd8c1b69e42aa1cc51b2eb6
21 changes: 21 additions & 0 deletions trunk/arch/x86/include/asm/stat.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ struct stat {
unsigned long __unused5;
};

/* We don't need to memset the whole thing just to initialize the padding */
#define INIT_STRUCT_STAT_PADDING(st) do { \
st.__unused4 = 0; \
st.__unused5 = 0; \
} while (0)

#define STAT64_HAS_BROKEN_ST_INO 1

/* This matches struct stat64 in glibc2.1, hence the absolutely
Expand Down Expand Up @@ -63,6 +69,12 @@ struct stat64 {
unsigned long long st_ino;
};

/* We don't need to memset the whole thing just to initialize the padding */
#define INIT_STRUCT_STAT64_PADDING(st) do { \
memset(&st.__pad0, 0, sizeof(st.__pad0)); \
memset(&st.__pad3, 0, sizeof(st.__pad3)); \
} while (0)

#else /* __i386__ */

struct stat {
Expand All @@ -87,6 +99,15 @@ struct stat {
unsigned long st_ctime_nsec;
long __unused[3];
};

/* We don't need to memset the whole thing just to initialize the padding */
#define INIT_STRUCT_STAT_PADDING(st) do { \
st.__pad0 = 0; \
st.__unused[0] = 0; \
st.__unused[1] = 0; \
st.__unused[2] = 0; \
} while (0)

#endif

/* for 32bit emulation and 32 bit kernels */
Expand Down
12 changes: 10 additions & 2 deletions trunk/fs/stat.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ SYSCALL_DEFINE2(fstat, unsigned int, fd, struct __old_kernel_stat __user *, stat
#define valid_dev(x) choose_32_64(old_valid_dev,new_valid_dev)(x)
#define encode_dev(x) choose_32_64(old_encode_dev,new_encode_dev)(x)

#ifndef INIT_STRUCT_STAT_PADDING
# define INIT_STRUCT_STAT_PADDING(st) memset(&st, 0, sizeof(st))
#endif

static int cp_new_stat(struct kstat *stat, struct stat __user *statbuf)
{
struct stat tmp;
Expand All @@ -210,7 +214,7 @@ static int cp_new_stat(struct kstat *stat, struct stat __user *statbuf)
return -EOVERFLOW;
#endif

memset(&tmp, 0, sizeof(tmp));
INIT_STRUCT_STAT_PADDING(tmp);
tmp.st_dev = encode_dev(stat->dev);
tmp.st_ino = stat->ino;
if (sizeof(tmp.st_ino) < sizeof(stat->ino) && tmp.st_ino != stat->ino)
Expand Down Expand Up @@ -323,11 +327,15 @@ SYSCALL_DEFINE3(readlink, const char __user *, path, char __user *, buf,
/* ---------- LFS-64 ----------- */
#ifdef __ARCH_WANT_STAT64

#ifndef INIT_STRUCT_STAT64_PADDING
# define INIT_STRUCT_STAT64_PADDING(st) memset(&st, 0, sizeof(st))
#endif

static long cp_new_stat64(struct kstat *stat, struct stat64 __user *statbuf)
{
struct stat64 tmp;

memset(&tmp, 0, sizeof(struct stat64));
INIT_STRUCT_STAT64_PADDING(tmp);
#ifdef CONFIG_MIPS
/* mips has weird padding, so we don't get 64 bits there */
if (!new_valid_dev(stat->dev) || !new_valid_dev(stat->rdev))
Expand Down

0 comments on commit 71794f8

Please sign in to comment.