bool ntfs::updateBootSector(Report& report, const QString& deviceNode) const { report.line() << xi18nc("@info:progress", "Updating boot sector for NTFS file system on partition <filename>%1</filename>.", deviceNode); quint32 n = firstSector(); char* s = reinterpret_cast<char*>(&n); #if Q_BYTE_ORDER == Q_BIG_ENDIAN std::swap(s[0], s[3]); std::swap(s[1], s[2]); #endif QFile device(deviceNode); if (!device.open(QFile::ReadWrite | QFile::Unbuffered)) { Log() << xi18nc("@info:progress", "Could not open partition <filename>%1</filename> for writing when trying to update the NTFS boot sector.", deviceNode); return false; } if (!device.seek(0x1c)) { Log() << xi18nc("@info:progress", "Could not seek to position 0x1c on partition <filename>%1</filename> when trying to update the NTFS boot sector.", deviceNode); return false; } if (device.write(s, 4) != 4) { Log() << xi18nc("@info:progress", "Could not write new start sector to partition <filename>%1</filename> when trying to update the NTFS boot sector.", deviceNode); return false; } Log() << xi18nc("@info:progress", "Updated NTFS boot sector for partition <filename>%1</filename> successfully.", deviceNode); return true; }
static void compute_all_sequences_for_size(struct params *fd, int *offset, int tracksize, int sizecode, int gap, int mask, int tailsize) { int base = *offset; int i; /* no sectors of this size */ if(!nrSectorsForSize(fd, tailsize)) return; fd[*offset] = fd[0]; if(compute_chunks_per_sect(fd + *offset, tracksize, sizecode, &gap, /* gap. expressed in 1/256 bytes */ mask, tailsize) < 0) { /* not enough raw space for this arrangement */ return; } for(i = firstSector(fd, tailsize); i < lastSector(fd, tailsize); i++) { fd[*offset] = fd[base]; compute_sector_sequence(fd+*offset, i, gap); (*offset)++; } }
/** Checks if this CopySourceDevice overlaps with the given CopyTarget @param target the CopyTarget to check overlapping with @return true if overlaps */ bool CopySourceDevice::overlaps(const CopyTarget& target) const { try { const CopyTargetDevice& t = dynamic_cast<const CopyTargetDevice&>(target); if (device().deviceNode() != t.device().deviceNode()) return false; // overlapping at the front? if (firstSector() <= t.firstSector() && lastSector() >= t.firstSector()) return true; // overlapping at the back? if (firstSector() <= t.lastSector() && lastSector() >= t.lastSector()) return true; } catch (...) { } return false; }
/** Returns the length of this CopySource @return length of the copy source */ qint64 CopySourceDevice::length() const { return lastSector() - firstSector() + 1; }
static inline int nrSectorsForSize(struct params *fd, int i) { return lastSector(fd, i) - firstSector(fd, i); }
K3b::Msf K3b::Device::Toc::length() const { // +1 since the last sector is included return lastSector() - firstSector() + 1; }