diff options
author | J. Bruce Fields <bfields@redhat.com> | 2011-08-26 20:40:28 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2011-08-27 14:21:18 -0400 |
commit | 48483bf23a568f3ef4cc7ad2c8f1a082f10ad0e7 (patch) | |
tree | 7eafa1dd82e7aeccfded9aff023c972d78f4609f /fs/nfsd/nfs4recover.c | |
parent | 8e82fa8fdcd1271d45bf6a5195801c706e190d69 (diff) |
nfsd4: simplify recovery dir setting
Move around some of this code, simplify a bit.
Reviewed-by: Boaz Harrosh <bharrosh@panasas.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd/nfs4recover.c')
-rw-r--r-- | fs/nfsd/nfs4recover.c | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c index 29d77f60585b..c3466610e6cd 100644 --- a/fs/nfsd/nfs4recover.c +++ b/fs/nfsd/nfs4recover.c | |||
@@ -45,6 +45,7 @@ | |||
45 | 45 | ||
46 | /* Globals */ | 46 | /* Globals */ |
47 | static struct file *rec_file; | 47 | static struct file *rec_file; |
48 | static char user_recovery_dirname[PATH_MAX] = "/var/lib/nfs/v4recovery"; | ||
48 | 49 | ||
49 | static int | 50 | static int |
50 | nfs4_save_creds(const struct cred **original_creds) | 51 | nfs4_save_creds(const struct cred **original_creds) |
@@ -354,13 +355,13 @@ nfsd4_recdir_load(void) { | |||
354 | */ | 355 | */ |
355 | 356 | ||
356 | void | 357 | void |
357 | nfsd4_init_recdir(char *rec_dirname) | 358 | nfsd4_init_recdir() |
358 | { | 359 | { |
359 | const struct cred *original_cred; | 360 | const struct cred *original_cred; |
360 | int status; | 361 | int status; |
361 | 362 | ||
362 | printk("NFSD: Using %s as the NFSv4 state recovery directory\n", | 363 | printk("NFSD: Using %s as the NFSv4 state recovery directory\n", |
363 | rec_dirname); | 364 | user_recovery_dirname); |
364 | 365 | ||
365 | BUG_ON(rec_file); | 366 | BUG_ON(rec_file); |
366 | 367 | ||
@@ -372,10 +373,10 @@ nfsd4_init_recdir(char *rec_dirname) | |||
372 | return; | 373 | return; |
373 | } | 374 | } |
374 | 375 | ||
375 | rec_file = filp_open(rec_dirname, O_RDONLY | O_DIRECTORY, 0); | 376 | rec_file = filp_open(user_recovery_dirname, O_RDONLY | O_DIRECTORY, 0); |
376 | if (IS_ERR(rec_file)) { | 377 | if (IS_ERR(rec_file)) { |
377 | printk("NFSD: unable to find recovery directory %s\n", | 378 | printk("NFSD: unable to find recovery directory %s\n", |
378 | rec_dirname); | 379 | user_recovery_dirname); |
379 | rec_file = NULL; | 380 | rec_file = NULL; |
380 | } | 381 | } |
381 | 382 | ||
@@ -390,3 +391,30 @@ nfsd4_shutdown_recdir(void) | |||
390 | fput(rec_file); | 391 | fput(rec_file); |
391 | rec_file = NULL; | 392 | rec_file = NULL; |
392 | } | 393 | } |
394 | |||
395 | /* | ||
396 | * Change the NFSv4 recovery directory to recdir. | ||
397 | */ | ||
398 | int | ||
399 | nfs4_reset_recoverydir(char *recdir) | ||
400 | { | ||
401 | int status; | ||
402 | struct path path; | ||
403 | |||
404 | status = kern_path(recdir, LOOKUP_FOLLOW, &path); | ||
405 | if (status) | ||
406 | return status; | ||
407 | status = -ENOTDIR; | ||
408 | if (S_ISDIR(path.dentry->d_inode->i_mode)) { | ||
409 | strcpy(user_recovery_dirname, recdir); | ||
410 | status = 0; | ||
411 | } | ||
412 | path_put(&path); | ||
413 | return status; | ||
414 | } | ||
415 | |||
416 | char * | ||
417 | nfs4_recoverydir(void) | ||
418 | { | ||
419 | return user_recovery_dirname; | ||
420 | } | ||