diff options
Diffstat (limited to 'include/linux/sunrpc')
-rw-r--r-- | include/linux/sunrpc/cache.h | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/include/linux/sunrpc/cache.h b/include/linux/sunrpc/cache.h index 6ce690de447f..437ddb6c4aef 100644 --- a/include/linux/sunrpc/cache.h +++ b/include/linux/sunrpc/cache.h | |||
@@ -264,12 +264,30 @@ static inline int get_uint(char **bpp, unsigned int *anint) | |||
264 | return 0; | 264 | return 0; |
265 | } | 265 | } |
266 | 266 | ||
267 | static inline int get_time(char **bpp, time_t *time) | ||
268 | { | ||
269 | char buf[50]; | ||
270 | long long ll; | ||
271 | int len = qword_get(bpp, buf, sizeof(buf)); | ||
272 | |||
273 | if (len < 0) | ||
274 | return -EINVAL; | ||
275 | if (len == 0) | ||
276 | return -ENOENT; | ||
277 | |||
278 | if (kstrtoll(buf, 0, &ll)) | ||
279 | return -EINVAL; | ||
280 | |||
281 | *time = (time_t)ll; | ||
282 | return 0; | ||
283 | } | ||
284 | |||
267 | static inline time_t get_expiry(char **bpp) | 285 | static inline time_t get_expiry(char **bpp) |
268 | { | 286 | { |
269 | int rv; | 287 | time_t rv; |
270 | struct timespec boot; | 288 | struct timespec boot; |
271 | 289 | ||
272 | if (get_int(bpp, &rv)) | 290 | if (get_time(bpp, &rv)) |
273 | return 0; | 291 | return 0; |
274 | if (rv < 0) | 292 | if (rv < 0) |
275 | return 0; | 293 | return 0; |