/* * Minimal fake declarations of "kernel" data types */ struct superblock; struct inode { int i_nlink; int i_size; int i_ctime; int i_mtime; struct superblock *i_sb; }; struct dentry { struct inode *d_inode; }; #define d_inode(dentry) ((dentry)->d_inode) extern int current_time(struct inode *); extern void inc_nlink(struct inode *); extern void ihold(struct inode *); extern void dget(struct dentry *); extern void d_instantiate(struct dentry *, struct inode *); extern int shmem_reserve_inode(struct superblock *); #define BOGO_DIRENT_SIZE 20 /* * The actual function where I'd have expected a warning * about "ret might be used uninitialized" */ int shmem_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry) { struct inode *inode = d_inode(old_dentry); int ret; /* * No ordinary (disk based) filesystem counts links as inodes; * but each new link needs a new dentry, pinning lowmem, and * tmpfs dentries cannot be pruned until they are unlinked. * But if an O_TMPFILE file is linked into the tmpfs, the * first link must skip that, to get the accounting right. */ if (inode->i_nlink) { ret = shmem_reserve_inode(inode->i_sb); #ifndef HIDE_PROBLEM if (ret) return ret; #endif } dir->i_size += BOGO_DIRENT_SIZE; inode->i_ctime = dir->i_ctime = dir->i_mtime = current_time(inode); inc_nlink(inode); ihold(inode); /* New dentry reference */ dget(dentry); /* Extra pinning count for the created dentry */ d_instantiate(dentry, inode); return ret; }