| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-require-effective-target arm_hard_vfp_ok } */ |
| 3 |
/* { dg-options "-O2 -mapcs -march=armv7-a -mfloat-abi=hard -mfpu=vfpv3-d16 -std=c17" } */ |
| 4 |
|
| 5 |
int inode_permission (), try_break_deleg (); |
| 6 |
int mutex_lock (), mutex_unlock (); |
| 7 |
struct mutex |
| 8 |
{ |
| 9 |
}; |
| 10 |
struct dentry |
| 11 |
{ |
| 12 |
struct inode *d_inode; |
| 13 |
}; |
| 14 |
struct inode |
| 15 |
{ |
| 16 |
const struct inode_operations *i_op; |
| 17 |
struct super_block *i_sb; |
| 18 |
union |
| 19 |
{ |
| 20 |
const unsigned int i_nlink; |
| 21 |
}; |
| 22 |
unsigned long i_state; |
| 23 |
struct mutex i_mutex; |
| 24 |
}; |
| 25 |
struct super_block |
| 26 |
{ |
| 27 |
unsigned int s_max_links; |
| 28 |
}; |
| 29 |
struct inode_operations |
| 30 |
{ |
| 31 |
int (*link) (struct dentry *, struct inode *, struct dentry *); |
| 32 |
} __attribute__ ((__aligned__ ((1 << 6)))); |
| 33 |
static inline __attribute__ ((always_inline)) |
| 34 |
__attribute__ ((no_instrument_function)) |
| 35 |
int may_create (struct inode *dir, struct dentry *child) |
| 36 |
{ |
| 37 |
if (child->d_inode) |
| 38 |
return -17; |
| 39 |
return inode_permission (dir, 0x00000002 | 0x00000001); |
| 40 |
} |
| 41 |
|
| 42 |
int |
| 43 |
vfs_link (struct dentry *old_dentry, struct inode *dir, |
| 44 |
struct dentry *new_dentry, struct inode **delegated_inode) |
| 45 |
{ |
| 46 |
struct inode *inode = old_dentry->d_inode; |
| 47 |
unsigned max_links = dir->i_sb->s_max_links; |
| 48 |
int error; |
| 49 |
error = may_create (dir, new_dentry); |
| 50 |
if (error) |
| 51 |
return error; |
| 52 |
mutex_lock (&inode->i_mutex); |
| 53 |
if (inode->i_nlink == 0 && !(inode->i_state & (1 << 10))) |
| 54 |
error = -2; |
| 55 |
else if (max_links && inode->i_nlink >= max_links) |
| 56 |
error = -31; |
| 57 |
else |
| 58 |
{ |
| 59 |
error = try_break_deleg (inode, delegated_inode); |
| 60 |
error = dir->i_op->link (old_dentry, dir, new_dentry); |
| 61 |
} |
| 62 |
mutex_unlock (&inode->i_mutex); |
| 63 |
return error; |
| 64 |
} |