/** Define a pointer to an osl blob table with a canonical name. */
#define DEFINE_BLOB_TABLE_PTR(table_name) struct osl_table *table_name ## _table;
-
/** Define a blob table. */
#define INIT_BLOB_TABLE(table_name) \
DEFINE_BLOB_TABLE_DESC(table_name); \
para_printf(&aca->pbout, "cannot list %s\n", name);
return ret;
}
- id = *(uint32_t *)obj.data;
+ id = read_u32(obj.data);
para_printf(&aca->pbout, "%u\t%s\n", id, name);
return 1;
}
.action = print_blob,
};
int ret;
+
ret = lls_deserialize_parse_result(aca->query.data, cmd, &aca->lpr);
pmd.lpr = aca->lpr;
assert(ret >= 0);
.data = &aca->fd,
.action = cat_blob
};
+
ret = lls_deserialize_parse_result(aca->query.data, cmd, &aca->lpr);
assert(ret >= 0);
pmd.lpr = aca->lpr;
{
struct afs_callback_arg *aca = data;
int ret = osl(osl_del_row(table, row));
+
if (ret < 0) {
para_printf(&aca->pbout, "cannot remove %s\n", name);
return ret;
.data = aca,
.action = remove_blob
};
+
ret = lls_deserialize_parse_result(aca->query.data, cmd, &aca->lpr);
assert(ret >= 0);
pmd.lpr = aca->lpr;
struct osl_object objs[NUM_BLOB_COLUMNS];
char *name = aca->query.data;
size_t name_len = strlen(name) + 1;
- uint32_t id;
+ uint32_t id = (uint32_t)-1; /* STFU, gcc */
+ char id_buf[sizeof(id)];
unsigned num_rows;
int ret;
if (ret < 0)
goto out;
if (!num_rows) { /* this is the first entry ever added */
- /* insert dummy row containing the id */
- id = 2; /* this entry will be entry #1, so 2 is the next */
- objs[BLOBCOL_ID].data = &id;
- objs[BLOBCOL_ID].size = sizeof(id);
+ /*
+ * Insert dummy row containing the next free ID. Since we are
+ * about to insert the first blob with ID 1, the next free ID
+ * will be 2.
+ */
+ id = 2U;
+ write_u32(id_buf, id);
+ objs[BLOBCOL_ID].data = id_buf;
+ objs[BLOBCOL_ID].size = sizeof(id_buf);
objs[BLOBCOL_NAME].data = "";
objs[BLOBCOL_NAME].size = 1;
objs[BLOBCOL_DEF].data = "";
ret = osl(osl_get_object(table, row, BLOBCOL_ID, &obj));
if (ret < 0)
goto out;
- id = *(uint32_t *)obj.data;
+ id = read_u32(obj.data);
obj.data = name + name_len;
obj.size = aca->query.size - name_len;
ret = osl(osl_update_object(table, row, BLOBCOL_DEF, &obj));
ret = osl(osl_get_object(table, row, BLOBCOL_ID, &obj));
if (ret < 0)
goto out;
- id = *(uint32_t *)obj.data + 1;
- obj.data = &id;
+ id = read_u32(obj.data) + 1;
+ write_u32(id_buf, id);
+ obj.data = &id_buf;
ret = osl(osl_update_object(table, row, BLOBCOL_ID, &obj));
if (ret < 0)
goto out;
}
id--;
- objs[BLOBCOL_ID].data = &id;
- objs[BLOBCOL_ID].size = sizeof(id);
+ write_u32(id_buf, id);
+ objs[BLOBCOL_ID].data = &id_buf;
+ objs[BLOBCOL_ID].size = sizeof(id_buf);
objs[BLOBCOL_NAME].data = name;
objs[BLOBCOL_NAME].size = name_len;
objs[BLOBCOL_DEF].data = name + name_len;
*
* This function is called from the addblob command handlers to instruct the
* afs process to store the input in a blob table. Input is read and decrypted
- * from the file descriptor given by cc and appended to arg_obj, which contains
+ * from the file descriptor given by cc and appended to a buffer which also contains
* the name of the blob to create. The combined buffer is made available to the
* afs process via the callback method.
*/
return blob_get_name_by_id(table_name ## _table, id, name); \
}
-
static int blob_get_def_by_name(struct osl_table *table, char *name,
struct osl_object *def)
{
{
struct osl_object obj;
int ret = osl(osl_get_object(table, row, BLOBCOL_NAME, &obj));
+
if (ret < 0)
return ret;
*name = obj.data;
const char *dir)
{
int ret;
+
desc->dir = dir;
ret = osl(osl_open_table(desc, table));
if (ret >= 0)