diff --git a/src/add-ons/kernel/file_systems/bfs/Volume.cpp b/src/add-ons/kernel/file_systems/bfs/Volume.cpp index 874511268d..3e674c499c 100644 --- a/src/add-ons/kernel/file_systems/bfs/Volume.cpp +++ b/src/add-ons/kernel/file_systems/bfs/Volume.cpp @@ -425,8 +425,12 @@ Volume::Mount(const char* deviceName, uint32 flags) if (!(fFlags & VOLUME_READ_ONLY)) { Attribute attr(fRootNode); - if (attr.Get("be:volume_id") == B_ENTRY_NOT_FOUND) - CreateVolumeID(); + if (attr.Get("be:volume_id") == B_ENTRY_NOT_FOUND) { + Transaction transaction(this, fRootNode->BlockNumber()); + fRootNode->WriteLockInTransaction(transaction); + CreateVolumeID(transaction); + transaction.Done(); + } } // all went fine @@ -509,7 +513,7 @@ Volume::CreateIndicesRoot(Transaction& transaction) status_t -Volume::CreateVolumeID() +Volume::CreateVolumeID(Transaction& transaction) { Attribute attr(fRootNode); status_t status; @@ -525,10 +529,7 @@ Volume::CreateVolumeID() uint64_t id; size_t length = sizeof(id); id = ((uint64_t)rand() << 32) | rand(); - Transaction transaction(this, fRootNode->BlockNumber()); - fRootNode->WriteLockInTransaction(transaction); attr.Write(transaction, cookie, 0, (uint8_t *)&id, &length, NULL); - transaction.Done(); } return status; } @@ -766,7 +767,7 @@ Volume::Initialize(int fd, const char* name, uint32 blockSize, return status; } - CreateVolumeID(); + CreateVolumeID(transaction); WriteSuperBlock(); transaction.Done(); diff --git a/src/add-ons/kernel/file_systems/bfs/Volume.h b/src/add-ons/kernel/file_systems/bfs/Volume.h index 500a00f682..1e9b8f9737 100644 --- a/src/add-ons/kernel/file_systems/bfs/Volume.h +++ b/src/add-ons/kernel/file_systems/bfs/Volume.h @@ -92,7 +92,7 @@ public: status_t CreateIndicesRoot(Transaction& transaction); - status_t CreateVolumeID(); + status_t CreateVolumeID(Transaction& transaction); InodeList& RemovedInodes() { return fRemovedInodes; } // This list is guarded by the transaction lock