Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 320314
b: refs/heads/master
c: ea3352f
h: refs/heads/master
v: v3
  • Loading branch information
Alex Elder authored and Sage Weil committed Jul 30, 2012
1 parent 21f09ee commit f43fec9
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f8c36c58accd5c53a472b5c289910565b3df9f9d
refs/heads/master: ea3352f4aa4fc32397d9a535780315e0f2bfee15
36 changes: 36 additions & 0 deletions trunk/drivers/block/rbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2280,6 +2280,42 @@ static inline size_t copy_token(const char **buf,
return len;
}

/*
* Finds the next token in *buf, dynamically allocates a buffer big
* enough to hold a copy of it, and copies the token into the new
* buffer. The copy is guaranteed to be terminated with '\0'. Note
* that a duplicate buffer is created even for a zero-length token.
*
* Returns a pointer to the newly-allocated duplicate, or a null
* pointer if memory for the duplicate was not available. If
* the lenp argument is a non-null pointer, the length of the token
* (not including the '\0') is returned in *lenp.
*
* If successful, the *buf pointer will be updated to point beyond
* the end of the found token.
*
* Note: uses GFP_KERNEL for allocation.
*/
static inline char *dup_token(const char **buf, size_t *lenp)
{
char *dup;
size_t len;

len = next_token(buf);
dup = kmalloc(len + 1, GFP_KERNEL);
if (!dup)
return NULL;

memcpy(dup, *buf, len);
*(dup + len) = '\0';
*buf += len;

if (lenp)
*lenp = len;

return dup;
}

/*
* This fills in the pool_name, obj, obj_len, snap_name, obj_len,
* rbd_dev, rbd_md_name, and name fields of the given rbd_dev, based
Expand Down

0 comments on commit f43fec9

Please sign in to comment.