Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 16555
b: refs/heads/master
c: bce74da
h: refs/heads/master
i:
  16553: 191e695
  16551: f1c3335
v: v3
  • Loading branch information
NeilBrown authored and Linus Torvalds committed Jan 6, 2006
1 parent c167ca2 commit dc0ddf3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1345b1d8adbdeceb1c871d9a4af5e2a700b341c6
refs/heads/master: bce74dac082787375e76d2b33726b94c9701fabc
29 changes: 24 additions & 5 deletions trunk/drivers/md/md.c
Original file line number Diff line number Diff line change
Expand Up @@ -1525,6 +1525,26 @@ static void md_update_sb(mddev_t * mddev)

}

/* words written to sysfs files may, or my not, be \n terminated.
* We want to accept with case. For this we use cmd_match.
*/
static int cmd_match(const char *cmd, const char *str)
{
/* See if cmd, written into a sysfs file, matches
* str. They must either be the same, or cmd can
* have a trailing newline
*/
while (*cmd && *str && *cmd == *str) {
cmd++;
str++;
}
if (*cmd == '\n')
cmd++;
if (*str || *cmd)
return 0;
return 1;
}

struct rdev_sysfs_entry {
struct attribute attr;
ssize_t (*show)(mdk_rdev_t *, char *);
Expand Down Expand Up @@ -1799,7 +1819,7 @@ action_store(mddev_t *mddev, const char *page, size_t len)
if (!mddev->pers || !mddev->pers->sync_request)
return -EINVAL;

if (strcmp(page, "idle")==0 || strcmp(page, "idle\n")==0) {
if (cmd_match(page, "idle")) {
if (mddev->sync_thread) {
set_bit(MD_RECOVERY_INTR, &mddev->recovery);
md_unregister_thread(mddev->sync_thread);
Expand All @@ -1812,13 +1832,12 @@ action_store(mddev_t *mddev, const char *page, size_t len)
if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery) ||
test_bit(MD_RECOVERY_NEEDED, &mddev->recovery))
return -EBUSY;
if (strcmp(page, "resync")==0 || strcmp(page, "resync\n")==0 ||
strcmp(page, "recover")==0 || strcmp(page, "recover\n")==0)
if (cmd_match(page, "resync") || cmd_match(page, "recover"))
set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
else {
if (strcmp(page, "check")==0 || strcmp(page, "check\n")==0)
if (cmd_match(page, "check"))
set_bit(MD_RECOVERY_CHECK, &mddev->recovery);
else if (strcmp(page, "repair")!=0 && strcmp(page, "repair\n")!=0)
else if (cmd_match(page, "repair"))
return -EINVAL;
set_bit(MD_RECOVERY_REQUESTED, &mddev->recovery);
set_bit(MD_RECOVERY_SYNC, &mddev->recovery);
Expand Down

0 comments on commit dc0ddf3

Please sign in to comment.