Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs updates from Al Viro: "The big thing in this pile is Eric's unmount-on-rmdir series; we finally have everything we need for that. The final piece of prereqs is delayed mntput() - now filesystem shutdown always happens on shallow stack. Other than that, we have several new primitives for iov_iter (Matt Wilcox, culled from his XIP-related series) pushing the conversion to ->read_iter()/ ->write_iter() a bit more, a bunch of fs/dcache.c cleanups and fixes (including the external name refcounting, which gives consistent behaviour of d_move() wrt procfs symlinks for long and short names alike) and assorted cleanups and fixes all over the place. This is just the first pile; there's a lot of stuff from various people that ought to go in this window. Starting with unionmount/overlayfs mess... ;-/" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (60 commits) fs/file_table.c: Update alloc_file() comment vfs: Deduplicate code shared by xattr system calls operating on paths reiserfs: remove pointless forward declaration of struct nameidata don't need that forward declaration of struct nameidata in dcache.h anymore take dname_external() into fs/dcache.c let path_init() failures treated the same way as subsequent link_path_walk() fix misuses of f_count() in ppp and netlink ncpfs: use list_for_each_entry() for d_subdirs walk vfs: move getname() from callers to do_mount() gfs2_atomic_open(): skip lookups on hashed dentry [infiniband] remove pointless assignments gadgetfs: saner API for gadgetfs_create_file() f_fs: saner API for ffs_sb_create_file() jfs: don't hash direct inode [s390] remove pointless assignment of ->f_op in vmlogrdr ->open() ecryptfs: ->f_op is never NULL android: ->f_op is never NULL nouveau: __iomem misannotations missing annotation in fs/file.c fs: namespace: suppress 'may be used uninitialized' warnings ...
This commit is contained in:
@@ -9,78 +9,48 @@
|
||||
*/
|
||||
s64 perf_atoll(const char *str)
|
||||
{
|
||||
unsigned int i;
|
||||
s64 length = -1, unit = 1;
|
||||
s64 length;
|
||||
char *p;
|
||||
char c;
|
||||
|
||||
if (!isdigit(str[0]))
|
||||
goto out_err;
|
||||
|
||||
for (i = 1; i < strlen(str); i++) {
|
||||
switch (str[i]) {
|
||||
case 'B':
|
||||
case 'b':
|
||||
break;
|
||||
case 'K':
|
||||
if (str[i + 1] != 'B')
|
||||
length = strtoll(str, &p, 10);
|
||||
switch (c = *p++) {
|
||||
case 'b': case 'B':
|
||||
if (*p)
|
||||
goto out_err;
|
||||
else
|
||||
goto kilo;
|
||||
case 'k':
|
||||
if (str[i + 1] != 'b')
|
||||
goto out_err;
|
||||
kilo:
|
||||
unit = K;
|
||||
break;
|
||||
case 'M':
|
||||
if (str[i + 1] != 'B')
|
||||
goto out_err;
|
||||
else
|
||||
goto mega;
|
||||
case 'm':
|
||||
if (str[i + 1] != 'b')
|
||||
goto out_err;
|
||||
mega:
|
||||
unit = K * K;
|
||||
break;
|
||||
case 'G':
|
||||
if (str[i + 1] != 'B')
|
||||
goto out_err;
|
||||
else
|
||||
goto giga;
|
||||
case 'g':
|
||||
if (str[i + 1] != 'b')
|
||||
goto out_err;
|
||||
giga:
|
||||
unit = K * K * K;
|
||||
break;
|
||||
case 'T':
|
||||
if (str[i + 1] != 'B')
|
||||
goto out_err;
|
||||
else
|
||||
goto tera;
|
||||
case 't':
|
||||
if (str[i + 1] != 'b')
|
||||
goto out_err;
|
||||
tera:
|
||||
unit = K * K * K * K;
|
||||
break;
|
||||
case '\0': /* only specified figures */
|
||||
unit = 1;
|
||||
break;
|
||||
case '\0':
|
||||
return length;
|
||||
default:
|
||||
if (!isdigit(str[i]))
|
||||
goto out_err;
|
||||
goto out_err;
|
||||
/* two-letter suffices */
|
||||
case 'k': case 'K':
|
||||
length <<= 10;
|
||||
break;
|
||||
case 'm': case 'M':
|
||||
length <<= 20;
|
||||
break;
|
||||
case 'g': case 'G':
|
||||
length <<= 30;
|
||||
break;
|
||||
case 't': case 'T':
|
||||
length <<= 40;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
length = atoll(str) * unit;
|
||||
goto out;
|
||||
/* we want the cases to match */
|
||||
if (islower(c)) {
|
||||
if (strcmp(p, "b") != 0)
|
||||
goto out_err;
|
||||
} else {
|
||||
if (strcmp(p, "B") != 0)
|
||||
goto out_err;
|
||||
}
|
||||
return length;
|
||||
|
||||
out_err:
|
||||
length = -1;
|
||||
out:
|
||||
return length;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user