diff options
Diffstat (limited to 'lib')
134 files changed, 972 insertions, 972 deletions
diff --git a/lib/blkid/blkid.h b/lib/blkid/blkid.h index f38a2350..81f3098c 100644 --- a/lib/blkid/blkid.h +++ b/lib/blkid/blkid.h @@ -90,7 +90,7 @@ extern blkid_tag_iterate blkid_tag_iterate_begin(blkid_dev dev); extern int blkid_tag_next(blkid_tag_iterate iterate, const char **type, const char **value); extern void blkid_tag_iterate_end(blkid_tag_iterate iterate); -extern int blkid_dev_has_tag(blkid_dev dev, const char *type, +extern int blkid_dev_has_tag(blkid_dev dev, const char *type, const char *value); extern blkid_dev blkid_find_dev_with_tag(blkid_cache cache, const char *type, diff --git a/lib/blkid/cache.c b/lib/blkid/cache.c index efd4656e..7c95726d 100644 --- a/lib/blkid/cache.c +++ b/lib/blkid/cache.c @@ -100,14 +100,14 @@ int blkid_get_cache(blkid_cache *ret_cache, const char *filename) if (filename && !strlen(filename)) filename = 0; - if (!filename) + if (!filename) filename = safe_getenv("BLKID_FILE"); if (!filename) filename = BLKID_CACHE_FILE; cache->bic_filename = blkid_strdup(filename); - + blkid_read_cache(cache); - + *ret_cache = cache; return 0; } @@ -120,7 +120,7 @@ void blkid_put_cache(blkid_cache cache) (void) blkid_flush_cache(cache); DBG(DEBUG_CACHE, printf("freeing cache struct\n")); - + /* DBG(DEBUG_CACHE, blkid_debug_dump_cache(cache)); */ while (!list_empty(&cache->bic_devs)) { @@ -137,7 +137,7 @@ void blkid_put_cache(blkid_cache cache) while (!list_empty(&tag->bit_names)) { blkid_tag bad = list_entry(tag->bit_names.next, - struct blkid_struct_tag, + struct blkid_struct_tag, bit_names); DBG(DEBUG_CACHE, printf("warning: unfreed tag %s=%s\n", @@ -148,7 +148,7 @@ void blkid_put_cache(blkid_cache cache) } if (cache->bic_filename) free(cache->bic_filename); - + free(cache); } @@ -165,12 +165,12 @@ void blkid_gc_cache(blkid_cache cache) if (!p) break; if (stat(dev->bid_name, &st) < 0) { - DBG(DEBUG_CACHE, + DBG(DEBUG_CACHE, printf("freeing %s\n", dev->bid_name)); blkid_free_dev(dev); cache->bic_flags |= BLKID_BIC_FL_CHANGED; } else { - DBG(DEBUG_CACHE, + DBG(DEBUG_CACHE, printf("Device %s exists\n", dev->bid_name)); } } diff --git a/lib/blkid/dev.c b/lib/blkid/dev.c index 5252a8eb..fb8d8527 100644 --- a/lib/blkid/dev.c +++ b/lib/blkid/dev.c @@ -77,7 +77,7 @@ void blkid_debug_dump_dev(blkid_dev dev) list_for_each(p, &dev->bid_tags) { blkid_tag tag = list_entry(p, struct blkid_struct_tag, bit_tags); if (tag) - printf(" tag: %s=\"%s\"\n", tag->bit_name, + printf(" tag: %s=\"%s\"\n", tag->bit_name, tag->bit_val); else printf(" tag: NULL\n"); @@ -102,7 +102,7 @@ void blkid_debug_dump_dev(blkid_dev dev) * This series of functions iterate over all devices in a blkid cache */ #define DEV_ITERATE_MAGIC 0x01a5284c - + struct blkid_struct_dev_iterate { int magic; blkid_cache cache; @@ -131,7 +131,7 @@ extern int blkid_dev_set_search(blkid_dev_iterate iter, { char *new_type, *new_value; - if (!iter || iter->magic != DEV_ITERATE_MAGIC || !search_type || + if (!iter || iter->magic != DEV_ITERATE_MAGIC || !search_type || !search_value) return -1; new_type = malloc(strlen(search_type)+1); @@ -168,8 +168,8 @@ extern int blkid_dev_next(blkid_dev_iterate iter, while (iter->p != &iter->cache->bic_devs) { dev = list_entry(iter->p, struct blkid_struct_dev, bid_devs); iter->p = iter->p->next; - if (iter->search_type && - !blkid_dev_has_tag(dev, iter->search_type, + if (iter->search_type && + !blkid_dev_has_tag(dev, iter->search_type, iter->search_value)) continue; *ret_dev = dev; @@ -220,7 +220,7 @@ int main(int argc, char **argv) case 'm': blkid_debug_mask = strtoul (optarg, &tmp, 0); if (*tmp) { - fprintf(stderr, "Invalid debug mask: %s\n", + fprintf(stderr, "Invalid debug mask: %s\n", optarg); exit(1); } diff --git a/lib/blkid/devname.c b/lib/blkid/devname.c index 2b3855b2..f0e127cf 100644 --- a/lib/blkid/devname.c +++ b/lib/blkid/devname.c @@ -58,7 +58,7 @@ blkid_dev blkid_get_dev(blkid_cache cache, const char *devname, int flags) if (strcmp(tmp->bid_name, devname)) continue; - DBG(DEBUG_DEVNAME, + DBG(DEBUG_DEVNAME, printf("found devname %s in cache\n", tmp->bid_name)); dev = tmp; break; @@ -79,7 +79,7 @@ blkid_dev blkid_get_dev(blkid_cache cache, const char *devname, int flags) dev = blkid_verify(cache, dev); if (!dev || !(dev->bid_flags & BLKID_BID_FL_VERIFIED)) return dev; - /* + /* * If the device is verified, then search the blkid * cache for any entries that match on the type, uuid, * and label, and verify them; if a cache entry can @@ -192,7 +192,7 @@ static void probe_one(blkid_cache cache, const char *ptname, dev->bid_devno == devno) goto set_pri; - if (stat(device, &st) == 0 && S_ISBLK(st.st_mode) && + if (stat(device, &st) == 0 && S_ISBLK(st.st_mode) && st.st_rdev == devno) { devname = blkid_strdup(device); break; @@ -309,7 +309,7 @@ static void lvm_probe_all(blkid_cache cache, int only_if_new) DBG(DEBUG_DEVNAME, printf("LVM dev %s: devno 0x%04X\n", lvm_device, (unsigned int) dev)); - probe_one(cache, lvm_device, dev, BLKID_PRI_LVM, + probe_one(cache, lvm_device, dev, BLKID_PRI_LVM, only_if_new); free(lvm_device); } @@ -417,7 +417,7 @@ static int probe_all(blkid_cache cache, int only_if_new) ptname, (unsigned int) devs[which])); if (sz > 1) - probe_one(cache, ptname, devs[which], 0, + probe_one(cache, ptname, devs[which], 0, only_if_new); lens[which] = 0; /* mark as checked */ } diff --git a/lib/blkid/devno.c b/lib/blkid/devno.c index e9c174f4..0a16d9be 100644 --- a/lib/blkid/devno.c +++ b/lib/blkid/devno.c @@ -122,7 +122,7 @@ void blkid__scan_dir(char *dirname, dev_t devno, struct dir_list **list, path, *devname)); break; } - if (list && S_ISDIR(st.st_mode) && !lstat(path, &st) && + if (list && S_ISDIR(st.st_mode) && !lstat(path, &st) && S_ISDIR(st.st_mode)) add_to_dirlist(path, list); } @@ -175,13 +175,13 @@ char *blkid_devno_to_devname(dev_t devno) if (!devname) { DBG(DEBUG_DEVNO, - printf("blkid: couldn't find devno 0x%04lx\n", + printf("blkid: couldn't find devno 0x%04lx\n", (unsigned long) devno)); } else { DBG(DEBUG_DEVNO, printf("found devno 0x%04llx as %s\n", (long long)devno, devname)); } - + return devname; } diff --git a/lib/blkid/getsize.c b/lib/blkid/getsize.c index 876d682c..10ba7ecf 100644 --- a/lib/blkid/getsize.c +++ b/lib/blkid/getsize.c @@ -199,7 +199,7 @@ int main(int argc, char **argv) perror(argv[0]); bytes = blkid_get_dev_size(fd); - printf("Device %s has %Ld 1k blocks.\n", argv[1], + printf("Device %s has %Ld 1k blocks.\n", argv[1], (unsigned long long) bytes >> 10); return 0; diff --git a/lib/blkid/probe.c b/lib/blkid/probe.c index 04eb29a7..10ac8036 100644 --- a/lib/blkid/probe.c +++ b/lib/blkid/probe.c @@ -47,7 +47,7 @@ static int figure_label_len(const unsigned char *label, int len) return 0; } -static unsigned char *get_buffer(struct blkid_probe *pr, +static unsigned char *get_buffer(struct blkid_probe *pr, blkid_loff_t off, size_t len) { ssize_t ret_read; @@ -96,7 +96,7 @@ static int check_mdraid(int fd, unsigned char *ret_uuid) struct mdp_superblock_s *md; blkid_loff_t offset; char buf[4096]; - + if (fd < 0) return -BLKID_ERR_PARAM; @@ -139,7 +139,7 @@ static void get_ext2_info(blkid_dev dev, struct blkid_magic *id, struct ext2_super_block *es = (struct ext2_super_block *) buf; const char *label = 0; - DBG(DEBUG_PROBE, printf("ext2_sb.compat = %08X:%08X:%08X\n", + DBG(DEBUG_PROBE, printf("ext2_sb.compat = %08X:%08X:%08X\n", blkid_le32(es->s_feature_compat), blkid_le32(es->s_feature_incompat), blkid_le32(es->s_feature_ro_compat))); @@ -307,7 +307,7 @@ static int probe_ext4(struct blkid_probe *probe, struct blkid_magic *id, es = (struct ext2_super_block *)buf; /* Distinguish from jbd */ - if (blkid_le32(es->s_feature_incompat) & + if (blkid_le32(es->s_feature_incompat) & EXT3_FEATURE_INCOMPAT_JOURNAL_DEV) return -BLKID_ERR_PARAM; @@ -419,13 +419,13 @@ static unsigned char *search_fat_label(struct vfat_dir_entry *dir, int count) for (i = 0; i < count; i++) { if (dir[i].name[0] == 0x00) break; - + if ((dir[i].name[0] == FAT_ENTRY_FREE) || (dir[i].cluster_high != 0 || dir[i].cluster_low != 0) || ((dir[i].attr & FAT_ATTR_MASK) == FAT_ATTR_LONG_NAME)) continue; - if ((dir[i].attr & (FAT_ATTR_VOLUME_ID | FAT_ATTR_DIR)) == + if ((dir[i].attr & (FAT_ATTR_VOLUME_ID | FAT_ATTR_DIR)) == FAT_ATTR_VOLUME_ID) { return dir[i].name; } @@ -436,7 +436,7 @@ static unsigned char *search_fat_label(struct vfat_dir_entry *dir, int count) /* FAT label extraction from the root directory taken from Kay * Sievers's volume_id library */ static int probe_fat(struct blkid_probe *probe, - struct blkid_magic *id __BLKID_ATTR((unused)), + struct blkid_magic *id __BLKID_ATTR((unused)), unsigned char *buf) { struct vfat_super_block *vs = (struct vfat_super_block *) buf; @@ -484,11 +484,11 @@ static int probe_fat(struct blkid_probe *probe, if (ms->ms_fat_length) { /* the label may be an attribute in the root directory */ root_start = (reserved + fat_size) * sector_size; - root_dir_entries = vs->vs_dir_entries[0] + + root_dir_entries = vs->vs_dir_entries[0] + (vs->vs_dir_entries[1] << 8); buf_size = root_dir_entries * sizeof(struct vfat_dir_entry); - dir = (struct vfat_dir_entry *) get_buffer(probe, root_start, + dir = (struct vfat_dir_entry *) get_buffer(probe, root_start, buf_size); if (dir) vol_label = search_fat_label(dir, root_dir_entries); @@ -497,7 +497,7 @@ static int probe_fat(struct blkid_probe *probe, vol_label = ms->ms_label; vol_serno = ms->ms_serno; - blkid_set_tag(probe->dev, "SEC_TYPE", "msdos", + blkid_set_tag(probe->dev, "SEC_TYPE", "msdos", sizeof("msdos")); } else { /* Search the FAT32 root dir for the label attribute */ @@ -511,10 +511,10 @@ static int probe_fat(struct blkid_probe *probe, int count; next_sect_off = (next - 2) * vs->vs_cluster_size; - next_off = (start_data_sect + next_sect_off) * + next_off = (start_data_sect + next_sect_off) * sector_size; - dir = (struct vfat_dir_entry *) + dir = (struct vfat_dir_entry *) get_buffer(probe, next_off, buf_size); if (dir == NULL) break; @@ -526,7 +526,7 @@ static int probe_fat(struct blkid_probe *probe, break; /* get FAT entry */ - fat_entry_off = (reserved * sector_size) + + fat_entry_off = (reserved * sector_size) + (next * sizeof(__u32)); buf = get_buffer(probe, fat_entry_off, buf_size); if (buf == NULL) @@ -563,7 +563,7 @@ static int probe_fat(struct blkid_probe *probe, * [7-Jul-2005, Karel Zak <kzak@redhat.com>] */ static int probe_fat_nomagic(struct blkid_probe *probe, - struct blkid_magic *id __BLKID_ATTR((unused)), + struct blkid_magic *id __BLKID_ATTR((unused)), unsigned char *buf) { struct msdos_super_block *ms; @@ -574,7 +574,7 @@ static int probe_fat_nomagic(struct blkid_probe *probe, if (ms->ms_heads == 0) return 1; - /* cluster size check*/ + /* cluster size check*/ if (ms->ms_cluster_size == 0 || (ms->ms_cluster_size & (ms->ms_cluster_size-1))) return 1; @@ -604,7 +604,7 @@ static int probe_fat_nomagic(struct blkid_probe *probe, } static int probe_ntfs(struct blkid_probe *probe, - struct blkid_magic *id __BLKID_ATTR((unused)), + struct blkid_magic *id __BLKID_ATTR((unused)), unsigned char *buf) { struct ntfs_super_block *ns; @@ -631,7 +631,7 @@ static int probe_ntfs(struct blkid_probe *probe, if (ns->cluster_per_mft_record < 0) mft_record_size = 1 << (0-ns->cluster_per_mft_record); else - mft_record_size = ns->cluster_per_mft_record * + mft_record_size = ns->cluster_per_mft_record * sectors_per_cluster * bytes_per_sector; nr_clusters = blkid_le64(ns->number_of_sectors) / sectors_per_cluster; @@ -639,7 +639,7 @@ static int probe_ntfs(struct blkid_probe *probe, (blkid_le64(ns->mft_mirror_cluster_location) > nr_clusters)) return 1; - off = blkid_le64(ns->mft_mirror_cluster_location) * + off = blkid_le64(ns->mft_mirror_cluster_location) * bytes_per_sector * sectors_per_cluster; buf_mft = get_buffer(probe, off, mft_record_size); @@ -649,7 +649,7 @@ static int probe_ntfs(struct blkid_probe *probe, if (memcmp(buf_mft, "FILE", 4)) return 1; - off = blkid_le64(ns->mft_cluster_location) * bytes_per_sector * + off = blkid_le64(ns->mft_cluster_location) * bytes_per_sector * sectors_per_cluster; buf_mft = get_buffer(probe, off, mft_record_size); @@ -672,7 +672,7 @@ static int probe_ntfs(struct blkid_probe *probe, attr_off = blkid_le16(mft->attrs_offset); label_str[0] = 0; - + while (1) { attr = (struct file_attribute *) (buf_mft + attr_off); attr_len = blkid_le16(attr->len); @@ -712,7 +712,7 @@ static int probe_ntfs(struct blkid_probe *probe, static int probe_xfs(struct blkid_probe *probe, - struct blkid_magic *id __BLKID_ATTR((unused)), + struct blkid_magic *id __BLKID_ATTR((unused)), unsigned char *buf) { struct xfs_super_block *xs; @@ -756,7 +756,7 @@ static int probe_reiserfs(struct blkid_probe *probe, } static int probe_reiserfs4(struct blkid_probe *probe, - struct blkid_magic *id __BLKID_ATTR((unused)), + struct blkid_magic *id __BLKID_ATTR((unused)), unsigned char *buf) { struct reiser4_super_block *rs4 = (struct reiser4_super_block *) buf; @@ -765,14 +765,14 @@ static int probe_reiserfs4(struct blkid_probe *probe, if (strlen((char *) rs4->rs4_label)) label = rs4->rs4_label; set_uuid(probe->dev, rs4->rs4_uuid, 0); - blkid_set_tag(probe->dev, "LABEL", (const char *) label, + blkid_set_tag(probe->dev, "LABEL", (const char *) label, sizeof(rs4->rs4_label)); return 0; } static int probe_jfs(struct blkid_probe *probe, - struct blkid_magic *id __BLKID_ATTR((unused)), + struct blkid_magic *id __BLKID_ATTR((unused)), unsigned char *buf) { struct jfs_super_block *js; @@ -825,7 +825,7 @@ static int probe_luks(struct blkid_probe *probe, } static int probe_romfs(struct blkid_probe *probe, - struct blkid_magic *id __BLKID_ATTR((unused)), + struct blkid_magic *id __BLKID_ATTR((unused)), unsigned char *buf) { struct romfs_super_block *ros; @@ -840,7 +840,7 @@ static int probe_romfs(struct blkid_probe *probe, } static int probe_cramfs(struct blkid_probe *probe, - struct blkid_magic *id __BLKID_ATTR((unused)), + struct blkid_magic *id __BLKID_ATTR((unused)), unsigned char *buf) { struct cramfs_super_block *csb; @@ -888,7 +888,7 @@ static int probe_swap1(struct blkid_probe *probe, /* arbitrary sanity check.. is there any garbage down there? */ if (sws->sws_pad[32] == 0 && sws->sws_pad[33] == 0) { if (sws->sws_volume[0]) - blkid_set_tag(probe->dev, "LABEL", sws->sws_volume, + blkid_set_tag(probe->dev, "LABEL", sws->sws_volume, sizeof(sws->sws_volume)); if (sws->sws_uuid[0]) set_uuid(probe->dev, sws->sws_uuid, 0); @@ -897,7 +897,7 @@ static int probe_swap1(struct blkid_probe *probe, } static int probe_iso9660(struct blkid_probe *probe, - struct blkid_magic *id __BLKID_ATTR((unused)), + struct blkid_magic *id __BLKID_ATTR((unused)), unsigned char *buf) { struct iso_volume_descriptor *iso; @@ -906,7 +906,7 @@ static int probe_iso9660(struct blkid_probe *probe, iso = (struct iso_volume_descriptor *) buf; label = iso->volume_id; - blkid_set_tag(probe->dev, "LABEL", (const char *) label, + blkid_set_tag(probe->dev, "LABEL", (const char *) label, figure_label_len(label, 32)); return 0; } @@ -917,7 +917,7 @@ static const char "NSR03", "TEA01", 0 }; static int probe_udf(struct blkid_probe *probe, - struct blkid_magic *id __BLKID_ATTR((unused)), + struct blkid_magic *id __BLKID_ATTR((unused)), unsigned char *buf __BLKID_ATTR((unused))) { int j, bs; @@ -927,7 +927,7 @@ static int probe_udf(struct blkid_probe *probe, /* determine the block size by scanning in 2K increments (block sizes larger than 2K will be null padded) */ for (bs = 1; bs < 16; bs++) { - isosb = (struct iso_volume_descriptor *) + isosb = (struct iso_volume_descriptor *) get_buffer(probe, bs*2048+32768, sizeof(isosb)); if (!isosb) return 1; @@ -938,8 +938,8 @@ static int probe_udf(struct blkid_probe *probe, /* Scan up to another 64 blocks looking for additional VSD's */ for (j = 1; j < 64; j++) { if (j > 1) { - isosb = (struct iso_volume_descriptor *) - get_buffer(probe, j*bs*2048+32768, + isosb = (struct iso_volume_descriptor *) + get_buffer(probe, j*bs*2048+32768, sizeof(isosb)); if (!isosb) return 1; @@ -960,7 +960,7 @@ static int probe_udf(struct blkid_probe *probe, } static int probe_ocfs(struct blkid_probe *probe, - struct blkid_magic *id __BLKID_ATTR((unused)), + struct blkid_magic *id __BLKID_ATTR((unused)), unsigned char *buf) { struct ocfs_volume_header ovh; @@ -975,7 +975,7 @@ static int probe_ocfs(struct blkid_probe *probe, blkid_set_tag(probe->dev,"SEC_TYPE","ocfs1",sizeof("ocfs1")); else if (major >= 9) blkid_set_tag(probe->dev,"SEC_TYPE","ntocfs",sizeof("ntocfs")); - + blkid_set_tag(probe->dev, "LABEL", ovl.label, ocfslabellen(ovl)); blkid_set_tag(probe->dev, "MOUNT", ovh.mount, ocfsmountlen(ovh)); set_uuid(probe->dev, ovl.vol_id, 0); @@ -983,7 +983,7 @@ static int probe_ocfs(struct blkid_probe *probe, } static int probe_ocfs2(struct blkid_probe *probe, - struct blkid_magic *id __BLKID_ATTR((unused)), + struct blkid_magic *id __BLKID_ATTR((unused)), unsigned char *buf) { struct ocfs2_super_block *osb; @@ -996,7 +996,7 @@ static int probe_ocfs2(struct blkid_probe *probe, } static int probe_oracleasm(struct blkid_probe *probe, - struct blkid_magic *id __BLKID_ATTR((unused)), + struct blkid_magic *id __BLKID_ATTR((unused)), unsigned char *buf) { struct oracle_asm_disk_label *dl; @@ -1018,9 +1018,9 @@ static int probe_gfs(struct blkid_probe *probe, if (blkid_be32(sbd->sb_fs_format) == GFS_FORMAT_FS && blkid_be32(sbd->sb_multihost_format) == GFS_FORMAT_MULTI) - { + { blkid_set_tag(probe->dev, "UUID", 0, 0); - + if (strlen(sbd->sb_locktable)) label = sbd->sb_locktable; blkid_set_tag(probe->dev, "LABEL", label, sizeof(sbd->sb_locktable)); @@ -1040,9 +1040,9 @@ static int probe_gfs2(struct blkid_probe *probe, if (blkid_be32(sbd->sb_fs_format) == GFS2_FORMAT_FS && blkid_be32(sbd->sb_multihost_format) == GFS2_FORMAT_MULTI) - { + { blkid_set_tag(probe->dev, "UUID", 0, 0); - + if (strlen(sbd->sb_locktable)) label = sbd->sb_locktable; blkid_set_tag(probe->dev, "LABEL", label, sizeof(sbd->sb_locktable)); @@ -1051,7 +1051,7 @@ static int probe_gfs2(struct blkid_probe *probe, return 1; } -static void unicode_16be_to_utf8(unsigned char *str, int out_len, +static void unicode_16be_to_utf8(unsigned char *str, int out_len, const unsigned char *buf, int in_len) { int i, j; @@ -1138,7 +1138,7 @@ static int probe_hfsplus(struct blkid_probe *probe, (memcmp(sbd->embed_sig, "HX", 2) != 0)) /* This must be an HFS volume, so fail */ return 1; - + alloc_block_size = blkid_be32(sbd->al_blk_size); alloc_first_block = blkid_be16(sbd->al_bl_st); embed_first_block = blkid_be16(sbd->embed_startblock); @@ -1431,7 +1431,7 @@ blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev) if ((now >= dev->bid_time) && (st.st_mtime <= dev->bid_time) && - ((diff < BLKID_PROBE_MIN) || + ((diff < BLKID_PROBE_MIN) || (dev->bid_flags & BLKID_BID_FL_VERIFIED && diff < BLKID_PROBE_INTERVAL))) return dev; @@ -1444,7 +1444,7 @@ blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev) if ((probe.fd = open(dev->bid_name, O_RDONLY)) < 0) { DBG(DEBUG_PROBE, printf("blkid_verify: error %s (%d) while " - "opening %s\n", strerror(errno), errno, + "opening %s\n", strerror(errno), errno, dev->bid_name)); goto open_err; } @@ -1454,12 +1454,12 @@ blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev) probe.sbbuf = 0; probe.buf = 0; probe.buf_max = 0; - + /* * Iterate over the type array. If we already know the type, * then try that first. If it doesn't work, then blow away * the type information, and try again. - * + * */ try_again: type = 0; @@ -1530,7 +1530,7 @@ found_type: free(probe.sbbuf); if (probe.buf) free(probe.buf); - if (probe.fd >= 0) + if (probe.fd >= 0) close(probe.fd); return dev; @@ -1574,7 +1574,7 @@ int main(int argc, char **argv) printf("LABEL='%s'\n", dev->bid_label); if (dev->bid_uuid) printf("UUID='%s'\n", dev->bid_uuid); - + blkid_free_dev(dev); return (0); } diff --git a/lib/blkid/probe.h b/lib/blkid/probe.h index 993156d1..bee5a518 100644 --- a/lib/blkid/probe.h +++ b/lib/blkid/probe.h @@ -30,7 +30,7 @@ struct blkid_probe { size_t buf_max; }; -typedef int (*blkid_probe_t)(struct blkid_probe *probe, +typedef int (*blkid_probe_t)(struct blkid_probe *probe, struct blkid_magic *id, unsigned char *buf); struct blkid_magic { @@ -347,7 +347,7 @@ struct ocfs_volume_header { struct ocfs_volume_label { unsigned char disk_lock[48]; - char label[64]; + char label[64]; unsigned char label_len[2]; unsigned char vol_id[16]; unsigned char vol_id_len[2]; @@ -432,15 +432,15 @@ struct gfs2_sb { __u32 sb_fs_format; __u32 sb_multihost_format; __u32 __pad0; /* Was superblock flags in gfs1 */ - + __u32 sb_bsize; __u32 sb_bsize_shift; __u32 __pad1; /* Was journal segment size in gfs1 */ - + struct gfs2_inum sb_master_dir; /* Was jindex dinode in gfs1 */ struct gfs2_inum __pad2; /* Was rindex dinode in gfs1 */ struct gfs2_inum sb_root_dir; - + char sb_lockproto[GFS_LOCKNAME_LEN]; char sb_locktable[GFS_LOCKNAME_LEN]; /* In gfs1, quota and license dinodes followed */ @@ -686,7 +686,7 @@ _INLINE_ __u64 blkid_swab64(__u64 val) return (blkid_swab32(val >> 32) | (((__u64) blkid_swab32(val & 0xFFFFFFFFUL)) << 32)); } -#endif +#endif diff --git a/lib/blkid/read.c b/lib/blkid/read.c index b913b631..ca2798f0 100644 --- a/lib/blkid/read.c +++ b/lib/blkid/read.c @@ -315,7 +315,7 @@ static int parse_tag(blkid_cache cache, blkid_dev dev, char **cp) return ret; /* Some tags are stored directly in the device struct */ - if (!strcmp(name, "DEVNO")) + if (!strcmp(name, "DEVNO")) dev->bid_devno = STRTOULL(value, 0, 0); else if (!strcmp(name, "PRI")) dev->bid_pri = strtol(value, 0, 0); @@ -401,7 +401,7 @@ void blkid_read_cache(blkid_cache cache) cache->bic_filename)); goto errout; } - + DBG(DEBUG_CACHE, printf("reading cache file %s\n", cache->bic_filename)); @@ -463,7 +463,7 @@ static void debug_dump_dev(blkid_dev dev) list_for_each(p, &dev->bid_tags) { blkid_tag tag = list_entry(p, struct blkid_struct_tag, bit_tags); if (tag) - printf(" tag: %s=\"%s\"\n", tag->bit_name, + printf(" tag: %s=\"%s\"\n", tag->bit_name, tag->bit_val); else printf(" tag: NULL\n"); diff --git a/lib/blkid/resolve.c b/lib/blkid/resolve.c index b4a93081..678f34e7 100644 --- a/lib/blkid/resolve.c +++ b/lib/blkid/resolve.c @@ -68,7 +68,7 @@ char *blkid_get_devname(blkid_cache cache, const char *token, if (!token) return NULL; - + if (!cache) { if (blkid_get_cache(&c, NULL) < 0) return NULL; @@ -126,7 +126,7 @@ int main(int argc, char **argv) fprintf(stderr, "Couldn't get blkid cache\n"); exit(1); } - + if (argv[2]) { value = blkid_get_tag_value(cache, argv[1], argv[2]); printf("%s has tag %s=%s\n", argv[2], argv[1], diff --git a/lib/blkid/save.c b/lib/blkid/save.c index 60aa6ce7..656bb0bb 100644 --- a/lib/blkid/save.c +++ b/lib/blkid/save.c @@ -181,7 +181,7 @@ int main(int argc, char **argv) exit(1); } cache->bic_filename = blkid_strdup(argv[1]); - + if ((ret = blkid_flush_cache(cache)) < 0) { fprintf(stderr, "error (%d) saving cache\n", ret); exit(1); diff --git a/lib/blkid/tag.c b/lib/blkid/tag.c index 8a8ac990..b305ab48 100644 --- a/lib/blkid/tag.c +++ b/lib/blkid/tag.c @@ -83,7 +83,7 @@ blkid_tag blkid_find_tag_dev(blkid_dev dev, const char *type) return NULL; } -extern int blkid_dev_has_tag(blkid_dev dev, const char *type, +extern int blkid_dev_has_tag(blkid_dev dev, const char *type, const char *value) { blkid_tag tag; @@ -125,7 +125,7 @@ static blkid_tag blkid_find_head_cache(blkid_cache cache, const char *type) /* * Set a tag on an existing device. - * + * * If value is NULL, then delete the tagsfrom the device. */ int blkid_set_tag(blkid_dev dev, const char *name, @@ -141,7 +141,7 @@ int blkid_set_tag(blkid_dev dev, const char *name, if (!(val = blkid_strndup(value, vlength)) && value) return -BLKID_ERR_MEM; - /* + /* * Certain common tags are linked directly to the device struct * We need to know what they are before we do anything else because * the function name parameter might get freed later on. @@ -174,7 +174,7 @@ int blkid_set_tag(blkid_dev dev, const char *name, t->bit_dev = dev; list_add_tail(&t->bit_tags, &dev->bid_tags); - + if (dev->bid_cache) { head = blkid_find_head_cache(dev->bid_cache, t->bit_name); @@ -194,11 +194,11 @@ int blkid_set_tag(blkid_dev dev, const char *name, list_add_tail(&t->bit_names, &head->bit_names); } } - + /* Link common tags directly to the device struct */ if (dev_var) *dev_var = val; - + if (dev->bid_cache) dev->bid_cache->bic_flags |= BLKID_BIC_FL_CHANGED; return 0; @@ -274,7 +274,7 @@ errout: * This series of functions iterate over all tags in a device */ #define TAG_ITERATE_MAGIC 0x01a5284c - + struct blkid_struct_tag_iterate { int magic; blkid_dev dev; @@ -301,7 +301,7 @@ extern int blkid_tag_next(blkid_tag_iterate iter, const char **type, const char **value) { blkid_tag tag; - + *type = 0; *value = 0; if (!iter || iter->magic != TAG_ITERATE_MAGIC || @@ -342,9 +342,9 @@ extern blkid_dev blkid_find_dev_with_tag(blkid_cache cache, return NULL; blkid_read_cache(cache); - + DBG(DEBUG_TAG, printf("looking for %s=%s in cache\n", type, value)); - + try_again: pri = -1; dev = 0; @@ -352,7 +352,7 @@ try_again: if (head) { list_for_each(p, &head->bit_names) { - blkid_tag tmp = list_entry(p, struct blkid_struct_tag, + blkid_tag tmp = list_entry(p, struct blkid_struct_tag, bit_names); if (!strcmp(tmp->bit_val, value) && @@ -395,7 +395,7 @@ extern int optind; void usage(char *prog) { fprintf(stderr, "Usage: %s [-f blkid_file] [-m debug_mask] device " - "[type value]\n", + "[type value]\n", prog); fprintf(stderr, "\tList all tags for a device and exit\n"); exit(1); @@ -423,7 +423,7 @@ int main(int argc, char **argv) case 'm': blkid_debug_mask = strtoul (optarg, &tmp, 0); if (*tmp) { - fprintf(stderr, "Invalid debug mask: %s\n", + fprintf(stderr, "Invalid debug mask: %s\n", optarg); exit(1); } @@ -448,14 +448,14 @@ int main(int argc, char **argv) dev = blkid_get_dev(cache, devname, flags); if (!dev) { - fprintf(stderr, "%s: Can not find device in blkid cache\n", + fprintf(stderr, "%s: Can not find device in blkid cache\n", devname); exit(1); } if (search_type) { found = blkid_dev_has_tag(dev, search_type, search_value); printf("Device %s: (%s, %s) %s\n", blkid_dev_devname(dev), - search_type, search_value ? search_value : "NULL", + search_type, search_value ? search_value : "NULL", found ? "FOUND" : "NOT FOUND"); return(!found); } diff --git a/lib/blkid/tst_types.c b/lib/blkid/tst_types.c index 8e3055d9..3003c8b5 100644 --- a/lib/blkid/tst_types.c +++ b/lib/blkid/tst_types.c @@ -2,7 +2,7 @@ * This testing program makes sure the blkid_types header file * * Copyright (C) 2006 by Theodore Ts'o. - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. diff --git a/lib/e2p/e2p.h b/lib/e2p/e2p.h index ad607f68..98c97db4 100644 --- a/lib/e2p/e2p.h +++ b/lib/e2p/e2p.h @@ -40,7 +40,7 @@ const char *e2p_feature2string(int compat, unsigned int mask); int e2p_string2feature(char *string, int *compat, unsigned int *mask); int e2p_edit_feature(const char *str, __u32 *compat_array, __u32 *ok_array); int e2p_edit_feature2(const char *str, __u32 *compat_array, __u32 *ok_array, - __u32 *clear_ok_array, int *type_err, + __u32 *clear_ok_array, int *type_err, unsigned int *mask_err); int e2p_is_null_uuid(void *uu); diff --git a/lib/e2p/feature.c b/lib/e2p/feature.c index e3a72047..1da3c7de 100644 --- a/lib/e2p/feature.c +++ b/lib/e2p/feature.c @@ -1,11 +1,11 @@ /* * feature.c --- convert between features and strings - * + * * Copyright (C) 1999 Theodore Ts'o <tytso@mit.edu> - * + * * This file can be redistributed under the terms of the GNU Library General * Public License - * + * */ #include <stdio.h> @@ -251,11 +251,11 @@ static char *skip_over_word(char *cp) /* * Edit a feature set array as requested by the user. The ok_array, * if set, allows the application to limit what features the user is - * allowed to set or clear using this function. If clear_ok_array is set, + * allowed to set or clear using this function. If clear_ok_array is set, * then use it tell whether or not it is OK to clear a filesystem feature. */ int e2p_edit_feature2(const char *str, __u32 *compat_array, __u32 *ok_array, - __u32 *clear_ok_array, int *type_err, + __u32 *clear_ok_array, int *type_err, unsigned int *mask_err) { char *cp, *buf, *next; @@ -280,7 +280,7 @@ int e2p_edit_feature2(const char *str, __u32 *compat_array, __u32 *ok_array, neg = 0; cp = skip_over_blanks(cp); next = skip_over_word(cp); - + if (*next == 0) next = 0; else @@ -307,11 +307,11 @@ int e2p_edit_feature2(const char *str, __u32 *compat_array, __u32 *ok_array, break; } if (neg) { - if (clear_ok_array && + if (clear_ok_array && !(clear_ok_array[compat_type] & mask)) { rc = 1; if (type_err) - *type_err = (compat_type | + *type_err = (compat_type | E2P_FEATURE_NEGATE_FLAG); if (mask_err) *mask_err = mask; diff --git a/lib/e2p/fsetflags.c b/lib/e2p/fsetflags.c index 3a053240..62189c9b 100644 --- a/lib/e2p/fsetflags.c +++ b/lib/e2p/fsetflags.c @@ -32,8 +32,8 @@ #include "e2p.h" -/* - * Deal with lame glibc's that define this function without actually +/* + * Deal with lame glibc's that define this function without actually * implementing it. Can you say "attractive nuisance", boys and girls? * I knew you could! */ diff --git a/lib/e2p/getflags.c b/lib/e2p/getflags.c index acf7a122..7b35246d 100644 --- a/lib/e2p/getflags.c +++ b/lib/e2p/getflags.c @@ -51,7 +51,7 @@ int getflags (int fd, unsigned long * flags) #else #if HAVE_EXT2_IOCTLS int r, f; - + if (!fstat(fd, &buf) && !S_ISREG(buf.st_mode) && !S_ISDIR(buf.st_mode)) goto notsupp; diff --git a/lib/e2p/getversion.c b/lib/e2p/getversion.c index 38b7d0fb..47c588fd 100644 --- a/lib/e2p/getversion.c +++ b/lib/e2p/getversion.c @@ -25,7 +25,7 @@ int getversion (int fd, unsigned long * version) { #if HAVE_EXT2_IOCTLS int r, ver; - + r = ioctl (fd, EXT2_IOC_GETVERSION, &ver); *version = ver; return 0; diff --git a/lib/e2p/hashstr.c b/lib/e2p/hashstr.c index b257eb26..ece4d058 100644 --- a/lib/e2p/hashstr.c +++ b/lib/e2p/hashstr.c @@ -1,11 +1,11 @@ /* * feature.c --- convert between features and strings - * + * * Copyright (C) 1999 Theodore Ts'o <tytso@mit.edu> - * + * * This file can be redistributed under the terms of the GNU Library General * Public License - * + * */ #include <stdio.h> diff --git a/lib/e2p/iod.c b/lib/e2p/iod.c index 84c97094..2c675b9d 100644 --- a/lib/e2p/iod.c +++ b/lib/e2p/iod.c @@ -29,7 +29,7 @@ int iterate_on_dir (const char * dir_name, struct dirent *de, *dep; int max_len = -1, len, ret = 0; -#if HAVE_PATHCONF && defined(_PC_NAME_MAX) +#if HAVE_PATHCONF && defined(_PC_NAME_MAX) max_len = pathconf(dir_name, _PC_NAME_MAX); #endif if (max_len == -1) { diff --git a/lib/e2p/ls.c b/lib/e2p/ls.c index c211dce7..6d2ce70a 100644 --- a/lib/e2p/ls.c +++ b/lib/e2p/ls.c @@ -6,7 +6,7 @@ * Universite Pierre et Marie Curie (Paris VI) * * Copyright (C) 1995, 1996, 1997 Theodore Ts'o <tytso@mit.edu> - * + * * This file can be redistributed under the terms of the GNU Library General * Public License */ @@ -227,7 +227,7 @@ void list_super2(struct ext2_super_block * sb, FILE *f) fprintf(f, "Block size: %u\n", EXT2_BLOCK_SIZE(sb)); fprintf(f, "Fragment size: %u\n", EXT2_FRAG_SIZE(sb)); if (sb->s_reserved_gdt_blocks) - fprintf(f, "Reserved GDT blocks: %u\n", + fprintf(f, "Reserved GDT blocks: %u\n", sb->s_reserved_gdt_blocks); fprintf(f, "Blocks per group: %u\n", sb->s_blocks_per_group); fprintf(f, "Fragments per group: %u\n", sb->s_frags_per_group); @@ -275,10 +275,10 @@ void list_super2(struct ext2_super_block * sb, FILE *f) fprintf(f, "First inode: %d\n", sb->s_first_ino); fprintf(f, "Inode size: %d\n", sb->s_inode_size); if (sb->s_min_extra_isize) - fprintf(f, "Required extra isize: %d\n", + fprintf(f, "Required extra isize: %d\n", sb->s_min_extra_isize); if (sb->s_want_extra_isize) - fprintf(f, "Desired extra isize: %d\n", + fprintf(f, "Desired extra isize: %d\n", sb->s_want_extra_isize); } if (!e2p_is_null_uuid(sb->s_journal_uuid)) diff --git a/lib/e2p/mntopts.c b/lib/e2p/mntopts.c index 4e50e9f9..51e349dc 100644 --- a/lib/e2p/mntopts.c +++ b/lib/e2p/mntopts.c @@ -1,11 +1,11 @@ /* * mountopts.c --- convert between default mount options and strings - * + * * Copyright (C) 2002 Theodore Ts'o <tytso@mit.edu> - * + * * This file can be redistributed under the terms of the GNU Library General * Public License - * + * */ #include <stdio.h> diff --git a/lib/e2p/ostype.c b/lib/e2p/ostype.c index 3cd6257c..c477535a 100644 --- a/lib/e2p/ostype.c +++ b/lib/e2p/ostype.c @@ -12,10 +12,10 @@ #include <stdlib.h> static const char *os_tab[] = - { "Linux", - "Hurd", - "Masix", - "FreeBSD", + { "Linux", + "Hurd", + "Masix", + "FreeBSD", "Lites", 0 }; diff --git a/lib/e2p/parse_num.c b/lib/e2p/parse_num.c index 7e9ee71a..7f817d60 100644 --- a/lib/e2p/parse_num.c +++ b/lib/e2p/parse_num.c @@ -1,8 +1,8 @@ /* - * parse_num.c - Parse the number of blocks + * parse_num.c - Parse the number of blocks * * Copyright (C) 2004,2005 Theodore Ts'o <tytso@mit.edu> - * + * * This file can be redistributed under the terms of the GNU Library General * Public License */ @@ -18,25 +18,25 @@ unsigned long parse_num_blocks(const char *arg, int log_block_size) num = strtoull(arg, &p, 0); - if (p[0] && p[1]) + if (p[0] && p[1]) return 0; switch (*p) { /* Using fall-through logic */ - case 'T': case 't': + case 'T': case 't': num <<= 10; - case 'G': case 'g': + case 'G': case 'g': num <<= 10; - case 'M': case 'm': + case 'M': case 'm': num <<= 10; - case 'K': case 'k': - num >>= log_block_size; + case 'K': case 'k': + num >>= log_block_size; break; - case 's': + case 's': num >>= (1+log_block_size); break; case '\0': break; - default: + default: return 0; } return num; diff --git a/lib/e2p/percent.c b/lib/e2p/percent.c index b8c936df..94d71e5c 100644 --- a/lib/e2p/percent.c +++ b/lib/e2p/percent.c @@ -2,7 +2,7 @@ * percent.c - Take percentage of a number * * Copyright (C) 2006 Theodore Ts'o <tytso@mit.edu> - * + * * This file can be redistributed under the terms of the GNU Library General * Public License */ @@ -23,7 +23,7 @@ unsigned int e2p_percent(int percent, unsigned int base) return 0; if (100 % percent == 0) return base / (100 / percent); - if (mask & base) + if (mask & base) return (base / 100) * percent; return base * percent / 100; } @@ -49,7 +49,7 @@ main(int argc, char **argv) fprintf(stderr, "Bad percent: %s\n", argv[1]); exit(1); } - + base = strtoul(argv[2], &p, 0); if (p[0] && p[1]) { fprintf(stderr, "Bad base: %s\n", argv[2]); diff --git a/lib/e2p/pf.c b/lib/e2p/pf.c index 05a961a9..078b82c7 100644 --- a/lib/e2p/pf.c +++ b/lib/e2p/pf.c @@ -41,7 +41,7 @@ static struct flags_name flags_array[] = { { EXT2_ECOMPR_FL, "E", "Compression_Error" }, #endif { EXT3_JOURNAL_DATA_FL, "j", "Journaled_Data" }, - { EXT2_INDEX_FL, "I", "Indexed_direcctory" }, + { EXT2_INDEX_FL, "I", "Indexed_direcctory" }, { EXT2_NOTAIL_FL, "t", "No_Tailmerging" }, { EXT2_TOPDIR_FL, "T", "Top_of_Directory_Hierarchies" }, { EXT4_EXTENTS_FL, "e", "Extents" }, diff --git a/lib/e2p/setflags.c b/lib/e2p/setflags.c index 47c52a7a..908f0f19 100644 --- a/lib/e2p/setflags.c +++ b/lib/e2p/setflags.c @@ -25,8 +25,8 @@ #include "e2p.h" -/* - * Deal with lame glibc's that define this function without actually +/* + * Deal with lame glibc's that define this function without actually * implementing it. Can you say "attractive nuisance", boys and girls? * I knew you could! */ diff --git a/lib/e2p/uuid.c b/lib/e2p/uuid.c index 60d42bae..0bf8f829 100644 --- a/lib/e2p/uuid.c +++ b/lib/e2p/uuid.c @@ -42,7 +42,7 @@ static void e2p_unpack_uuid(void *in, struct uuid *uu) tmp = *ptr++; tmp = (tmp << 8) | *ptr++; uu->time_mid = tmp; - + tmp = *ptr++; tmp = (tmp << 8) | *ptr++; uu->time_hi_and_version = tmp; diff --git a/lib/et/com_err.c b/lib/et/com_err.c index 77938b04..d83d6a92 100644 --- a/lib/et/com_err.c +++ b/lib/et/com_err.c @@ -1,6 +1,6 @@ /* * Copyright 1987, 1988 by MIT Student Information Processing Board. - * + * * Permission to use, copy, modify, and distribute this software and * its documentation for any purpose is hereby granted, provided that * the names of M.I.T. and the M.I.T. S.I.P.B. not be used in diff --git a/lib/et/com_err.h b/lib/et/com_err.h index a49c5a5a..1c6ce94c 100644 --- a/lib/et/com_err.h +++ b/lib/et/com_err.h @@ -36,10 +36,10 @@ extern void com_err_va (const char *whoami, errcode_t code, const char *fmt, extern char const *error_message (long); extern void (*com_err_hook) (const char *, long, const char *, va_list); -extern void (*set_com_err_hook (void (*) (const char *, long, +extern void (*set_com_err_hook (void (*) (const char *, long, const char *, va_list))) (const char *, long, const char *, va_list); -extern void (*reset_com_err_hook (void)) (const char *, long, +extern void (*reset_com_err_hook (void)) (const char *, long, const char *, va_list); extern int init_error_table(const char * const *msgs, long base, int count); @@ -49,8 +49,8 @@ extern void add_to_error_table(struct et_list *new_table); /* Provided for Heimdall compatibility */ extern const char *com_right(struct et_list *list, long code); -extern void initialize_error_table_r(struct et_list **list, - const char **messages, +extern void initialize_error_table_r(struct et_list **list, + const char **messages, int num_errors, long base); extern void free_error_table(struct et_list *et); diff --git a/lib/et/com_right.c b/lib/et/com_right.c index 5ac6e7f0..173fd1a3 100644 --- a/lib/et/com_right.c +++ b/lib/et/com_right.c @@ -1,41 +1,41 @@ /* * com_right.c -- provide Heimdall / Kerberos4kth com_err interfaces - * for backwards compatbility - * + * for backwards compatbility + * * Copyright (c) 2003 by Theodore Ts'o * * Taken from lib/com_err/error.c from Kerberos4kth distribution. - * + * * Copyright (c) 1997, 1998, 2001 Kungliga Tekniska Högskolan - * (Royal Institute of Technology, Stockholm, Sweden). - * All rights reserved. + * (Royal Institute of Technology, Stockholm, Sweden). + * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. * - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. */ #include <stdio.h> @@ -68,8 +68,8 @@ struct foobar { * afoul of dependencies. */ void -initialize_error_table_r(struct et_list **list, - const char **messages, +initialize_error_table_r(struct et_list **list, + const char **messages, int num_errors, long base) { @@ -91,7 +91,7 @@ initialize_error_table_r(struct et_list **list, et->next = NULL; *end = et; } - + void free_error_table(struct et_list *et) diff --git a/lib/ext2fs/alloc.c b/lib/ext2fs/alloc.c index ebe2bf6e..230bec9c 100644 --- a/lib/ext2fs/alloc.c +++ b/lib/ext2fs/alloc.c @@ -7,7 +7,7 @@ * This file may be redistributed under the terms of the GNU Public * License. * %End-Header% - * + * */ #include <stdio.h> @@ -100,7 +100,7 @@ static check_inode_uninit(ext2_filsys fs, ext2fs_inode_bitmap map, * * Should have a special policy for directories. */ -errcode_t ext2fs_new_inode(ext2_filsys fs, ext2_ino_t dir, +errcode_t ext2fs_new_inode(ext2_filsys fs, ext2_ino_t dir, int mode EXT2FS_ATTR((unused)), ext2fs_inode_bitmap map, ext2_ino_t *ret) { @@ -109,13 +109,13 @@ errcode_t ext2fs_new_inode(ext2_filsys fs, ext2_ino_t dir, ext2_ino_t start_inode; EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); - + if (!map) map = fs->inode_map; if (!map) return EXT2_ET_NO_INODE_BITMAP; - - if (dir > 0) + + if (dir > 0) dir_group = (dir - 1) / EXT2_INODES_PER_GROUP(fs->super); start_inode = (dir_group * EXT2_INODES_PER_GROUP(fs->super)) + 1; @@ -134,7 +134,7 @@ errcode_t ext2fs_new_inode(ext2_filsys fs, ext2_ino_t dir, if (i > fs->super->s_inodes_count) i = EXT2_FIRST_INODE(fs->super); } while (i != start_inode); - + if (ext2fs_test_inode_bitmap(map, i)) return EXT2_ET_INODE_ALLOC_FAIL; *ret = i; @@ -221,7 +221,7 @@ errcode_t ext2fs_alloc_block(ext2_filsys fs, blk_t goal, retval = io_channel_write_blk(fs->io, block, 1, block_buf); if (retval) goto fail; - + ext2fs_block_alloc_stats(fs, block, +1); *ret = block; @@ -260,7 +260,7 @@ errcode_t ext2fs_get_free_blocks(ext2_filsys fs, blk_t start, blk_t finish, return EXT2_ET_BLOCK_ALLOC_FAIL; } -void ext2fs_set_alloc_block_callback(ext2_filsys fs, +void ext2fs_set_alloc_block_callback(ext2_filsys fs, errcode_t (*func)(ext2_filsys fs, blk64_t goal, blk64_t *ret), diff --git a/lib/ext2fs/alloc_sb.c b/lib/ext2fs/alloc_sb.c index cdcb8666..b0aeb964 100644 --- a/lib/ext2fs/alloc_sb.c +++ b/lib/ext2fs/alloc_sb.c @@ -1,5 +1,5 @@ /* - * alloc_sb.c --- Allocate the superblock and block group descriptors for a + * alloc_sb.c --- Allocate the superblock and block group descriptors for a * newly initialized filesystem. Used by mke2fs when initializing a filesystem * * Copyright (C) 1994, 1995, 1996, 2003 Theodore Ts'o. @@ -40,20 +40,20 @@ * * See also the comment for ext2fs_super_and_bgd_loc() */ -int ext2fs_reserve_super_and_bgd(ext2_filsys fs, +int ext2fs_reserve_super_and_bgd(ext2_filsys fs, dgrp_t group, ext2fs_block_bitmap bmap) { blk_t super_blk, old_desc_blk, new_desc_blk; int j, old_desc_blocks, num_blocks; - num_blocks = ext2fs_super_and_bgd_loc(fs, group, &super_blk, + num_blocks = ext2fs_super_and_bgd_loc(fs, group, &super_blk, &old_desc_blk, &new_desc_blk, 0); if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG) old_desc_blocks = fs->super->s_first_meta_bg; else - old_desc_blocks = + old_desc_blocks = fs->desc_blocks + fs->super->s_reserved_gdt_blocks; if (super_blk || (group == 0)) diff --git a/lib/ext2fs/alloc_stats.c b/lib/ext2fs/alloc_stats.c index a8514cc2..97661dc7 100644 --- a/lib/ext2fs/alloc_stats.c +++ b/lib/ext2fs/alloc_stats.c @@ -7,7 +7,7 @@ * This file may be redistributed under the terms of the GNU Public * License. * %End-Header% - * + * */ #include <stdio.h> @@ -73,7 +73,7 @@ void ext2fs_block_alloc_stats(ext2_filsys fs, blk_t blk, int inuse) (fs->block_alloc_stats)(fs, (blk64_t) blk, inuse); } -void ext2fs_set_block_alloc_stats_callback(ext2_filsys fs, +void ext2fs_set_block_alloc_stats_callback(ext2_filsys fs, void (*func)(ext2_filsys fs, blk64_t blk, int inuse), diff --git a/lib/ext2fs/alloc_tables.c b/lib/ext2fs/alloc_tables.c index 7726eefd..4d2535e4 100644 --- a/lib/ext2fs/alloc_tables.c +++ b/lib/ext2fs/alloc_tables.c @@ -101,7 +101,7 @@ errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group, if (last_grp > fs->group_desc_count) last_grp = fs->group_desc_count; } - + /* * Allocate the block and inode bitmaps, if necessary */ @@ -130,7 +130,7 @@ errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group, if (!fs->group_desc[group].bg_block_bitmap) { retval = ext2fs_get_free_blocks(fs, start_blk, last_blk, 1, bmap, &new_blk); - if (retval == EXT2_ET_BLOCK_ALLOC_FAIL) + if (retval == EXT2_ET_BLOCK_ALLOC_FAIL) retval = ext2fs_get_free_blocks(fs, group_blk, last_blk, 1, bmap, &new_blk); if (retval) @@ -158,7 +158,7 @@ errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group, if (!fs->group_desc[group].bg_inode_bitmap) { retval = ext2fs_get_free_blocks(fs, start_blk, last_blk, 1, bmap, &new_blk); - if (retval == EXT2_ET_BLOCK_ALLOC_FAIL) + if (retval == EXT2_ET_BLOCK_ALLOC_FAIL) retval = ext2fs_get_free_blocks(fs, group_blk, last_blk, 1, bmap, &new_blk); if (retval) diff --git a/lib/ext2fs/badblocks.c b/lib/ext2fs/badblocks.c index da7889d2..6eadb126 100644 --- a/lib/ext2fs/badblocks.c +++ b/lib/ext2fs/badblocks.c @@ -1,6 +1,6 @@ /* * badblocks.c --- routines to manipulate the bad block structure - * + * * Copyright (C) 1994, 1995, 1996 Theodore Ts'o. * * %Begin-Header% @@ -34,7 +34,7 @@ static errcode_t make_u32_list(int size, int num, __u32 *list, { ext2_u32_list bb; errcode_t retval; - + retval = ext2fs_get_mem(sizeof(struct ext2_struct_u32_list), &bb); if (retval) return retval; @@ -54,7 +54,7 @@ static errcode_t make_u32_list(int size, int num, __u32 *list, *ret = bb; return 0; } - + /* * This procedure creates an empty u32 list. @@ -79,7 +79,7 @@ errcode_t ext2fs_badblocks_list_create(ext2_badblocks_list *ret, int size) errcode_t ext2fs_u32_copy(ext2_u32_list src, ext2_u32_list *dest) { errcode_t retval; - + retval = make_u32_list(src->size, src->num, src->list, dest); if (retval) return retval; @@ -271,11 +271,11 @@ int ext2fs_u32_list_iterate(ext2_u32_iterate iter, __u32 *blk) if (bb->magic != EXT2_ET_MAGIC_BADBLOCKS_LIST) return 0; - + if (iter->ptr < bb->num) { *blk = bb->list[iter->ptr++]; return 1; - } + } *blk = 0; return 0; } diff --git a/lib/ext2fs/bb_compat.c b/lib/ext2fs/bb_compat.c index 40f73436..5a158b34 100644 --- a/lib/ext2fs/bb_compat.c +++ b/lib/ext2fs/bb_compat.c @@ -1,6 +1,6 @@ /* * bb_compat.c --- compatibility badblocks routines - * + * * Copyright (C) 1997 Theodore Ts'o. * * %Begin-Header% diff --git a/lib/ext2fs/bb_inode.c b/lib/ext2fs/bb_inode.c index dbda79f1..cbeeb98f 100644 --- a/lib/ext2fs/bb_inode.c +++ b/lib/ext2fs/bb_inode.c @@ -1,12 +1,12 @@ /* * bb_inode.c --- routines to update the bad block inode. - * + * * WARNING: This routine modifies a lot of state in the filesystem; if * this routine returns an error, the bad block inode may be in an * inconsistent state. - * + * * Copyright (C) 1994, 1995 Theodore Ts'o. - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. @@ -49,7 +49,7 @@ static int clear_bad_block_proc(ext2_filsys fs, blk_t *block_nr, e2_blkcnt_t blockcnt, blk_t ref_block, int ref_offset, void *priv_data); - + /* * Given a bad blocks bitmap, update the bad blocks inode to reflect * the map. @@ -59,12 +59,12 @@ errcode_t ext2fs_update_bb_inode(ext2_filsys fs, ext2_badblocks_list bb_list) errcode_t retval; struct set_badblock_record rec; struct ext2_inode inode; - + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); if (!fs->block_map) return EXT2_ET_NO_BLOCK_BITMAP; - + rec.bad_block_count = 0; rec.ind_blocks_size = rec.ind_blocks_ptr = 0; rec.max_ind_blocks = 10; @@ -78,9 +78,9 @@ errcode_t ext2fs_update_bb_inode(ext2_filsys fs, ext2_badblocks_list bb_list) goto cleanup; memset(rec.block_buf, 0, fs->blocksize); rec.err = 0; - + /* - * First clear the old bad blocks (while saving the indirect blocks) + * First clear the old bad blocks (while saving the indirect blocks) */ retval = ext2fs_block_iterate2(fs, EXT2_BAD_INO, BLOCK_FLAG_DEPTH_TRAVERSE, 0, @@ -91,7 +91,7 @@ errcode_t ext2fs_update_bb_inode(ext2_filsys fs, ext2_badblocks_list bb_list) retval = rec.err; goto cleanup; } - + /* * Now set the bad blocks! * @@ -108,22 +108,22 @@ errcode_t ext2fs_update_bb_inode(ext2_filsys fs, ext2_badblocks_list bb_list) BLOCK_FLAG_APPEND, 0, set_bad_block_proc, &rec); ext2fs_badblocks_list_iterate_end(rec.bb_iter); - if (retval) + if (retval) goto cleanup; if (rec.err) { retval = rec.err; goto cleanup; } } - + /* * Update the bad block inode's mod time and block count - * field. + * field. */ retval = ext2fs_read_inode(fs, EXT2_BAD_INO, &inode); if (retval) goto cleanup; - + inode.i_atime = inode.i_mtime = fs->now ? fs->now : time(0); if (!inode.i_ctime) inode.i_ctime = fs->now ? fs->now : time(0); @@ -133,7 +133,7 @@ errcode_t ext2fs_update_bb_inode(ext2_filsys fs, ext2_badblocks_list bb_list) retval = ext2fs_write_inode(fs, EXT2_BAD_INO, &inode); if (retval) goto cleanup; - + cleanup: ext2fs_free_mem(&rec.ind_blocks); ext2fs_free_mem(&rec.block_buf); @@ -176,7 +176,7 @@ static int clear_bad_block_proc(ext2_filsys fs, blk_t *block_nr, if (rec->ind_blocks_size >= rec->max_ind_blocks) { old_size = rec->max_ind_blocks * sizeof(blk_t); rec->max_ind_blocks += 10; - retval = ext2fs_resize_mem(old_size, + retval = ext2fs_resize_mem(old_size, rec->max_ind_blocks * sizeof(blk_t), &rec->ind_blocks); if (retval) { @@ -192,12 +192,12 @@ static int clear_bad_block_proc(ext2_filsys fs, blk_t *block_nr, * Mark the block as unused, and update accounting information */ ext2fs_block_alloc_stats(fs, *block_nr, -1); - + *block_nr = 0; return BLOCK_CHANGED; } - + /* * Helper function for update_bb_inode() * @@ -250,12 +250,12 @@ static int set_bad_block_proc(ext2_filsys fs, blk_t *block_nr, return BLOCK_ABORT; } } - + /* * Update block counts */ ext2fs_block_alloc_stats(fs, blk, +1); - + *block_nr = blk; return BLOCK_CHANGED; } diff --git a/lib/ext2fs/bitmaps.c b/lib/ext2fs/bitmaps.c index b033fa36..ea08b3e2 100644 --- a/lib/ext2fs/bitmaps.c +++ b/lib/ext2fs/bitmaps.c @@ -46,7 +46,7 @@ errcode_t ext2fs_copy_bitmap(ext2fs_generic_bitmap src, void ext2fs_set_bitmap_padding(ext2fs_generic_bitmap map) { ext2fs_set_generic_bitmap_padding(map); -} +} errcode_t ext2fs_allocate_inode_bitmap(ext2_filsys fs, const char *descr, @@ -79,9 +79,9 @@ errcode_t ext2fs_allocate_block_bitmap(ext2_filsys fs, start = fs->super->s_first_data_block; end = fs->super->s_blocks_count-1; - real_end = (EXT2_BLOCKS_PER_GROUP(fs->super) + real_end = (EXT2_BLOCKS_PER_GROUP(fs->super) * fs->group_desc_count)-1 + start; - + return (ext2fs_make_generic_bitmap(EXT2_ET_MAGIC_BLOCK_BITMAP, fs, start, end, real_end, descr, 0, ret)); @@ -168,7 +168,7 @@ errcode_t ext2fs_set_block_bitmap_range(ext2fs_block_bitmap bmap, blk_t start, unsigned int num, void *in) { - return (ext2fs_set_generic_bitmap_range(bmap, + return (ext2fs_set_generic_bitmap_range(bmap, EXT2_ET_MAGIC_BLOCK_BITMAP, start, num, in)); } diff --git a/lib/ext2fs/bitops.c b/lib/ext2fs/bitops.c index 9c348474..485e997b 100644 --- a/lib/ext2fs/bitops.c +++ b/lib/ext2fs/bitops.c @@ -1,7 +1,7 @@ /* * bitops.c --- Bitmap frobbing code. See bitops.h for the inlined * routines. - * + * * Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o. * * %Begin-Header% diff --git a/lib/ext2fs/bitops.h b/lib/ext2fs/bitops.h index 391b8cdb..82ca138f 100644 --- a/lib/ext2fs/bitops.h +++ b/lib/ext2fs/bitops.h @@ -1,14 +1,14 @@ /* * bitops.h --- Bitmap frobbing code. The byte swapping routines are * also included here. - * + * * Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o. * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. * %End-Header% - * + * * i386 bitops operations taken from <asm/bitops.h>, Copyright 1992, * Linus Torvalds. */ @@ -118,7 +118,7 @@ extern __u32 ext2fs_get_generic_bitmap_end(ext2fs_generic_bitmap bitmap); /* * The inline routines themselves... - * + * * If NO_INLINE_FUNCS is defined, then we won't try to do inline * functions at all; they will be included as normal functions in * inline.c @@ -185,7 +185,7 @@ _INLINE_ void ext2fs_fast_clear_bit(unsigned int nr, void * addr) */ struct __dummy_h { unsigned long a[100]; }; #define EXT2FS_ADDR (*(struct __dummy_h *) addr) -#define EXT2FS_CONST_ADDR (*(const struct __dummy_h *) addr) +#define EXT2FS_CONST_ADDR (*(const struct __dummy_h *) addr) _INLINE_ int ext2fs_set_bit(unsigned int nr, void * addr) { @@ -230,7 +230,7 @@ _INLINE_ int ext2fs_find_first_bit_set(void * addr, unsigned size) return 0; /* This looks at memory. Mark it volatile to tell gcc not to move it around */ __asm__ __volatile__( - "cld\n\t" + "cld\n\t" "xorl %%eax,%%eax\n\t" "xorl %%edx,%%edx\n\t" "repe; scasl\n\t" @@ -250,7 +250,7 @@ _INLINE_ int ext2fs_find_next_bit_set (void * addr, int size, int offset) { unsigned long * p = ((unsigned long *) addr) + (offset >> 5); int set = 0, bit = offset & 31, res; - + if (bit) { /* * Look for zero in first byte @@ -376,7 +376,7 @@ _INLINE_ int ext2fs_find_first_bit_set(void * addr, unsigned size) d0 = ffs(*cp); if (d0 == 0) return size; - + return res + d0 - 1; } @@ -384,10 +384,10 @@ _INLINE_ int ext2fs_find_next_bit_set (void * addr, int size, int offset) { unsigned char * p; int set = 0, bit = offset & 7, res = 0, d0; - + res = offset >> 3; p = ((unsigned char *) addr) + res; - + if (bit) { set = ffs(*p & ~((1 << bit) - 1)); if (set) @@ -405,7 +405,7 @@ _INLINE_ int ext2fs_find_next_bit_set (void * addr, int size, int offset) return (res + d0 - 1); } -#endif +#endif _INLINE_ int ext2fs_mark_block_bitmap(ext2fs_block_bitmap bitmap, blk_t block) @@ -417,35 +417,35 @@ _INLINE_ int ext2fs_mark_block_bitmap(ext2fs_block_bitmap bitmap, _INLINE_ int ext2fs_unmark_block_bitmap(ext2fs_block_bitmap bitmap, blk_t block) { - return ext2fs_unmark_generic_bitmap((ext2fs_generic_bitmap) bitmap, + return ext2fs_unmark_generic_bitmap((ext2fs_generic_bitmap) bitmap, block); } _INLINE_ int ext2fs_test_block_bitmap(ext2fs_block_bitmap bitmap, blk_t block) { - return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap, + return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap, block); } _INLINE_ int ext2fs_mark_inode_bitmap(ext2fs_inode_bitmap bitmap, ext2_ino_t inode) { - return ext2fs_mark_generic_bitmap((ext2fs_generic_bitmap) bitmap, + return ext2fs_mark_generic_bitmap((ext2fs_generic_bitmap) bitmap, inode); } _INLINE_ int ext2fs_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap, ext2_ino_t inode) { - return ext2fs_unmark_generic_bitmap((ext2fs_generic_bitmap) bitmap, + return ext2fs_unmark_generic_bitmap((ext2fs_generic_bitmap) bitmap, inode); } _INLINE_ int ext2fs_test_inode_bitmap(ext2fs_inode_bitmap bitmap, ext2_ino_t inode) { - return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap, + return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap, inode); } @@ -464,7 +464,7 @@ _INLINE_ void ext2fs_fast_unmark_block_bitmap(ext2fs_block_bitmap bitmap, _INLINE_ int ext2fs_fast_test_block_bitmap(ext2fs_block_bitmap bitmap, blk_t block) { - return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap, + return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap, block); } @@ -483,7 +483,7 @@ _INLINE_ void ext2fs_fast_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap, _INLINE_ int ext2fs_fast_test_inode_bitmap(ext2fs_inode_bitmap bitmap, ext2_ino_t inode) { - return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap, + return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap, inode); } diff --git a/lib/ext2fs/block.c b/lib/ext2fs/block.c index 71fec23a..b19c450d 100644 --- a/lib/ext2fs/block.c +++ b/lib/ext2fs/block.c @@ -1,6 +1,6 @@ /* * block.c --- iterate over all blocks in an inode - * + * * Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o. * * %Begin-Header% @@ -80,7 +80,7 @@ static int block_iterate_ind(blk_t *ind_block, blk_t ref_block, ret |= BLOCK_ERROR; return ret; } - ctx->errcode = ext2fs_read_ind_block(ctx->fs, *ind_block, + ctx->errcode = ext2fs_read_ind_block(ctx->fs, *ind_block, ctx->ind_buf); if (ctx->errcode) { ret |= BLOCK_ERROR; @@ -92,7 +92,7 @@ static int block_iterate_ind(blk_t *ind_block, blk_t ref_block, if (ctx->flags & BLOCK_FLAG_APPEND) { for (i = 0; i < limit; i++, ctx->bcount++, block_nr++) { flags = (*ctx->func)(ctx->fs, block_nr, ctx->bcount, - *ind_block, offset, + *ind_block, offset, ctx->priv_data); changed |= flags; if (flags & BLOCK_ABORT) { @@ -106,7 +106,7 @@ static int block_iterate_ind(blk_t *ind_block, blk_t ref_block, if (*block_nr == 0) continue; flags = (*ctx->func)(ctx->fs, block_nr, ctx->bcount, - *ind_block, offset, + *ind_block, offset, ctx->priv_data); changed |= flags; if (flags & BLOCK_ABORT) { @@ -132,7 +132,7 @@ static int block_iterate_ind(blk_t *ind_block, blk_t ref_block, check_for_ro_violation_return(ctx, ret); return ret; } - + static int block_iterate_dind(blk_t *dind_block, blk_t ref_block, int ref_offset, struct block_context *ctx) { @@ -157,7 +157,7 @@ static int block_iterate_dind(blk_t *dind_block, blk_t ref_block, ret |= BLOCK_ERROR; return ret; } - ctx->errcode = ext2fs_read_ind_block(ctx->fs, *dind_block, + ctx->errcode = ext2fs_read_ind_block(ctx->fs, *dind_block, ctx->dind_buf); if (ctx->errcode) { ret |= BLOCK_ERROR; @@ -211,7 +211,7 @@ static int block_iterate_dind(blk_t *dind_block, blk_t ref_block, check_for_ro_violation_return(ctx, ret); return ret; } - + static int block_iterate_tind(blk_t *tind_block, blk_t ref_block, int ref_offset, struct block_context *ctx) { @@ -236,7 +236,7 @@ static int block_iterate_tind(blk_t *tind_block, blk_t ref_block, ret |= BLOCK_ERROR; return ret; } - ctx->errcode = ext2fs_read_ind_block(ctx->fs, *tind_block, + ctx->errcode = ext2fs_read_ind_block(ctx->fs, *tind_block, ctx->tind_buf); if (ctx->errcode) { ret |= BLOCK_ERROR; @@ -290,7 +290,7 @@ static int block_iterate_tind(blk_t *tind_block, blk_t ref_block, check_for_ro_violation_return(ctx, ret); return ret; } - + errcode_t ext2fs_block_iterate2(ext2_filsys fs, ext2_ino_t ino, int flags, @@ -357,7 +357,7 @@ errcode_t ext2fs_block_iterate2(ext2_filsys fs, check_for_ro_violation_goto(&ctx, ret, abort_exit); } } - + if (inode.i_flags & EXT4_EXTENTS_FL) { ext2_extent_handle_t handle; struct ext2fs_extent extent; @@ -385,7 +385,7 @@ errcode_t ext2fs_block_iterate2(ext2_filsys fs, check_for_ro_violation_goto(&ctx, ret, extent_errout); if (r & BLOCK_CHANGED) { - ctx.errcode = + ctx.errcode = ext2fs_extent_set_bmap(handle, (blk64_t) blockcnt++, (blk64_t) blk, 0); @@ -529,7 +529,7 @@ errcode_t ext2fs_block_iterate(ext2_filsys fs, void *priv_data) { struct xlate xl; - + xl.real_private = priv_data; xl.func = func; diff --git a/lib/ext2fs/bmap.c b/lib/ext2fs/bmap.c index be7ccbc9..4edf425e 100644 --- a/lib/ext2fs/bmap.c +++ b/lib/ext2fs/bmap.c @@ -26,14 +26,14 @@ #endif extern errcode_t ext2fs_bmap(ext2_filsys fs, ext2_ino_t ino, - struct ext2_inode *inode, + struct ext2_inode *inode, char *block_buf, int bmap_flags, blk_t block, blk_t *phys_blk); #define inode_bmap(inode, nr) ((inode)->i_block[(nr)]) -static _BMAP_INLINE_ errcode_t block_ind_bmap(ext2_filsys fs, int flags, - blk_t ind, char *block_buf, +static _BMAP_INLINE_ errcode_t block_ind_bmap(ext2_filsys fs, int flags, + blk_t ind, char *block_buf, int *blocks_alloc, blk_t nr, blk_t *ret_blk) { @@ -90,17 +90,17 @@ static _BMAP_INLINE_ errcode_t block_ind_bmap(ext2_filsys fs, int flags, } static _BMAP_INLINE_ errcode_t block_dind_bmap(ext2_filsys fs, int flags, - blk_t dind, char *block_buf, + blk_t dind, char *block_buf, int *blocks_alloc, blk_t nr, blk_t *ret_blk) { blk_t b; errcode_t retval; blk_t addr_per_block; - + addr_per_block = (blk_t) fs->blocksize >> 2; - retval = block_ind_bmap(fs, flags & ~BMAP_SET, dind, block_buf, + retval = block_ind_bmap(fs, flags & ~BMAP_SET, dind, block_buf, blocks_alloc, nr / addr_per_block, &b); if (retval) return retval; @@ -110,17 +110,17 @@ static _BMAP_INLINE_ errcode_t block_dind_bmap(ext2_filsys fs, int flags, } static _BMAP_INLINE_ errcode_t block_tind_bmap(ext2_filsys fs, int flags, - blk_t tind, char *block_buf, + blk_t tind, char *block_buf, int *blocks_alloc, blk_t nr, blk_t *ret_blk) { blk_t b; errcode_t retval; blk_t addr_per_block; - + addr_per_block = (blk_t) fs->blocksize >> 2; - retval = block_dind_bmap(fs, flags & ~BMAP_SET, tind, block_buf, + retval = block_dind_bmap(fs, flags & ~BMAP_SET, tind, block_buf, blocks_alloc, nr / addr_per_block, &b); if (retval) return retval; @@ -224,7 +224,7 @@ errcode_t ext2fs_bmap2(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode *inode, *phys_blk = inode_bmap(inode, block); b = block ? inode_bmap(inode, block-1) : 0; - + if ((*phys_blk == 0) && (bmap_flags & BMAP_ALLOC)) { retval = ext2fs_alloc_block(fs, b, block_buf, &b); if (retval) @@ -235,7 +235,7 @@ errcode_t ext2fs_bmap2(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode *inode, } goto done; } - + /* Indirect block */ block -= EXT2_NDIR_BLOCKS; blk32 = *phys_blk; @@ -255,13 +255,13 @@ errcode_t ext2fs_bmap2(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode *inode, inode_bmap(inode, EXT2_IND_BLOCK) = b; blocks_alloc++; } - retval = block_ind_bmap(fs, bmap_flags, b, block_buf, + retval = block_ind_bmap(fs, bmap_flags, b, block_buf, &blocks_alloc, block, &blk32); if (retval == 0) *phys_blk = blk32; goto done; } - + /* Doubly indirect block */ block -= addr_per_block; if (block < addr_per_block * addr_per_block) { @@ -280,7 +280,7 @@ errcode_t ext2fs_bmap2(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode *inode, inode_bmap(inode, EXT2_DIND_BLOCK) = b; blocks_alloc++; } - retval = block_dind_bmap(fs, bmap_flags, b, block_buf, + retval = block_dind_bmap(fs, bmap_flags, b, block_buf, &blocks_alloc, block, &blk32); if (retval == 0) *phys_blk = blk32; @@ -304,7 +304,7 @@ errcode_t ext2fs_bmap2(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode *inode, inode_bmap(inode, EXT2_TIND_BLOCK) = b; blocks_alloc++; } - retval = block_tind_bmap(fs, bmap_flags, b, block_buf, + retval = block_tind_bmap(fs, bmap_flags, b, block_buf, &blocks_alloc, block, &blk32); if (retval == 0) *phys_blk = blk32; diff --git a/lib/ext2fs/bmove.c b/lib/ext2fs/bmove.c index 7d4b21af..019db91c 100644 --- a/lib/ext2fs/bmove.c +++ b/lib/ext2fs/bmove.c @@ -44,7 +44,7 @@ static int process_block(ext2_filsys fs, blk_t *block_nr, pb = (struct process_block_struct *) priv_data; block = orig = *block_nr; ret = 0; - + /* * Let's see if this is one which we need to relocate */ @@ -98,7 +98,7 @@ errcode_t ext2fs_move_blocks(ext2_filsys fs, struct process_block_struct pb; ext2_inode_scan scan; char *block_buf; - + retval = ext2fs_open_inode_scan(fs, 0, &scan); if (retval) return retval; @@ -107,7 +107,7 @@ errcode_t ext2fs_move_blocks(ext2_filsys fs, pb.error = 0; pb.alloc_map = alloc_map ? alloc_map : fs->block_map; pb.flags = flags; - + retval = ext2fs_get_array(4, fs->blocksize, &block_buf); if (retval) return retval; @@ -131,12 +131,12 @@ errcode_t ext2fs_move_blocks(ext2_filsys fs, retval = ext2fs_get_next_inode(scan, &ino, &inode); if (retval) return retval; - + while (ino) { if ((inode.i_links_count == 0) || !ext2fs_inode_has_valid_blocks(&inode)) goto next; - + pb.ino = ino; pb.inode = &inode; diff --git a/lib/ext2fs/brel.h b/lib/ext2fs/brel.h index be97243c..a7f97765 100644 --- a/lib/ext2fs/brel.h +++ b/lib/ext2fs/brel.h @@ -1,6 +1,6 @@ /* * brel.h - * + * * Copyright (C) 1996, 1997 Theodore Ts'o. * * %Begin-Header% @@ -47,7 +47,7 @@ struct ext2_block_relocation_table { * Initialize for iterating over the block relocation entries. */ errcode_t (*start_iter)(ext2_brel brel); - + /* * The iterator function for the inode relocation entries. * Returns an inode number of 0 when out of entries. diff --git a/lib/ext2fs/brel_ma.c b/lib/ext2fs/brel_ma.c index 3753e9fa..1c4f218d 100644 --- a/lib/ext2fs/brel_ma.c +++ b/lib/ext2fs/brel_ma.c @@ -1,6 +1,6 @@ /* * brel_ma.c - * + * * Copyright (C) 1996, 1997 Theodore Ts'o. * * TODO: rewrite to not use a direct array!!! (Fortunately this @@ -61,18 +61,18 @@ errcode_t ext2fs_brel_memarray_create(char *name, blk_t max_block, if (retval) goto errout; memset(brel, 0, sizeof(struct ext2_block_relocation_table)); - + retval = ext2fs_get_mem(strlen(name)+1, &brel->name); if (retval) goto errout; strcpy(brel->name, name); - + retval = ext2fs_get_mem(sizeof(struct brel_ma), &ma); if (retval) goto errout; memset(ma, 0, sizeof(struct brel_ma)); brel->priv_data = ma; - + size = (size_t) (sizeof(struct ext2_block_relocate_entry) * (max_block+1)); retval = ext2fs_get_array(max_block+1, @@ -92,7 +92,7 @@ errcode_t ext2fs_brel_memarray_create(char *name, blk_t max_block, brel->move = bma_move; brel->delete = bma_delete; brel->free = bma_free; - + *new_brel = brel; return 0; diff --git a/lib/ext2fs/check_desc.c b/lib/ext2fs/check_desc.c index c84589bf..299cb010 100644 --- a/lib/ext2fs/check_desc.c +++ b/lib/ext2fs/check_desc.c @@ -1,6 +1,6 @@ /* * check_desc.c --- Check the group descriptors of an ext2 filesystem - * + * * Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o. * * %Begin-Header% @@ -53,7 +53,7 @@ errcode_t ext2fs_check_desc(ext2_filsys fs) EXT4_FEATURE_INCOMPAT_FLEX_BG)) { first_block = ext2fs_group_first_block(fs, i); last_block = ext2fs_group_last_block(fs, i); - if (i == (fs->group_desc_count - 1)) + if (i == (fs->group_desc_count - 1)) last_block = fs->super->s_blocks_count-1; } @@ -88,7 +88,7 @@ errcode_t ext2fs_check_desc(ext2_filsys fs) retval = EXT2_ET_GDESC_BAD_INODE_TABLE; goto errout; } - for (j = 0, b = blk; j < fs->inode_blocks_per_group; + for (j = 0, b = blk; j < fs->inode_blocks_per_group; j++, b++) { if (ext2fs_test_block_bitmap(bmap, b)) { retval = EXT2_ET_GDESC_BAD_INODE_TABLE; diff --git a/lib/ext2fs/closefs.c b/lib/ext2fs/closefs.c index 206faa6c..baf8ce13 100644 --- a/lib/ext2fs/closefs.c +++ b/lib/ext2fs/closefs.c @@ -1,6 +1,6 @@ /* * closefs.c --- close an ext2 filesystem - * + * * Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o. * * %Begin-Header% @@ -58,7 +58,7 @@ int ext2fs_bg_has_super(ext2_filsys fs, int group_block) * * See also the comment for ext2fs_reserve_super_and_bgd() */ -int ext2fs_super_and_bgd_loc(ext2_filsys fs, +int ext2fs_super_and_bgd_loc(ext2_filsys fs, dgrp_t group, blk_t *ret_super_blk, blk_t *ret_old_desc_blk, @@ -75,7 +75,7 @@ int ext2fs_super_and_bgd_loc(ext2_filsys fs, if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG) old_desc_blocks = fs->super->s_first_meta_bg; else - old_desc_blocks = + old_desc_blocks = fs->desc_blocks + fs->super->s_reserved_gdt_blocks; if (group == fs->group_desc_count-1) { @@ -112,7 +112,7 @@ int ext2fs_super_and_bgd_loc(ext2_filsys fs, numblocks--; } } - + numblocks -= 2 + fs->inode_blocks_per_group; if (ret_super_blk) @@ -200,7 +200,7 @@ static errcode_t write_backup_super(ext2_filsys fs, dgrp_t group, struct ext2_super_block *super_shadow) { dgrp_t sgrp = group; - + if (sgrp > ((1 << 16) - 1)) sgrp = (1 << 16) - 1; #ifdef WORDS_BIGENDIAN @@ -209,7 +209,7 @@ static errcode_t write_backup_super(ext2_filsys fs, dgrp_t group, fs->super->s_block_group_nr = sgrp; #endif - return io_channel_write_blk(fs->io, group_block, -SUPERBLOCK_SIZE, + return io_channel_write_blk(fs->io, group_block, -SUPERBLOCK_SIZE, super_shadow); } @@ -228,7 +228,7 @@ errcode_t ext2fs_flush(ext2_filsys fs) #endif char *group_ptr; int old_desc_blocks; - + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); fs_state = fs->super->s_state; @@ -241,13 +241,13 @@ errcode_t ext2fs_flush(ext2_filsys fs) retval = ext2fs_get_mem(SUPERBLOCK_SIZE, &super_shadow); if (retval) goto errout; - retval = ext2fs_get_array(fs->desc_blocks, fs->blocksize, + retval = ext2fs_get_array(fs->desc_blocks, fs->blocksize, &group_shadow); if (retval) goto errout; memset(group_shadow, 0, (size_t) fs->blocksize * fs->desc_blocks); - + /* swap the group descriptors */ for (j=0, s=fs->group_desc, t=group_shadow; j < fs->group_desc_count; j++, t++, s++) { @@ -258,7 +258,7 @@ errcode_t ext2fs_flush(ext2_filsys fs) super_shadow = fs->super; group_shadow = fs->group_desc; #endif - + /* * Set the state of the FS to be non-valid. (The state has * already been backed up earlier, and will be restored after @@ -293,7 +293,7 @@ errcode_t ext2fs_flush(ext2_filsys fs) blk_t super_blk, old_desc_blk, new_desc_blk; int meta_bg; - ext2fs_super_and_bgd_loc(fs, i, &super_blk, &old_desc_blk, + ext2fs_super_and_bgd_loc(fs, i, &super_blk, &old_desc_blk, &new_desc_blk, &meta_bg); if (!(fs->flags & EXT2_FLAG_MASTER_SB_ONLY) &&i && super_blk) { @@ -304,7 +304,7 @@ errcode_t ext2fs_flush(ext2_filsys fs) } if (fs->flags & EXT2_FLAG_SUPER_ONLY) continue; - if ((old_desc_blk) && + if ((old_desc_blk) && (!(fs->flags & EXT2_FLAG_MASTER_SB_ONLY) || (i == 0))) { retval = io_channel_write_blk(fs->io, old_desc_blk, old_desc_blocks, group_ptr); @@ -370,7 +370,7 @@ errout: errcode_t ext2fs_close(ext2_filsys fs) { errcode_t retval; - + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); if (fs->flags & EXT2_FLAG_DIRTY) { diff --git a/lib/ext2fs/csum.c b/lib/ext2fs/csum.c index 257d7133..459c3c08 100644 --- a/lib/ext2fs/csum.c +++ b/lib/ext2fs/csum.c @@ -63,7 +63,7 @@ int ext2fs_group_desc_csum_verify(ext2_filsys fs, dgrp_t group) { if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super, EXT4_FEATURE_RO_COMPAT_GDT_CSUM) && - (fs->group_desc[group].bg_checksum != + (fs->group_desc[group].bg_checksum != ext2fs_group_desc_csum(fs, group))) return 0; diff --git a/lib/ext2fs/dblist.c b/lib/ext2fs/dblist.c index 188e36e3..4a80367c 100644 --- a/lib/ext2fs/dblist.c +++ b/lib/ext2fs/dblist.c @@ -1,13 +1,13 @@ /* * dblist.c -- directory block list functions - * + * * Copyright 1997 by Theodore Ts'o - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. * %End-Header% - * + * */ #include <stdio.h> @@ -33,7 +33,7 @@ errcode_t ext2fs_get_num_dirs(ext2_filsys fs, ext2_ino_t *ret_num_dirs) ext2_ino_t num_dirs, max_dirs; EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); - + num_dirs = 0; max_dirs = fs->super->s_inodes_per_group; for (i = 0; i < fs->group_desc_count; i++) { @@ -89,7 +89,7 @@ static errcode_t make_dblist(ext2_filsys fs, ext2_ino_t size, ext2_ino_t count, &dblist->list); if (retval) goto cleanup; - + if (list) memcpy(dblist->list, list, len); else @@ -159,7 +159,7 @@ errcode_t ext2fs_add_dir_block(ext2_dblist dblist, ext2_ino_t ino, blk_t blk, struct ext2_db_entry *new_entry; errcode_t retval; unsigned long old_size; - + EXT2_CHECK_MAGIC(dblist, EXT2_ET_MAGIC_DBLIST); if (dblist->count >= dblist->size) { @@ -190,7 +190,7 @@ errcode_t ext2fs_set_dir_block(ext2_dblist dblist, ext2_ino_t ino, blk_t blk, int blockcnt) { dgrp_t i; - + EXT2_CHECK_MAGIC(dblist, EXT2_ET_MAGIC_DBLIST); for (i=0; i < dblist->count; i++) { @@ -226,7 +226,7 @@ errcode_t ext2fs_dblist_iterate(ext2_dblist dblist, { ext2_ino_t i; int ret; - + EXT2_CHECK_MAGIC(dblist, EXT2_ET_MAGIC_DBLIST); if (!dblist->sorted) @@ -248,7 +248,7 @@ static EXT2_QSORT_TYPE dir_block_cmp(const void *a, const void *b) if (db_a->blk != db_b->blk) return (int) (db_a->blk - db_b->blk); - + if (db_a->ino != db_b->ino) return (int) (db_a->ino - db_b->ino); @@ -260,7 +260,7 @@ int ext2fs_dblist_count(ext2_dblist dblist) return (int) dblist->count; } -errcode_t ext2fs_dblist_get_last(ext2_dblist dblist, +errcode_t ext2fs_dblist_get_last(ext2_dblist dblist, struct ext2_db_entry **entry) { EXT2_CHECK_MAGIC(dblist, EXT2_ET_MAGIC_DBLIST); @@ -274,7 +274,7 @@ errcode_t ext2fs_dblist_get_last(ext2_dblist dblist, } errcode_t ext2fs_dblist_drop_last(ext2_dblist dblist) -{ +{ EXT2_CHECK_MAGIC(dblist, EXT2_ET_MAGIC_DBLIST); if (dblist->count == 0) diff --git a/lib/ext2fs/dblist_dir.c b/lib/ext2fs/dblist_dir.c index 28a04c74..6f370cd3 100644 --- a/lib/ext2fs/dblist_dir.c +++ b/lib/ext2fs/dblist_dir.c @@ -2,12 +2,12 @@ * dblist_dir.c --- iterate by directory entry * * Copyright 1997 by Theodore Ts'o - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. * %End-Header% - * + * */ #include <stdio.h> @@ -54,7 +54,7 @@ errcode_t ext2fs_dblist_dir_iterate(ext2_dblist dblist, ctx.errcode = 0; retval = ext2fs_dblist_iterate(dblist, db_dir_proc, &ctx); - + if (!block_buf) ext2fs_free_mem(&ctx.buf); if (retval) @@ -71,7 +71,7 @@ static int db_dir_proc(ext2_filsys fs, struct ext2_db_entry *db_info, ctx = (struct dir_context *) priv_data; ctx->dir = db_info->ino; ctx->errcode = 0; - + ret = ext2fs_process_dir_block(fs, &db_info->blk, db_info->blockcnt, 0, 0, priv_data); if ((ret & BLOCK_ABORT) && !ctx->errcode) diff --git a/lib/ext2fs/dir_iterate.c b/lib/ext2fs/dir_iterate.c index 6bb536b0..1f8cf8ff 100644 --- a/lib/ext2fs/dir_iterate.c +++ b/lib/ext2fs/dir_iterate.c @@ -1,6 +1,6 @@ /* * dir_iterate.c --- ext2fs directory iteration operations - * + * * Copyright (C) 1993, 1994, 1994, 1995, 1996, 1997 Theodore Ts'o. * * %Begin-Header% @@ -34,7 +34,7 @@ static int ext2fs_validate_entry(ext2_filsys fs, char *buf, int offset, { struct ext2_dir_entry *dirent; int rec_len; - + while (offset < final_offset) { dirent = (struct ext2_dir_entry *)(buf + offset); rec_len = (dirent->rec_len || fs->blocksize < 65536) ? @@ -63,13 +63,13 @@ errcode_t ext2fs_dir_iterate2(ext2_filsys fs, { struct dir_context ctx; errcode_t retval; - + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); retval = ext2fs_check_directory(fs, dir); if (retval) return retval; - + ctx.dir = dir; ctx.flags = flags; if (block_buf) @@ -110,7 +110,7 @@ static int xlate_func(ext2_ino_t dir EXT2FS_ATTR((unused)), return (*xl->func)(dirent, offset, blocksize, buf, xl->real_private); } -extern errcode_t ext2fs_dir_iterate(ext2_filsys fs, +extern errcode_t ext2fs_dir_iterate(ext2_filsys fs, ext2_ino_t dir, int flags, char *block_buf, @@ -122,7 +122,7 @@ extern errcode_t ext2fs_dir_iterate(ext2_filsys fs, void *priv_data) { struct xlate xl; - + xl.real_private = priv_data; xl.func = func; @@ -155,7 +155,7 @@ int ext2fs_process_dir_block(ext2_filsys fs, return 0; entry = blockcnt ? DIRENT_OTHER_FILE : DIRENT_DOT_FILE; - + ctx->errcode = ext2fs_read_dir_block(fs, *blocknr, ctx->buf); if (ctx->errcode) return BLOCK_ABORT; @@ -183,7 +183,7 @@ int ext2fs_process_dir_block(ext2_filsys fs, ctx->priv_data); if (entry < DIRENT_OTHER_FILE) entry++; - + if (ret & DIRENT_CHANGED) { rec_len = (dirent->rec_len || fs->blocksize < 65536) ? dirent->rec_len : 65536; @@ -193,10 +193,10 @@ int ext2fs_process_dir_block(ext2_filsys fs, do_abort++; break; } -next: +next: if (next_real_entry == offset) next_real_entry += rec_len; - + if (ctx->flags & DIRENT_FLAG_INCLUDE_REMOVED) { size = ((dirent->name_len & 0xFF) + 11) & ~3; diff --git a/lib/ext2fs/dirblock.c b/lib/ext2fs/dirblock.c index c61e001c..501c6560 100644 --- a/lib/ext2fs/dirblock.c +++ b/lib/ext2fs/dirblock.c @@ -1,6 +1,6 @@ /* * dirblock.c --- directory block routines. - * + * * Copyright (C) 1995, 1996 Theodore Ts'o. * * %Begin-Header% @@ -26,7 +26,7 @@ errcode_t ext2fs_read_dir_block2(ext2_filsys fs, blk_t block, char *p, *end; struct ext2_dir_entry *dirent; unsigned int name_len, rec_len; - + retval = io_channel_read_blk(fs->io, block, 1, buf); if (retval) diff --git a/lib/ext2fs/dirhash.c b/lib/ext2fs/dirhash.c index 9fd20160..c42ccd95 100644 --- a/lib/ext2fs/dirhash.c +++ b/lib/ext2fs/dirhash.c @@ -2,7 +2,7 @@ * dirhash.c -- Calculate the hash of a directory entry * * Copyright (c) 2001 Daniel Phillips - * + * * Copyright (c) 2002 Theodore Ts'o. * * %Begin-Header% @@ -25,7 +25,7 @@ * (see Applied Cryptography, 2nd edition, p448). * * Jeremy Fitzhardinge <jeremy@zip.com.au> 1998 - * + * * This code is made available under the terms of the GPL */ #define DELTA 0x9E3779B9 @@ -37,10 +37,10 @@ static void TEA_transform(__u32 buf[4], __u32 const in[]) __u32 a = in[0], b = in[1], c = in[2], d = in[3]; int n = 16; - do { - sum += DELTA; - b0 += ((b1 << 4)+a) ^ (b1+sum) ^ ((b1 >> 5)+b); - b1 += ((b0 << 4)+c) ^ (b0+sum) ^ ((b0 >> 5)+d); + do { + sum += DELTA; + b0 += ((b1 << 4)+a) ^ (b1+sum) ^ ((b1 >> 5)+b); + b1 += ((b0 << 4)+c) ^ (b0+sum) ^ ((b0 >> 5)+d); } while(--n); buf[0] += b0; @@ -130,7 +130,7 @@ static ext2_dirhash_t dx_hack_hash (const char *name, int len, else c = (int) *scp++; hash = hash1 + (hash0 ^ (c * 7152373)); - + if (hash & 0x80000000) hash -= 0x7fffffff; hash1 = hash0; hash0 = hash; @@ -177,11 +177,11 @@ static void str2hashbuf(const char *msg, int len, __u32 *buf, int num, * Returns the hash of a filename. If len is 0 and name is NULL, then * this function can be used to test whether or not a hash version is * supported. - * + * * The seed is an 4 longword (32 bits) "secret" which can be used to * uniquify a hash. If the seed is all zero's, then some default seed * may be used. - * + * * A particular hash version specifies whether or not the seed is * represented, and whether or not the returned hash is 32 bits or 64 * bits. 32 bit hashes will return 0 for the minor hash. @@ -213,7 +213,7 @@ errcode_t ext2fs_dirhash(int version, const char *name, int len, if (i < 4) memcpy(buf, seed, sizeof(buf)); } - + switch (version) { case EXT2_HASH_LEGACY_UNSIGNED: unsigned_flag++; diff --git a/lib/ext2fs/dosio.c b/lib/ext2fs/dosio.c index d695b18e..d93cc6a3 100644 --- a/lib/ext2fs/dosio.c +++ b/lib/ext2fs/dosio.c @@ -2,7 +2,7 @@ * dosio.c -- Disk I/O module for the ext2fs/DOS library. * * Copyright (c) 1997 by Theodore Ts'o. - * + * * Copyright (c) 1997 Mark Habersack * This file may be distributed under the terms of the GNU Public License. * @@ -179,7 +179,7 @@ static errcode_t dos_open(const char *dev, int flags, io_channel *channel) PARTITION *part; PTABLE_ENTRY *pent; PARTITION **newparts; - + if(!dev) { _dio_error = ERR_BADDEV; diff --git a/lib/ext2fs/dupfs.c b/lib/ext2fs/dupfs.c index 1cf314ce..2f9bedcd 100644 --- a/lib/ext2fs/dupfs.c +++ b/lib/ext2fs/dupfs.c @@ -1,6 +1,6 @@ /* * dupfs.c --- duplicate a ext2 filesystem handle - * + * * Copyright (C) 1997, 1998, 2001, 2003, 2005 by Theodore Ts'o. * * %Begin-Header% @@ -25,7 +25,7 @@ errcode_t ext2fs_dup_handle(ext2_filsys src, ext2_filsys *dest) errcode_t retval; EXT2_CHECK_MAGIC(src, EXT2_ET_MAGIC_EXT2FS_FILSYS); - + retval = ext2fs_get_mem(sizeof(struct struct_ext2_filsys), &fs); if (retval) return retval; @@ -91,6 +91,6 @@ errcode_t ext2fs_dup_handle(ext2_filsys src, ext2_filsys *dest) errout: ext2fs_free(fs); return retval; - + } diff --git a/lib/ext2fs/e2image.h b/lib/ext2fs/e2image.h index e12b7d69..c05d43e2 100644 --- a/lib/ext2fs/e2image.h +++ b/lib/ext2fs/e2image.h @@ -1,10 +1,10 @@ /* * e2image.h --- header file describing the ext2 image format - * + * * Copyright (C) 2000 Theodore Ts'o. * * Note: this uses the POSIX IO interfaces, unlike most of the other - * functions in this library. So sue me. + * functions in this library. So sue me. * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public @@ -24,7 +24,7 @@ struct ext2_image_hdr { char fs_uuid[16]; /* UUID of filesystem */ __u32 fs_blocksize; /* Block size of the filesystem */ __u32 fs_reserved[8]; - + __u32 image_device; /* Device number of image file */ __u32 image_inode; /* Inode number of image file */ __u32 image_time; /* Time of image creation */ @@ -37,15 +37,15 @@ struct ext2_image_hdr { __u32 offset_reserved[8]; }; - - - - - - - - - - - - + + + + + + + + + + + + diff --git a/lib/ext2fs/expanddir.c b/lib/ext2fs/expanddir.c index c124d3e1..934eaf12 100644 --- a/lib/ext2fs/expanddir.c +++ b/lib/ext2fs/expanddir.c @@ -1,6 +1,6 @@ /* * expand.c --- expand an ext2fs directory - * + * * Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999 Theodore Ts'o. * * %Begin-Header% @@ -36,7 +36,7 @@ static int expand_dir_proc(ext2_filsys fs, static blk_t last_blk = 0; char *block; errcode_t retval; - + if (*blocknr) { last_blk = *blocknr; return 0; @@ -62,7 +62,7 @@ static int expand_dir_proc(ext2_filsys fs, } memset(block, 0, fs->blocksize); retval = io_channel_write_blk(fs->io, new_blk, 1, block); - } + } if (retval) { es->err = retval; return BLOCK_ABORT; @@ -83,7 +83,7 @@ errcode_t ext2fs_expand_dir(ext2_filsys fs, ext2_ino_t dir) errcode_t retval; struct expand_dir_struct es; struct ext2_inode inode; - + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); if (!(fs->flags & EXT2_FLAG_RW)) @@ -95,11 +95,11 @@ errcode_t ext2fs_expand_dir(ext2_filsys fs, ext2_ino_t dir) retval = ext2fs_check_directory(fs, dir); if (retval) return retval; - + es.done = 0; es.err = 0; es.newblocks = 0; - + retval = ext2fs_block_iterate2(fs, dir, BLOCK_FLAG_APPEND, 0, expand_dir_proc, &es); @@ -114,7 +114,7 @@ errcode_t ext2fs_expand_dir(ext2_filsys fs, ext2_ino_t dir) retval = ext2fs_read_inode(fs, dir, &inode); if (retval) return retval; - + inode.i_size += fs->blocksize; ext2fs_iblk_add_blocks(fs, &inode, es.newblocks); diff --git a/lib/ext2fs/ext2_fs.h b/lib/ext2fs/ext2_fs.h index 554c708b..d7d7bdb1 100644 --- a/lib/ext2fs/ext2_fs.h +++ b/lib/ext2fs/ext2_fs.h @@ -666,7 +666,7 @@ struct ext2_super_block { #define EXT2_DEFM_XATTR_USER 0x0004 #define EXT2_DEFM_ACL 0x0008 #define EXT2_DEFM_UID16 0x0010 -#define EXT3_DEFM_JMODE 0x0060 +#define EXT3_DEFM_JMODE 0x0060 #define EXT3_DEFM_JMODE_DATA 0x0020 #define EXT3_DEFM_JMODE_ORDERED 0x0040 #define EXT3_DEFM_JMODE_WBACK 0x0060 diff --git a/lib/ext2fs/ext2_io.h b/lib/ext2fs/ext2_io.h index dce21386..2a579e6b 100644 --- a/lib/ext2fs/ext2_io.h +++ b/lib/ext2fs/ext2_io.h @@ -1,6 +1,6 @@ /* * io.h --- the I/O manager abstraction - * + * * Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o. * * %Begin-Header% @@ -76,7 +76,7 @@ struct struct_io_manager { errcode_t (*flush)(io_channel channel); errcode_t (*write_byte)(io_channel channel, unsigned long offset, int count, const void *data); - errcode_t (*set_option)(io_channel channel, const char *option, + errcode_t (*set_option)(io_channel channel, const char *option, const char *arg); errcode_t (*get_stats)(io_channel channel, io_stats *io_stats); errcode_t (*read_blk64)(io_channel channel, unsigned long long block, @@ -98,11 +98,11 @@ struct struct_io_manager { #define io_channel_write_blk(c,b,n,d) ((c)->manager->write_blk((c),b,n,d)) #define io_channel_flush(c) ((c)->manager->flush((c))) #define io_channel_bumpcount(c) ((c)->refcount++) - + /* io_manager.c */ -extern errcode_t io_channel_set_options(io_channel channel, +extern errcode_t io_channel_set_options(io_channel channel, const char *options); -extern errcode_t io_channel_write_byte(io_channel channel, +extern errcode_t io_channel_write_byte(io_channel channel, unsigned long offset, int count, const void *data); extern errcode_t io_channel_read_blk64(io_channel channel, @@ -130,4 +130,4 @@ extern void (*test_io_cb_set_blksize) (int blksize, errcode_t err); #endif /* _EXT2FS_EXT2_IO_H */ - + diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h index 04a95a26..e02a55f6 100644 --- a/lib/ext2fs/ext2fs.h +++ b/lib/ext2fs/ext2fs.h @@ -1,6 +1,6 @@ /* * ext2fs.h --- ext2fs - * + * * Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o. * * %Begin-Header% @@ -259,7 +259,7 @@ struct struct_ext2_filsys { * This is used by ext2fs_expand_dir() to be able to add a new block * to an inode. It can also be used for programs that want to be able * to deal with files that contain "holes". - * + * * BLOCK_FLAG_DEPTH_TRAVERSE indicates that the iterator function for * the indirect, doubly indirect, etc. blocks should be called after * all of the blocks containined in the indirect blocks are processed. @@ -269,7 +269,7 @@ struct struct_ext2_filsys { * BLOCK_FLAG_DATA_ONLY indicates that the iterator function should be * called for data blocks only. * - * BLOCK_FLAG_READ_ONLY is a promise by the caller that it will not + * BLOCK_FLAG_READ_ONLY is a promise by the caller that it will not * modify returned block number. * * BLOCK_FLAG_NO_LARGE is for internal use only. It informs @@ -295,7 +295,7 @@ struct struct_ext2_filsys { /* * Flags for ext2fs_move_blocks */ -#define EXT2_BMOVE_GET_DBLIST 0x0001 +#define EXT2_BMOVE_GET_DBLIST 0x0001 #define EXT2_BMOVE_DEBUG 0x0002 #endif @@ -560,7 +560,7 @@ extern errcode_t ext2fs_get_free_blocks(ext2_filsys fs, blk_t start, blk_t *ret); extern errcode_t ext2fs_alloc_block(ext2_filsys fs, blk_t goal, char *block_buf, blk_t *ret); -extern void ext2fs_set_alloc_block_callback(ext2_filsys fs, +extern void ext2fs_set_alloc_block_callback(ext2_filsys fs, errcode_t (*func)(ext2_filsys fs, blk64_t goal, blk64_t *ret), @@ -569,10 +569,10 @@ extern void ext2fs_set_alloc_block_callback(ext2_filsys fs, blk64_t *ret)); /* alloc_sb.c */ -extern int ext2fs_reserve_super_and_bgd(ext2_filsys fs, +extern int ext2fs_reserve_super_and_bgd(ext2_filsys fs, dgrp_t group, ext2fs_block_bitmap bmap); -extern void ext2fs_set_block_alloc_stats_callback(ext2_filsys fs, +extern void ext2fs_set_block_alloc_stats_callback(ext2_filsys fs, void (*func)(ext2_filsys fs, blk64_t blk, int inuse), @@ -706,10 +706,10 @@ errcode_t ext2fs_block_iterate2(ext2_filsys fs, /* bmap.c */ extern errcode_t ext2fs_bmap(ext2_filsys fs, ext2_ino_t ino, - struct ext2_inode *inode, + struct ext2_inode *inode, char *block_buf, int bmap_flags, blk_t block, blk_t *phys_blk); -extern errcode_t ext2fs_bmap2(ext2_filsys fs, ext2_ino_t ino, +extern errcode_t ext2fs_bmap2(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode *inode, char *block_buf, int bmap_flags, blk64_t block, int *ret_flags, blk64_t *phys_blk); @@ -729,7 +729,7 @@ extern errcode_t ext2fs_check_desc(ext2_filsys fs); extern errcode_t ext2fs_close(ext2_filsys fs); extern errcode_t ext2fs_flush(ext2_filsys fs); extern int ext2fs_bg_has_super(ext2_filsys fs, int group_block); -extern int ext2fs_super_and_bgd_loc(ext2_filsys fs, +extern int ext2fs_super_and_bgd_loc(ext2_filsys fs, dgrp_t group, blk_t *ret_super_blk, blk_t *ret_old_desc_blk, @@ -760,7 +760,7 @@ extern errcode_t ext2fs_set_dir_block(ext2_dblist dblist, ext2_ino_t ino, extern errcode_t ext2fs_copy_dblist(ext2_dblist src, ext2_dblist *dest); extern int ext2fs_dblist_count(ext2_dblist dblist); -extern errcode_t ext2fs_dblist_get_last(ext2_dblist dblist, +extern errcode_t ext2fs_dblist_get_last(ext2_dblist dblist, struct ext2_db_entry **entry); extern errcode_t ext2fs_dblist_drop_last(ext2_dblist dblist); @@ -796,7 +796,7 @@ extern errcode_t ext2fs_dirhash(int version, const char *name, int len, /* dir_iterate.c */ -extern errcode_t ext2fs_dir_iterate(ext2_filsys fs, +extern errcode_t ext2fs_dir_iterate(ext2_filsys fs, ext2_ino_t dir, int flags, char *block_buf, @@ -806,7 +806,7 @@ extern errcode_t ext2fs_dir_iterate(ext2_filsys fs, char *buf, void *priv_data), void *priv_data); -extern errcode_t ext2fs_dir_iterate2(ext2_filsys fs, +extern errcode_t ext2fs_dir_iterate2(ext2_filsys fs, ext2_ino_t dir, int flags, char *block_buf, @@ -890,8 +890,8 @@ extern void ext2fs_u32_list_free(ext2_u32_list bb); /* gen_bitmap.c */ extern void ext2fs_free_generic_bitmap(ext2fs_inode_bitmap bitmap); -extern errcode_t ext2fs_make_generic_bitmap(errcode_t magic, ext2_filsys fs, - __u32 start, __u32 end, +extern errcode_t ext2fs_make_generic_bitmap(errcode_t magic, ext2_filsys fs, + __u32 start, __u32 end, __u32 real_end, const char *descr, char *init_map, ext2fs_generic_bitmap *ret); @@ -904,9 +904,9 @@ extern errcode_t ext2fs_copy_generic_bitmap(ext2fs_generic_bitmap src, ext2fs_generic_bitmap *dest); extern void ext2fs_clear_generic_bitmap(ext2fs_generic_bitmap bitmap); extern errcode_t ext2fs_fudge_generic_bitmap_end(ext2fs_inode_bitmap bitmap, - errcode_t magic, + errcode_t magic, errcode_t neq, - ext2_ino_t end, + ext2_ino_t end, ext2_ino_t *oend); extern void ext2fs_set_generic_bitmap_padding(ext2fs_generic_bitmap map); extern errcode_t ext2fs_resize_generic_bitmap(errcode_t magic, @@ -960,10 +960,10 @@ extern errcode_t ext2fs_initialize(const char *name, int flags, extern void ext2fs_free_icount(ext2_icount_t icount); extern errcode_t ext2fs_create_icount_tdb(ext2_filsys fs, char *tdb_dir, int flags, ext2_icount_t *ret); -extern errcode_t ext2fs_create_icount2(ext2_filsys fs, int flags, +extern errcode_t ext2fs_create_icount2(ext2_filsys fs, int flags, unsigned int size, ext2_icount_t hint, ext2_icount_t *ret); -extern errcode_t ext2fs_create_icount(ext2_filsys fs, int flags, +extern errcode_t ext2fs_create_icount(ext2_filsys fs, int flags, unsigned int size, ext2_icount_t *ret); extern errcode_t ext2fs_icount_fetch(ext2_icount_t icount, ext2_ino_t ino, @@ -979,9 +979,9 @@ errcode_t ext2fs_icount_validate(ext2_icount_t icount, FILE *); /* inode.c */ extern errcode_t ext2fs_flush_icache(ext2_filsys fs); -extern errcode_t ext2fs_get_next_inode_full(ext2_inode_scan scan, +extern errcode_t ext2fs_get_next_inode_full(ext2_inode_scan scan, ext2_ino_t *ino, - struct ext2_inode *inode, + struct ext2_inode *inode, int bufsize); extern errcode_t ext2fs_open_inode_scan(ext2_filsys fs, int buffer_blocks, ext2_inode_scan *ret_scan); @@ -1000,12 +1000,12 @@ extern void ext2fs_set_inode_callback extern int ext2fs_inode_scan_flags(ext2_inode_scan scan, int set_flags, int clear_flags); extern errcode_t ext2fs_read_inode_full(ext2_filsys fs, ext2_ino_t ino, - struct ext2_inode * inode, + struct ext2_inode * inode, int bufsize); extern errcode_t ext2fs_read_inode (ext2_filsys fs, ext2_ino_t ino, struct ext2_inode * inode); extern errcode_t ext2fs_write_inode_full(ext2_filsys fs, ext2_ino_t ino, - struct ext2_inode * inode, + struct ext2_inode * inode, int bufsize); extern errcode_t ext2fs_write_inode(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode * inode); @@ -1016,12 +1016,12 @@ extern errcode_t ext2fs_check_directory(ext2_filsys fs, ext2_ino_t ino); /* inode_io.c */ extern io_manager inode_io_manager; -extern errcode_t ext2fs_inode_io_intern(ext2_filsys fs, ext2_ino_t ino, +extern errcode_t ext2fs_inode_io_intern(ext2_filsys fs, ext2_ino_t ino, char **name); extern errcode_t ext2fs_inode_io_intern2(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode *inode, char **name); - + /* ismounted.c */ extern errcode_t ext2fs_check_if_mounted(const char *file, int *mount_flags); extern errcode_t ext2fs_check_mount_point(const char *device, int *mount_flags, @@ -1064,11 +1064,11 @@ extern int ext2fs_default_journal_size(__u64 blocks); extern errcode_t ext2fs_open(const char *name, int flags, int superblock, unsigned int block_size, io_manager manager, ext2_filsys *ret_fs); -extern errcode_t ext2fs_open2(const char *name, const char *io_options, - int flags, int superblock, +extern errcode_t ext2fs_open2(const char *name, const char *io_options, + int flags, int superblock, unsigned int block_size, io_manager manager, ext2_filsys *ret_fs); -extern blk_t ext2fs_descriptor_block_loc(ext2_filsys fs, blk_t group_block, +extern blk_t ext2fs_descriptor_block_loc(ext2_filsys fs, blk_t group_block, dgrp_t i); errcode_t ext2fs_get_data_io(ext2_filsys fs, io_channel *old_io); errcode_t ext2fs_set_data_io(ext2_filsys fs, io_channel new_io); @@ -1089,14 +1089,14 @@ extern errcode_t ext2fs_read_bb_inode(ext2_filsys fs, ext2_badblocks_list *bb_list); /* read_bb_file.c */ -extern errcode_t ext2fs_read_bb_FILE2(ext2_filsys fs, FILE *f, +extern errcode_t ext2fs_read_bb_FILE2(ext2_filsys fs, FILE *f, ext2_badblocks_list *bb_list, void *priv_data, void (*invalid)(ext2_filsys fs, blk_t blk, char *badstr, void *priv_data)); -extern errcode_t ext2fs_read_bb_FILE(ext2_filsys fs, FILE *f, +extern errcode_t ext2fs_read_bb_FILE(ext2_filsys fs, FILE *f, ext2_badblocks_list *bb_list, void (*invalid)(ext2_filsys fs, blk_t blk)); @@ -1105,7 +1105,7 @@ extern errcode_t ext2fs_read_bb_FILE(ext2_filsys fs, FILE *f, extern errcode_t ext2fs_create_resize_inode(ext2_filsys fs); /* swapfs.c */ -extern void ext2fs_swap_ext_attr(char *to, char *from, int bufsize, +extern void ext2fs_swap_ext_attr(char *to, char *from, int bufsize, int has_header); extern void ext2fs_swap_ext_attr_header(struct ext2_ext_attr_header *to_header, struct ext2_ext_attr_header *from_hdr); @@ -1210,7 +1210,7 @@ _INLINE_ errcode_t ext2fs_free_mem(void *ptr) memcpy(ptr, &p, sizeof(p)); return 0; } - + /* * Resize memory */ diff --git a/lib/ext2fs/ext2fsP.h b/lib/ext2fs/ext2fsP.h index eea32d63..c666faaf 100644 --- a/lib/ext2fs/ext2fsP.h +++ b/lib/ext2fs/ext2fsP.h @@ -1,6 +1,6 @@ /* * ext2fsP.h --- private header file for ext2 library - * + * * Copyright (C) 1997 Theodore Ts'o. * * %Begin-Header% diff --git a/lib/ext2fs/ext_attr.c b/lib/ext2fs/ext_attr.c index 3d208ec7..9f5e10fb 100644 --- a/lib/ext2fs/ext_attr.c +++ b/lib/ext2fs/ext_attr.c @@ -1,6 +1,6 @@ /* * ext_attr.c --- extended attribute blocks - * + * * Copyright (C) 2001 Andreas Gruenbacher, <a.gruenbacher@computer.org> * * Copyright (C) 2002 Theodore Ts'o. diff --git a/lib/ext2fs/extent.c b/lib/ext2fs/extent.c index a2cf679f..929e5cdc 100644 --- a/lib/ext2fs/extent.c +++ b/lib/ext2fs/extent.c @@ -147,7 +147,7 @@ errcode_t ext2fs_extent_header_verify(void *ptr, int size) eh_max = (size - sizeof(*eh)) / entry_size; /* Allow two extent-sized items at the end of the block, for * ext4_extent_tail with checksum in the future. */ - if ((ext2fs_le16_to_cpu(eh->eh_max) > eh_max) || + if ((ext2fs_le16_to_cpu(eh->eh_max) > eh_max) || (ext2fs_le16_to_cpu(eh->eh_max) < (eh_max - 2))) return EXT2_ET_EXTENT_HEADER_BAD; @@ -731,7 +731,7 @@ done: return retval; } -errcode_t ext2fs_extent_replace(ext2_extent_handle_t handle, +errcode_t ext2fs_extent_replace(ext2_extent_handle_t handle, int flags EXT2FS_ATTR((unused)), struct ext2fs_extent *extent) { @@ -1426,7 +1426,7 @@ int common_extent_args_process(int argc, char *argv[], int min_argc, if (common_args_process(argc, argv, min_argc, max_argc, cmd, usage, flags)) return 1; - + if (!current_handle) { com_err(cmd, 0, "Extent handle not open"); return 1; diff --git a/lib/ext2fs/fileio.c b/lib/ext2fs/fileio.c index 8bf99fb9..70325a8f 100644 --- a/lib/ext2fs/fileio.c +++ b/lib/ext2fs/fileio.c @@ -1,6 +1,6 @@ /* * fileio.c --- Simple file I/O routines - * + * * Copyright (C) 1997 Theodore Ts'o. * * %Begin-Header% @@ -50,7 +50,7 @@ errcode_t ext2fs_file_open2(ext2_filsys fs, ext2_ino_t ino, retval = ext2fs_get_mem(sizeof(struct ext2_file), &file); if (retval) return retval; - + memset(file, 0, sizeof(struct ext2_file)); file->magic = EXT2_ET_MAGIC_EXT2_FILE; file->fs = fs; @@ -64,14 +64,14 @@ errcode_t ext2fs_file_open2(ext2_filsys fs, ext2_ino_t ino, if (retval) goto fail; } - + retval = ext2fs_get_array(3, fs->blocksize, &file->buf); if (retval) goto fail; *ret = file; return 0; - + fail: if (file->buf) ext2fs_free_mem(&file->buf); @@ -103,7 +103,7 @@ errcode_t ext2fs_file_flush(ext2_file_t file) { errcode_t retval; ext2_filsys fs; - + EXT2_CHECK_MAGIC(file, EXT2_ET_MAGIC_EXT2_FILE); fs = file->fs; @@ -176,7 +176,7 @@ static errcode_t load_buffer(ext2_file_t file, int dontfill) if (!dontfill) { if (file->physblock) { retval = io_channel_read_blk(fs->io, - file->physblock, + file->physblock, 1, file->buf); if (retval) return retval; @@ -187,16 +187,16 @@ static errcode_t load_buffer(ext2_file_t file, int dontfill) } return 0; } - + errcode_t ext2fs_file_close(ext2_file_t file) { errcode_t retval; - + EXT2_CHECK_MAGIC(file, EXT2_ET_MAGIC_EXT2_FILE); retval = ext2fs_file_flush(file); - + if (file->buf) ext2fs_free_mem(&file->buf); ext2fs_free_mem(&file); @@ -232,14 +232,14 @@ errcode_t ext2fs_file_read(ext2_file_t file, void *buf, left = EXT2_I_SIZE(&file->inode) - file->pos ; if (c > left) c = left; - + memcpy(ptr, file->buf+start, c); file->pos += c; ptr += c; count += c; wanted -= c; } - + fail: if (got) *got = count; @@ -265,7 +265,7 @@ errcode_t ext2fs_file_write(ext2_file_t file, const void *buf, retval = sync_buffer_position(file); if (retval) goto fail; - + start = file->pos % fs->blocksize; c = fs->blocksize - start; if (c > nbytes) @@ -286,7 +286,7 @@ errcode_t ext2fs_file_write(ext2_file_t file, const void *buf, count += c; nbytes -= c; } - + fail: if (written) *written = count; @@ -318,7 +318,7 @@ errcode_t ext2fs_file_lseek(ext2_file_t file, ext2_off_t offset, { __u64 loffset, ret_loffset; errcode_t retval; - + loffset = offset; retval = ext2fs_file_llseek(file, loffset, whence, &ret_loffset); if (ret_pos) @@ -354,14 +354,14 @@ ext2_off_t ext2fs_file_get_size(ext2_file_t file) /* * This function sets the size of the file, truncating it if necessary - * + * * XXX still need to call truncate */ errcode_t ext2fs_file_set_size(ext2_file_t file, ext2_off_t size) { errcode_t retval; EXT2_CHECK_MAGIC(file, EXT2_ET_MAGIC_EXT2_FILE); - + file->inode.i_size = size; file->inode.i_size_high = 0; if (file->ino) { @@ -370,7 +370,7 @@ errcode_t ext2fs_file_set_size(ext2_file_t file, ext2_off_t size) return retval; } - /* + /* * XXX truncate inode if necessary */ diff --git a/lib/ext2fs/finddev.c b/lib/ext2fs/finddev.c index 2e9d70a4..56b76dfc 100644 --- a/lib/ext2fs/finddev.c +++ b/lib/ext2fs/finddev.c @@ -1,7 +1,7 @@ /* * finddev.c -- this routine attempts to find a particular device in * /dev - * + * * Copyright (C) 2000 Theodore Ts'o. * * %Begin-Header% @@ -134,7 +134,7 @@ char *ext2fs_find_block_device(dev_t device) add_to_dirlist("/devices", &list); add_to_dirlist("/devfs", &list); add_to_dirlist("/dev", &list); - + while (list) { current = list; list = list->next; @@ -160,7 +160,7 @@ char *ext2fs_find_block_device(dev_t device) return ret_path; } - + #ifdef DEBUG int main(int argc, char** argv) { @@ -204,5 +204,5 @@ int main(int argc, char** argv) } return 0; } - + #endif diff --git a/lib/ext2fs/flushb.c b/lib/ext2fs/flushb.c index 18827955..f0630ea1 100644 --- a/lib/ext2fs/flushb.c +++ b/lib/ext2fs/flushb.c @@ -1,7 +1,7 @@ /* * flushb.c --- Hides system-dependent information for both syncing a * device to disk and to flush any buffers from disk cache. - * + * * Copyright (C) 2000 Theodore Ts'o. * * %Begin-Header% @@ -29,7 +29,7 @@ #include "ext2fs.h" /* - * For Linux, define BLKFLSBUF and FDFLUSH if necessary, since + * For Linux, define BLKFLSBUF and FDFLUSH if necessary, since * not all portable header file does so for us. This really should be * fixed in the glibc header files. (Recent glibcs appear to define * BLKFLSBUF in sys/mount.h, but FDFLUSH still doesn't seem to be diff --git a/lib/ext2fs/freefs.c b/lib/ext2fs/freefs.c index d6ac9011..2a1c9152 100644 --- a/lib/ext2fs/freefs.c +++ b/lib/ext2fs/freefs.c @@ -1,6 +1,6 @@ /* * freefs.c --- free an ext2 filesystem - * + * * Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o. * * %Begin-Header% @@ -52,7 +52,7 @@ void ext2fs_free(ext2_filsys fs) if (fs->icache) ext2fs_free_inode_cache(fs->icache); - + fs->magic = 0; ext2fs_free_mem(&fs); diff --git a/lib/ext2fs/gen_bitmap.c b/lib/ext2fs/gen_bitmap.c index 66172e5d..a1b1d8f4 100644 --- a/lib/ext2fs/gen_bitmap.c +++ b/lib/ext2fs/gen_bitmap.c @@ -1,6 +1,6 @@ /* * gen_bitmap.c --- Generic (32-bit) bitmap routines - * + * * Copyright (C) 2001 Theodore Ts'o. * * %Begin-Header% @@ -38,7 +38,7 @@ struct ext2fs_struct_generic_bitmap { __u32 reserved[7]; }; -/* +/* * Used by previously inlined function, so we have to export this and * not change the function signature */ @@ -63,7 +63,7 @@ static errcode_t check_magic(ext2fs_generic_bitmap bitmap) return 0; } -errcode_t ext2fs_make_generic_bitmap(errcode_t magic, ext2_filsys fs, +errcode_t ext2fs_make_generic_bitmap(errcode_t magic, ext2_filsys fs, __u32 start, __u32 end, __u32 real_end, const char *descr, char *init_map, ext2fs_generic_bitmap *ret) @@ -72,7 +72,7 @@ errcode_t ext2fs_make_generic_bitmap(errcode_t magic, ext2_filsys fs, errcode_t retval; size_t size; - retval = ext2fs_get_mem(sizeof(struct ext2fs_struct_generic_bitmap), + retval = ext2fs_get_mem(sizeof(struct ext2fs_struct_generic_bitmap), &bitmap); if (retval) return retval; @@ -124,7 +124,7 @@ errcode_t ext2fs_allocate_generic_bitmap(__u32 start, const char *descr, ext2fs_generic_bitmap *ret) { - return ext2fs_make_generic_bitmap(EXT2_ET_MAGIC_GENERIC_BITMAP, 0, + return ext2fs_make_generic_bitmap(EXT2_ET_MAGIC_GENERIC_BITMAP, 0, start, end, real_end, descr, 0, ret); } @@ -132,7 +132,7 @@ errcode_t ext2fs_copy_generic_bitmap(ext2fs_generic_bitmap src, ext2fs_generic_bitmap *dest) { return (ext2fs_make_generic_bitmap(src->magic, src->fs, - src->start, src->end, + src->start, src->end, src->real_end, src->description, src->bitmap, dest)); @@ -209,7 +209,7 @@ errcode_t ext2fs_fudge_generic_bitmap_end(ext2fs_inode_bitmap bitmap, ext2_ino_t end, ext2_ino_t *oend) { EXT2_CHECK_MAGIC(bitmap, magic); - + if (end > bitmap->real_end) return neq; if (oend) @@ -244,7 +244,7 @@ errcode_t ext2fs_resize_generic_bitmap(errcode_t magic, bmap->end = new_end; return 0; } - + size = ((bmap->real_end - bmap->start) / 8) + 1; new_size = ((new_real_end - bmap->start) / 8) + 1; @@ -266,7 +266,7 @@ errcode_t ext2fs_compare_generic_bitmap(errcode_t magic, errcode_t neq, ext2fs_generic_bitmap bm2) { blk_t i; - + if (!bm1 || bm1->magic != magic) return magic; if (!bm2 || bm2->magic != magic) @@ -291,8 +291,8 @@ void ext2fs_set_generic_bitmap_padding(ext2fs_generic_bitmap map) __u32 i, j; /* Protect loop from wrap-around if map->real_end is maxed */ - for (i=map->end+1, j = i - map->start; - i <= map->real_end && i > map->end; + for (i=map->end+1, j = i - map->start; + i <= map->real_end && i > map->end; i++, j++) ext2fs_set_bit(j, map->bitmap); } @@ -348,7 +348,7 @@ void ext2fs_mark_block_bitmap_range(ext2fs_block_bitmap bitmap, blk_t block, int num) { int i; - + if ((block < bitmap->start) || (block+num-1 > bitmap->end)) { ext2fs_warn_bitmap(EXT2_ET_BAD_BLOCK_MARK, block, bitmap->description); @@ -362,13 +362,13 @@ void ext2fs_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap, blk_t block, int num) { int i; - + if ((block < bitmap->start) || (block+num-1 > bitmap->end)) { ext2fs_warn_bitmap(EXT2_ET_BAD_BLOCK_UNMARK, block, bitmap->description); return; } for (i=0; i < num; i++) - ext2fs_fast_clear_bit(block + i - bitmap->start, + ext2fs_fast_clear_bit(block + i - bitmap->start, bitmap->bitmap); } diff --git a/lib/ext2fs/get_pathname.c b/lib/ext2fs/get_pathname.c index 23f593f6..c46b3a0a 100644 --- a/lib/ext2fs/get_pathname.c +++ b/lib/ext2fs/get_pathname.c @@ -1,6 +1,6 @@ /* * get_pathname.c --- do directry/inode -> name translation - * + * * Copyright (C) 1993, 1994, 1995 Theodore Ts'o. * * %Begin-Header% @@ -15,7 +15,7 @@ * directory inode, and <ino> is the inode number itself. If * <ino> is zero, then ext2fs_get_pathname will return pathname * of the the directory <dir>. - * + * */ #include <stdio.h> @@ -65,8 +65,8 @@ static int get_pathname_proc(struct ext2_dir_entry *dirent, return 0; } -static errcode_t ext2fs_get_pathname_int(ext2_filsys fs, ext2_ino_t dir, - ext2_ino_t ino, int maxdepth, +static errcode_t ext2fs_get_pathname_int(ext2_filsys fs, ext2_ino_t dir, + ext2_ino_t ino, int maxdepth, char *buf, char **name) { struct get_pathname_struct gp; @@ -93,7 +93,7 @@ static errcode_t ext2fs_get_pathname_int(ext2_filsys fs, ext2_ino_t dir, gp.parent = 0; gp.name = 0; gp.errcode = 0; - + retval = ext2fs_dir_iterate(fs, dir, 0, buf, get_pathname_proc, &gp); if (retval) goto cleanup; @@ -110,15 +110,15 @@ static errcode_t ext2fs_get_pathname_int(ext2_filsys fs, ext2_ino_t dir, *name = parent_name; return 0; } - - if (gp.name) + + if (gp.name) retval = ext2fs_get_mem(strlen(parent_name)+strlen(gp.name)+2, &ret); else retval = ext2fs_get_mem(strlen(parent_name)+5, &ret); if (retval) goto cleanup; - + ret[0] = 0; if (parent_name[1]) strcat(ret, parent_name); @@ -130,7 +130,7 @@ static errcode_t ext2fs_get_pathname_int(ext2_filsys fs, ext2_ino_t dir, *name = ret; ext2fs_free_mem(&parent_name); retval = 0; - + cleanup: if (gp.name) ext2fs_free_mem(&gp.name); @@ -153,5 +153,5 @@ errcode_t ext2fs_get_pathname(ext2_filsys fs, ext2_ino_t dir, ext2_ino_t ino, retval = ext2fs_get_pathname_int(fs, dir, ino, 32, buf, name); ext2fs_free_mem(&buf); return retval; - + } diff --git a/lib/ext2fs/getsectsize.c b/lib/ext2fs/getsectsize.c index e749d396..ae9139d0 100644 --- a/lib/ext2fs/getsectsize.c +++ b/lib/ext2fs/getsectsize.c @@ -1,6 +1,6 @@ /* * getsectsize.c --- get the sector size of a device. - * + * * Copyright (C) 1995, 1995 Theodore Ts'o. * Copyright (C) 2003 VMware, Inc. * diff --git a/lib/ext2fs/getsize.c b/lib/ext2fs/getsize.c index 7f6ef71b..b45e285c 100644 --- a/lib/ext2fs/getsize.c +++ b/lib/ext2fs/getsize.c @@ -1,11 +1,11 @@ /* * getsize.c --- get the size of a partition. - * + * * Copyright (C) 1995, 1995 Theodore Ts'o. * Copyright (C) 2003 VMware, Inc. * * Windows version of ext2fs_get_device_size by Chris Li, VMware. - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. @@ -82,10 +82,10 @@ errcode_t ext2fs_get_device_size(const char *file, int blocksize, DWORD filesize; #endif /* HAVE_GET_FILE_SIZE_EX */ - dev = CreateFile(file, GENERIC_READ, + dev = CreateFile(file, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE , - NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - + NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (dev == INVALID_HANDLE_VALUE) return EBADF; if (DeviceIoControl(dev, IOCTL_DISK_GET_PARTITION_INFO, @@ -94,7 +94,7 @@ errcode_t ext2fs_get_device_size(const char *file, int blocksize, &retbytes, NULL)) { *retblocks = pi.PartitionLength.QuadPart / blocksize; - + } else if (DeviceIoControl(dev, IOCTL_DISK_GET_DRIVE_GEOMETRY, &gi, sizeof(DISK_GEOMETRY), &gi, sizeof(DISK_GEOMETRY), @@ -300,7 +300,7 @@ int main(int argc, char **argv) { blk_t blocks; int retval; - + if (argc < 2) { fprintf(stderr, "Usage: %s device\n", argv[0]); exit(1); diff --git a/lib/ext2fs/imager.c b/lib/ext2fs/imager.c index 9f7534ab..01543338 100644 --- a/lib/ext2fs/imager.c +++ b/lib/ext2fs/imager.c @@ -5,7 +5,7 @@ * Copyright (C) 2000 Theodore Ts'o. * * Note: this uses the POSIX IO interfaces, unlike most of the other - * functions in this library. So sue me. + * functions in this library. So sue me. * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public @@ -69,7 +69,7 @@ errcode_t ext2fs_image_inode_write(ext2_filsys fs, int fd, int flags) buf = malloc(fs->blocksize * BUF_BLOCKS); if (!buf) return ENOMEM; - + for (group = 0; group < fs->group_desc_count; group++) { blk = fs->group_desc[(unsigned)group].bg_inode_table; if (!blk) { @@ -131,7 +131,7 @@ errout: /* * Read in the inode table and stuff it into place */ -errcode_t ext2fs_image_inode_read(ext2_filsys fs, int fd, +errcode_t ext2fs_image_inode_read(ext2_filsys fs, int fd, int flags EXT2FS_ATTR((unused))) { unsigned int group, c, left; @@ -143,7 +143,7 @@ errcode_t ext2fs_image_inode_read(ext2_filsys fs, int fd, buf = malloc(fs->blocksize * BUF_BLOCKS); if (!buf) return ENOMEM; - + for (group = 0; group < fs->group_desc_count; group++) { blk = fs->group_desc[(unsigned)group].bg_inode_table; if (!blk) { @@ -167,7 +167,7 @@ errcode_t ext2fs_image_inode_read(ext2_filsys fs, int fd, retval = io_channel_write_blk(fs->io, blk, c, buf); if (retval) goto errout; - + blk += c; left -= c; } @@ -182,7 +182,7 @@ errout: /* * Write out superblock and group descriptors */ -errcode_t ext2fs_image_super_write(ext2_filsys fs, int fd, +errcode_t ext2fs_image_super_write(ext2_filsys fs, int fd, int flags EXT2FS_ATTR((unused))) { char *buf, *cp; @@ -221,7 +221,7 @@ errcode_t ext2fs_image_super_write(ext2_filsys fs, int fd, retval = EXT2_ET_SHORT_WRITE; goto errout; } - + retval = 0; errout: @@ -232,7 +232,7 @@ errout: /* * Read the superblock and group descriptors and overwrite them. */ -errcode_t ext2fs_image_super_read(ext2_filsys fs, int fd, +errcode_t ext2fs_image_super_read(ext2_filsys fs, int fd, int flags EXT2FS_ATTR((unused))) { char *buf; @@ -314,7 +314,7 @@ errcode_t ext2fs_image_bitmap_write(ext2_filsys fs, int fd, int flags) if (size > (cnt >> 3)) size = (cnt >> 3); - retval = ext2fs_get_generic_bitmap_range(bmap, + retval = ext2fs_get_generic_bitmap_range(bmap, err, itr, size << 3, buf); if (retval) return retval; @@ -324,7 +324,7 @@ errcode_t ext2fs_image_bitmap_write(ext2_filsys fs, int fd, int flags) return errno; if (actual != (int) size) return EXT2_ET_SHORT_READ; - + itr += size << 3; cnt -= size << 3; } @@ -396,7 +396,7 @@ errcode_t ext2fs_image_bitmap_read(ext2_filsys fs, int fd, int flags) if (actual != (int) size) return EXT2_ET_SHORT_READ; - retval = ext2fs_set_generic_bitmap_range(bmap, + retval = ext2fs_set_generic_bitmap_range(bmap, err, itr, size << 3, buf); if (retval) return retval; diff --git a/lib/ext2fs/ind_block.c b/lib/ext2fs/ind_block.c index efd7fb10..09c04324 100644 --- a/lib/ext2fs/ind_block.c +++ b/lib/ext2fs/ind_block.c @@ -1,7 +1,7 @@ /* * ind_block.c --- indirect block I/O routines - * - * Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, + * + * Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, * 2001, 2002, 2003, 2004, 2005 by Theodore Ts'o. * * %Begin-Header% diff --git a/lib/ext2fs/initialize.c b/lib/ext2fs/initialize.c index aa4f424d..22d18990 100644 --- a/lib/ext2fs/initialize.c +++ b/lib/ext2fs/initialize.c @@ -1,9 +1,9 @@ /* * initialize.c --- initialize a filesystem handle given superblock * parameters. Used by mke2fs when initializing a filesystem. - * + * * Copyright (C) 1994, 1995, 1996 Theodore Ts'o. - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. @@ -44,13 +44,13 @@ #endif /* defined(__FreeBSD__) && defined(EXT2_OS_FREEBSD) */ #endif /* defined(__GNU__) && defined(EXT2_OS_HURD) */ #endif /* defined(__linux__) && defined(EXT2_OS_LINUX) */ - + /* * Note we override the kernel include file's idea of what the default * check interval (never) should be. It's a good idea to check at * least *occasionally*, specially since servers will never rarely get * to reboot, since Linux is so robust these days. :-) - * + * * 180 days (six months) seems like a good value. */ #ifdef EXT2_DFL_CHECKINTERVAL @@ -110,11 +110,11 @@ errcode_t ext2fs_initialize(const char *name, int flags, if (!param || !param->s_blocks_count) return EXT2_ET_INVALID_ARGUMENT; - + retval = ext2fs_get_mem(sizeof(struct struct_ext2_filsys), &fs); if (retval) return retval; - + memset(fs, 0, sizeof(struct struct_ext2_filsys)); fs->magic = EXT2_ET_MAGIC_EXT2FS_FILSYS; fs->flags = flags | EXT2_FLAG_RW; @@ -199,7 +199,7 @@ errcode_t ext2fs_initialize(const char *name, int flags, if (super->s_blocks_per_group > EXT2_MAX_BLOCKS_PER_GROUP(super)) super->s_blocks_per_group = EXT2_MAX_BLOCKS_PER_GROUP(super); super->s_frags_per_group = super->s_blocks_per_group * frags_per_block; - + super->s_blocks_count = param->s_blocks_count; super->s_r_blocks_count = param->s_r_blocks_count; if (super->s_r_blocks_count >= param->s_blocks_count) { @@ -238,7 +238,7 @@ retry: */ if (super->s_inodes_count < EXT2_FIRST_INODE(super)+1) super->s_inodes_count = EXT2_FIRST_INODE(super)+1; - + /* * There should be at least as many inodes as the user * requested. Figure out how many inodes per group that @@ -358,13 +358,13 @@ ipg_retry: retval = ext2fs_get_mem(strlen(fs->device_name) + 80, &buf); if (retval) goto cleanup; - + strcpy(buf, "block bitmap for "); strcat(buf, fs->device_name); retval = ext2fs_allocate_block_bitmap(fs, buf, &fs->block_map); if (retval) goto cleanup; - + strcpy(buf, "inode bitmap for "); strcat(buf, fs->device_name); retval = ext2fs_allocate_inode_bitmap(fs, buf, &fs->inode_map); @@ -420,7 +420,7 @@ ipg_retry: fs->group_desc[i].bg_used_dirs_count = 0; ext2fs_group_desc_csum_set(fs, i); } - + c = (char) 255; if (((int) c) == -1) { super->s_flags |= EXT2_FLAGS_SIGNED_HASH; @@ -431,7 +431,7 @@ ipg_retry: ext2fs_mark_super_dirty(fs); ext2fs_mark_bb_dirty(fs); ext2fs_mark_ib_dirty(fs); - + io_channel_set_blksize(fs->io, fs->blocksize); *ret_fs = fs; diff --git a/lib/ext2fs/inline.c b/lib/ext2fs/inline.c index 5833b1d9..13e2f835 100644 --- a/lib/ext2fs/inline.c +++ b/lib/ext2fs/inline.c @@ -2,7 +2,7 @@ * inline.c --- Includes the inlined functions defined in the header * files as standalone functions, in case the application program * is compiled with inlining turned off. - * + * * Copyright (C) 1993, 1994 Theodore Ts'o. * * %Begin-Header% diff --git a/lib/ext2fs/inode.c b/lib/ext2fs/inode.c index b45de872..b75cb77d 100644 --- a/lib/ext2fs/inode.c +++ b/lib/ext2fs/inode.c @@ -1,6 +1,6 @@ /* * inode.c --- utility routines to read and write inodes - * + * * Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o. * * %Begin-Header% @@ -59,7 +59,7 @@ struct ext2_struct_inode_scan { errcode_t ext2fs_flush_icache(ext2_filsys fs) { int i; - + if (!fs->icache) return 0; @@ -73,7 +73,7 @@ errcode_t ext2fs_flush_icache(ext2_filsys fs) static errcode_t create_icache(ext2_filsys fs) { errcode_t retval; - + if (fs->icache) return 0; retval = ext2fs_get_mem(sizeof(struct ext2_inode_cache), &fs->icache); @@ -184,7 +184,7 @@ void ext2fs_close_inode_scan(ext2_inode_scan scan) { if (!scan || (scan->magic != EXT2_ET_MAGIC_INODE_SCAN)) return; - + ext2fs_free_mem(&scan->inode_buffer); scan->inode_buffer = NULL; ext2fs_free_mem(&scan->temp_buffer); @@ -202,7 +202,7 @@ void ext2fs_set_inode_callback(ext2_inode_scan scan, { if (!scan || (scan->magic != EXT2_ET_MAGIC_INODE_SCAN)) return; - + scan->done_group = done_group; scan->done_group_data = done_group_data; } @@ -358,7 +358,7 @@ static errcode_t get_next_blocks(ext2_inode_scan scan) if (retval) return retval; } - + if ((scan->scan_flags & EXT2_SF_BAD_INODE_BLK) || (scan->current_block == 0)) { memset(scan->inode_buffer, 0, @@ -390,7 +390,7 @@ static errcode_t get_next_blocks(ext2_inode_scan scan) static inline int is_empty_scan(ext2_inode_scan scan) { int i; - + if (scan->bytes_left == 0) return 0; @@ -406,7 +406,7 @@ errcode_t ext2fs_get_next_inode_full(ext2_inode_scan scan, ext2_ino_t *ino, { errcode_t retval; int extra_bytes = 0; - + EXT2_CHECK_MAGIC(scan, EXT2_ET_MAGIC_INODE_SCAN); /* @@ -430,7 +430,7 @@ errcode_t ext2fs_get_next_inode_full(ext2_inode_scan scan, ext2_ino_t *ino, return retval; } /* - * These checks are done outside the above if statement so + * These checks are done outside the above if statement so * they can be done for block group #0. */ if ((scan->scan_flags & EXT2_SF_DO_LAZY) && @@ -445,7 +445,7 @@ errcode_t ext2fs_get_next_inode_full(ext2_inode_scan scan, ext2_ino_t *ino, } else return EXT2_ET_MISSING_INODE_TABLE; } - + /* * Have we run out of space in the inode buffer? If so, we @@ -477,9 +477,9 @@ errcode_t ext2fs_get_next_inode_full(ext2_inode_scan scan, ext2_ino_t *ino, #ifdef WORDS_BIGENDIAN memset(inode, 0, bufsize); - ext2fs_swap_inode_full(scan->fs, + ext2fs_swap_inode_full(scan->fs, (struct ext2_inode_large *) inode, - (struct ext2_inode_large *) scan->temp_buffer, + (struct ext2_inode_large *) scan->temp_buffer, 0, bufsize); #else *inode = *((struct ext2_inode *) scan->temp_buffer); @@ -490,7 +490,7 @@ errcode_t ext2fs_get_next_inode_full(ext2_inode_scan scan, ext2_ino_t *ino, } else { #ifdef WORDS_BIGENDIAN memset(inode, 0, bufsize); - ext2fs_swap_inode_full(scan->fs, + ext2fs_swap_inode_full(scan->fs, (struct ext2_inode_large *) inode, (struct ext2_inode_large *) scan->ptr, 0, bufsize); @@ -568,7 +568,7 @@ errcode_t ext2fs_read_inode_full(ext2_filsys fs, ext2_ino_t ino, block = offset >> EXT2_BLOCK_SIZE_BITS(fs->super); if (!fs->group_desc[(unsigned)group].bg_inode_table) return EXT2_ET_MISSING_INODE_TABLE; - block_nr = fs->group_desc[(unsigned)group].bg_inode_table + + block_nr = fs->group_desc[(unsigned)group].bg_inode_table + block; io = fs->io; } @@ -602,8 +602,8 @@ errcode_t ext2fs_read_inode_full(ext2_filsys fs, ext2_ino_t ino, } #ifdef WORDS_BIGENDIAN - ext2fs_swap_inode_full(fs, (struct ext2_inode_large *) inode, - (struct ext2_inode_large *) inode, + ext2fs_swap_inode_full(fs, (struct ext2_inode_large *) inode, + (struct ext2_inode_large *) inode, 0, bufsize); #endif @@ -612,7 +612,7 @@ errcode_t ext2fs_read_inode_full(ext2_filsys fs, ext2_ino_t ino, fs->icache->cache_size; fs->icache->cache[fs->icache->cache_last].ino = ino; fs->icache->cache[fs->icache->cache_last].inode = *inode; - + return 0; } @@ -654,7 +654,7 @@ errcode_t ext2fs_write_inode_full(ext2_filsys fs, ext2_ino_t ino, if (retval) return retval; } - + if (!(fs->flags & EXT2_FLAG_RW)) return EXT2_ET_RO_FILSYS; @@ -674,8 +674,8 @@ errcode_t ext2fs_write_inode_full(ext2_filsys fs, ext2_ino_t ino, memset(w_inode, 0, length); #ifdef WORDS_BIGENDIAN - ext2fs_swap_inode_full(fs, w_inode, - (struct ext2_inode_large *) inode, + ext2fs_swap_inode_full(fs, w_inode, + (struct ext2_inode_large *) inode, 1, bufsize); #else memcpy(w_inode, inode, bufsize); @@ -712,11 +712,11 @@ errcode_t ext2fs_write_inode_full(ext2_filsys fs, ext2_ino_t ino, fs->icache->buffer_blk = block_nr; } - - memcpy((char *) fs->icache->buffer + (unsigned) offset, + + memcpy((char *) fs->icache->buffer + (unsigned) offset, ptr, clen); - retval = io_channel_write_blk(fs->io, block_nr, 1, + retval = io_channel_write_blk(fs->io, block_nr, 1, fs->icache->buffer); if (retval) goto errout; @@ -726,7 +726,7 @@ errcode_t ext2fs_write_inode_full(ext2_filsys fs, ext2_ino_t ino, length -= clen; block_nr++; } - + fs->flags |= EXT2_FLAG_CHANGED; errout: if (w_inode && w_inode != &temp_inode) @@ -741,7 +741,7 @@ errcode_t ext2fs_write_inode(ext2_filsys fs, ext2_ino_t ino, sizeof(struct ext2_inode)); } -/* +/* * This function should be called when writing a new inode. It makes * sure that extra part of large inodes is initialized properly. */ @@ -773,7 +773,7 @@ errcode_t ext2fs_write_new_inode(ext2_filsys fs, ext2_ino_t ino, *buf = *inode; large_inode = (struct ext2_inode_large *) buf; - large_inode->i_extra_isize = sizeof(struct ext2_inode_large) - + large_inode->i_extra_isize = sizeof(struct ext2_inode_large) - EXT2_GOOD_OLD_INODE_SIZE; if (!large_inode->i_crtime) large_inode->i_crtime = t; @@ -783,13 +783,13 @@ errcode_t ext2fs_write_new_inode(ext2_filsys fs, ext2_ino_t ino, return retval; } - + errcode_t ext2fs_get_blocks(ext2_filsys fs, ext2_ino_t ino, blk_t *blocks) { struct ext2_inode inode; int i; errcode_t retval; - + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); if (ino > fs->super->s_inodes_count) @@ -811,7 +811,7 @@ errcode_t ext2fs_check_directory(ext2_filsys fs, ext2_ino_t ino) { struct ext2_inode inode; errcode_t retval; - + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); if (ino > fs->super->s_inodes_count) diff --git a/lib/ext2fs/inode_io.c b/lib/ext2fs/inode_io.c index 0e234942..4d29a9f8 100644 --- a/lib/ext2fs/inode_io.c +++ b/lib/ext2fs/inode_io.c @@ -56,11 +56,11 @@ static errcode_t inode_write_blk(io_channel channel, unsigned long block, static errcode_t inode_flush(io_channel channel); static errcode_t inode_write_byte(io_channel channel, unsigned long offset, int size, const void *data); -static errcode_t inode_read_blk64(io_channel channel, +static errcode_t inode_read_blk64(io_channel channel, unsigned long long block, int count, void *data); -static errcode_t inode_write_blk64(io_channel channel, +static errcode_t inode_write_blk64(io_channel channel, unsigned long long block, int count, const void *data); - + static struct struct_io_manager struct_inode_manager = { EXT2_ET_MAGIC_IO_MANAGER, "Inode I/O Manager", @@ -158,7 +158,7 @@ static errcode_t inode_open(const char *name, int flags, io_channel *channel) &data->file); if (retval) goto cleanup; - + *channel = io; return 0; @@ -184,7 +184,7 @@ static errcode_t inode_close(io_channel channel) return 0; retval = ext2fs_file_close(data->file); - + ext2fs_free_mem(&channel->private_data); if (channel->name) ext2fs_free_mem(&channel->name); @@ -251,7 +251,7 @@ static errcode_t inode_write_blk64(io_channel channel, return ext2fs_file_write(data->file, buf, count, 0); } -static errcode_t inode_write_blk(io_channel channel, unsigned long block, +static errcode_t inode_write_blk(io_channel channel, unsigned long block, int count, const void *buf) { return inode_write_blk64(channel, block, count, buf); @@ -275,12 +275,12 @@ static errcode_t inode_write_byte(io_channel channel, unsigned long offset, } /* - * Flush data buffers to disk. + * Flush data buffers to disk. */ static errcode_t inode_flush(io_channel channel) { struct inode_private_data *data; - + EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL); data = (struct inode_private_data *) channel->private_data; EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_INODE_IO_CHANNEL); diff --git a/lib/ext2fs/io_manager.c b/lib/ext2fs/io_manager.c index 8d732530..6d0e2343 100644 --- a/lib/ext2fs/io_manager.c +++ b/lib/ext2fs/io_manager.c @@ -61,8 +61,8 @@ errcode_t io_channel_write_byte(io_channel channel, unsigned long offset, { EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL); - if (channel->manager->write_byte) - return channel->manager->write_byte(channel, offset, + if (channel->manager->write_byte) + return channel->manager->write_byte(channel, offset, count, data); return EXT2_ET_UNIMPLEMENTED; diff --git a/lib/ext2fs/irel.h b/lib/ext2fs/irel.h index 9b943ced..45e031be 100644 --- a/lib/ext2fs/irel.h +++ b/lib/ext2fs/irel.h @@ -1,6 +1,6 @@ /* * irel.h - * + * * Copyright (C) 1996, 1997 Theodore Ts'o. * * %Begin-Header% diff --git a/lib/ext2fs/irel_ma.c b/lib/ext2fs/irel_ma.c index c6fa828a..f565939a 100644 --- a/lib/ext2fs/irel_ma.c +++ b/lib/ext2fs/irel_ma.c @@ -1,6 +1,6 @@ /* * irel_ma.c - * + * * Copyright (C) 1996, 1997 Theodore Ts'o. * * %Begin-Header% @@ -77,18 +77,18 @@ errcode_t ext2fs_irel_memarray_create(char *name, ext2_ino_t max_inode, if (retval) goto errout; memset(irel, 0, sizeof(struct ext2_inode_relocation_table)); - + retval = ext2fs_get_mem(strlen(name)+1, &irel->name); if (retval) goto errout; strcpy(irel->name, name); - + retval = ext2fs_get_mem(sizeof(struct irel_ma), &ma); if (retval) goto errout; memset(ma, 0, sizeof(struct irel_ma)); irel->priv_data = ma; - + size = (size_t) (sizeof(ext2_ino_t) * (max_inode+1)); retval = ext2fs_get_array(max_inode+1, sizeof(ext2_ino_t), &ma->orig_map); @@ -127,7 +127,7 @@ errcode_t ext2fs_irel_memarray_create(char *name, ext2_ino_t max_inode, irel->move = ima_move; irel->delete = ima_delete; irel->free = ima_free; - + *new_irel = irel; return 0; @@ -156,7 +156,7 @@ static errcode_t ima_put(ext2_irel irel, ext2_ino_t old, ent->orig = old; else ent->orig = ma->entries[(unsigned) old].orig; - + /* * If max_refs has changed, reallocate the refs array */ @@ -245,12 +245,12 @@ static errcode_t ima_add_ref(ext2_irel irel, ext2_ino_t ino, ref_ent = ma->ref_entries + (unsigned) ino; ent = ma->entries + (unsigned) ino; - + /* * If the inode reference array doesn't exist, create it. */ if (ref_ent->refs == 0) { - size = (size_t) ((sizeof(struct ext2_inode_reference) * + size = (size_t) ((sizeof(struct ext2_inode_reference) * ent->max_refs)); retval = ext2fs_get_array(ent->max_refs, sizeof(struct ext2_inode_reference), &ref_ent->refs); @@ -288,7 +288,7 @@ static errcode_t ima_next_ref(ext2_irel irel, struct inode_reference_entry *ref_ent; ma = irel->priv_data; - + ref_ent = ma->ref_entries + ma->ref_current; if ((ref_ent->refs == NULL) || @@ -311,12 +311,12 @@ static errcode_t ima_move(ext2_irel irel, ext2_ino_t old, ext2_ino_t new) return EXT2_ET_INVALID_ARGUMENT; if (ma->entries[(unsigned) old].new == 0) return ENOENT; - + ma->entries[(unsigned) new] = ma->entries[(unsigned) old]; if (ma->ref_entries[(unsigned) new].refs) ext2fs_free_mem(&ma->ref_entries[(unsigned) new].refs); ma->ref_entries[(unsigned) new] = ma->ref_entries[(unsigned) old]; - + ma->entries[(unsigned) old].new = 0; ma->ref_entries[(unsigned) old].num = 0; ma->ref_entries[(unsigned) old].refs = 0; @@ -334,12 +334,12 @@ static errcode_t ima_delete(ext2_irel irel, ext2_ino_t old) return EXT2_ET_INVALID_ARGUMENT; if (ma->entries[(unsigned) old].new == 0) return ENOENT; - + ma->entries[old].new = 0; if (ma->ref_entries[(unsigned) old].refs) ext2fs_free_mem(&ma->ref_entries[(unsigned) old].refs); ma->orig_map[ma->entries[(unsigned) old].orig] = 0; - + ma->ref_entries[(unsigned) old].num = 0; ma->ref_entries[(unsigned) old].refs = 0; return 0; diff --git a/lib/ext2fs/ismounted.c b/lib/ext2fs/ismounted.c index d6573ad2..4a7c8c69 100644 --- a/lib/ext2fs/ismounted.c +++ b/lib/ext2fs/ismounted.c @@ -1,6 +1,6 @@ /* * ismounted.c --- Check to see if the filesystem was mounted - * + * * Copyright (C) 1995,1996,1997,1998,1999,2000 Theodore Ts'o. * * %Begin-Header% @@ -38,9 +38,9 @@ /* * Helper function which checks a file in /etc/mtab format to see if a * filesystem is mounted. Returns an error if the file doesn't exist - * or can't be opened. + * or can't be opened. */ -static errcode_t check_mntent_file(const char *mtab_file, const char *file, +static errcode_t check_mntent_file(const char *mtab_file, const char *file, int *mount_flags, char *mtpt, int mtlen) { struct mntent *mnt; @@ -103,7 +103,7 @@ static errcode_t check_mntent_file(const char *mtab_file, const char *file, } #ifndef __GNU__ /* The GNU hurd is deficient; what else is new? */ /* Validate the entry in case /etc/mtab is out of date */ - /* + /* * We need to be paranoid, because some broken distributions * (read: Slackware) don't initialize /etc/mtab before checking * all of the non-root filesystems on the disk. @@ -128,7 +128,7 @@ static errcode_t check_mntent_file(const char *mtab_file, const char *file, } #endif /* __GNU__ */ *mount_flags = EXT2_MF_MOUNTED; - + #ifdef MNTOPT_RO /* Check to see if the ro option is set */ if (hasmntopt(mnt, MNTOPT_RO)) @@ -145,7 +145,7 @@ static errcode_t check_mntent_file(const char *mtab_file, const char *file, */ if (!strcmp(mnt->mnt_dir, "/")) { is_root: -#define TEST_FILE "/.ismount-test-file" +#define TEST_FILE "/.ismount-test-file" *mount_flags |= EXT2_MF_ISROOT; fd = open(TEST_FILE, O_RDWR|O_CREAT, 0600); if (fd < 0) { @@ -184,7 +184,7 @@ static errcode_t check_mntent(const char *file, int *mount_flags, #endif /* MOUNTED */ retval = check_mntent_file(MOUNTED, file, mount_flags, mtpt, mtlen); return retval; -#else +#else *mount_flags = 0; return 0; #endif /* defined(MOUNTED) || defined(_PATH_MOUNTED) */ @@ -209,7 +209,7 @@ static errcode_t check_getmntinfo(const char *file, int *mount_flags, s1 = file; if (strncmp(_PATH_DEV, s1, len) == 0) s1 += len; - + *mount_flags = 0; while (--n >= 0) { s2 = mp->f_mntfromname; @@ -299,7 +299,7 @@ errcode_t ext2fs_check_mount_point(const char *device, int *mount_flags, } else { #ifdef HAVE_MNTENT_H retval = check_mntent(device, mount_flags, mtpt, mtlen); -#else +#else #ifdef HAVE_GETMNTINFO retval = check_getmntinfo(device, mount_flags, mtpt, mtlen); #else @@ -331,7 +331,7 @@ errcode_t ext2fs_check_mount_point(const char *device, int *mount_flags, /* * ext2fs_check_if_mounted() sets the mount_flags EXT2_MF_MOUNTED, * EXT2_MF_READONLY, and EXT2_MF_ROOT - * + * */ errcode_t ext2fs_check_if_mounted(const char *file, int *mount_flags) { @@ -343,7 +343,7 @@ int main(int argc, char **argv) { int retval, mount_flags; char mntpt[80]; - + if (argc < 2) { fprintf(stderr, "Usage: %s device\n", argv[0]); exit(1); diff --git a/lib/ext2fs/jfs_dat.h b/lib/ext2fs/jfs_dat.h index d6ad9c48..62778c62 100644 --- a/lib/ext2fs/jfs_dat.h +++ b/lib/ext2fs/jfs_dat.h @@ -9,7 +9,7 @@ * On-disk structures */ -/* +/* * Descriptor block types: */ @@ -28,8 +28,8 @@ typedef struct journal_header_s } journal_header_t; -/* - * The block tag: used to describe a single buffer in the journal +/* + * The block tag: used to describe a single buffer in the journal */ typedef struct journal_block_tag_s { @@ -55,10 +55,10 @@ typedef struct journal_superblock_s __u32 s_blocksize; /* journal device blocksize */ __u32 s_maxlen; /* total blocks in journal file */ __u32 s_first; /* first block of log information */ - + /* Dynamic information describing the current state of the log */ __u32 s_sequence; /* first commit ID expected in log */ __u32 s_start; /* blocknr of start of log */ - + } journal_superblock_t; diff --git a/lib/ext2fs/kernel-jbd.h b/lib/ext2fs/kernel-jbd.h index 158d7641..331b0e47 100644 --- a/lib/ext2fs/kernel-jbd.h +++ b/lib/ext2fs/kernel-jbd.h @@ -1,6 +1,6 @@ /* * linux/include/linux/jbd.h - * + * * Written by Stephen C. Tweedie <sct@redhat.com> * * Copyright 1998-2000 Red Hat, Inc --- All Rights Reserved @@ -59,7 +59,7 @@ extern int journal_enable_debug; #define jbd_debug(f, a...) /**/ #else #define jbd_debug(f, ...) /**/ -#endif +#endif #endif #else #define jbd_debug(x) /* AIX doesn't do STDC */ @@ -88,7 +88,7 @@ typedef struct journal_s journal_t; /* Journal control structure */ * On-disk structures */ -/* +/* * Descriptor block types: */ @@ -133,8 +133,8 @@ struct commit_header { __u32 h_commit_nsec; }; -/* - * The block tag: used to describe a single buffer in the journal +/* + * The block tag: used to describe a single buffer in the journal */ typedef struct journal_block_tag_s { @@ -146,9 +146,9 @@ typedef struct journal_block_tag_s #define JBD_TAG_SIZE64 (sizeof(journal_block_tag_t)) #define JBD_TAG_SIZE32 (8) -/* +/* * The revoke descriptor: used on disk to describe a series of blocks to - * be revoked from the log + * be revoked from the log */ typedef struct journal_revoke_header_s { @@ -177,7 +177,7 @@ typedef struct journal_superblock_s __u32 s_blocksize; /* journal device blocksize */ __u32 s_maxlen; /* total blocks in journal file */ __u32 s_first; /* first block of log information */ - + /* 0x0018 */ /* Dynamic information describing the current state of the log */ __u32 s_sequence; /* first commit ID expected in log */ @@ -197,9 +197,9 @@ typedef struct journal_superblock_s /* 0x0040 */ __u32 s_nr_users; /* Nr of filesystems sharing log */ - + __u32 s_dynsuper; /* Blocknr of dynamic superblock copy*/ - + /* 0x0048 */ __u32 s_max_transaction; /* Limit of journal blocks per trans.*/ __u32 s_max_trans_data; /* Limit of data blocks per trans. */ @@ -311,7 +311,7 @@ struct jbd_revoke_table_s; * the transaction, so that at all times we know how many buffers the * outstanding updates on a transaction might possibly touch. */ -struct handle_s +struct handle_s { /* Which compound transaction is this update a part of? */ transaction_t * h_transaction; @@ -349,14 +349,14 @@ struct handle_s * flushed to home for finished transactions. */ -struct transaction_s +struct transaction_s { /* Pointer to the journal for this transaction. */ journal_t * t_journal; - + /* Sequence number for this transaction */ tid_t t_tid; - + /* Transaction's current state */ enum { T_RUNNING, @@ -364,74 +364,74 @@ struct transaction_s T_RUNDOWN, T_FLUSH, T_COMMIT, - T_FINISHED + T_FINISHED } t_state; /* Where in the log does this transaction's commit start? */ unsigned long t_log_start; - + /* Doubly-linked circular list of all inodes owned by this transaction */ /* AKPM: unused */ struct inode * t_ilist; - + /* Number of buffers on the t_buffers list */ int t_nr_buffers; - + /* Doubly-linked circular list of all buffers reserved but not yet modified by this transaction */ struct journal_head * t_reserved_list; - + /* Doubly-linked circular list of all metadata buffers owned by this transaction */ struct journal_head * t_buffers; - + /* * Doubly-linked circular list of all data buffers still to be * flushed before this transaction can be committed. * Protected by journal_datalist_lock. */ struct journal_head * t_sync_datalist; - + /* * Doubly-linked circular list of all writepage data buffers * still to be written before this transaction can be committed. * Protected by journal_datalist_lock. */ struct journal_head * t_async_datalist; - + /* Doubly-linked circular list of all forget buffers (superceded buffers which we can un-checkpoint once this transaction commits) */ struct journal_head * t_forget; - + /* * Doubly-linked circular list of all buffers still to be * flushed before this transaction can be checkpointed. */ /* Protected by journal_datalist_lock */ struct journal_head * t_checkpoint_list; - + /* Doubly-linked circular list of temporary buffers currently undergoing IO in the log */ struct journal_head * t_iobuf_list; - + /* Doubly-linked circular list of metadata buffers being shadowed by log IO. The IO buffers on the iobuf list and the shadow buffers on this list match each other one for one at all times. */ struct journal_head * t_shadow_list; - + /* Doubly-linked circular list of control buffers being written to the log. */ struct journal_head * t_log_list; - + /* Number of outstanding updates running on this transaction */ int t_updates; /* Number of buffers reserved for use by all handles in this * transaction handle but not yet modified. */ int t_outstanding_credits; - + /* * Forward and backward links for the circular list of all * transactions awaiting checkpoint. @@ -450,7 +450,7 @@ struct transaction_s /* The journal_t maintains all of the journaling state information for a * single filesystem. It is linked to from the fs superblock structure. - * + * * We use the journal_t to keep track of all outstanding transaction * activity on the filesystem, and to manage the state of the log * writing process. */ @@ -463,7 +463,7 @@ struct journal_s /* Is there an outstanding uncleared error on the journal (from * a prior abort)? */ int j_errno; - + /* The superblock buffer */ struct buffer_head * j_sb_buffer; journal_superblock_t * j_superblock; @@ -473,16 +473,16 @@ struct journal_s /* Number of processes waiting to create a barrier lock */ int j_barrier_count; - + /* The barrier lock itself */ struct semaphore j_barrier; - + /* Transactions: The current running transaction... */ transaction_t * j_running_transaction; - + /* ... the transaction we are pushing to disk ... */ transaction_t * j_committing_transaction; - + /* ... and a linked circular list of all transactions waiting * for checkpointing. */ /* Protected by journal_datalist_lock */ @@ -491,19 +491,19 @@ struct journal_s /* Wait queue for waiting for a locked transaction to start committing, or for a barrier lock to be released */ wait_queue_head_t j_wait_transaction_locked; - + /* Wait queue for waiting for checkpointing to complete */ wait_queue_head_t j_wait_logspace; - + /* Wait queue for waiting for commit to complete */ wait_queue_head_t j_wait_done_commit; - + /* Wait queue to trigger checkpointing */ wait_queue_head_t j_wait_checkpoint; - + /* Wait queue to trigger commit */ wait_queue_head_t j_wait_commit; - + /* Wait queue to wait for updates to complete */ wait_queue_head_t j_wait_updates; @@ -512,10 +512,10 @@ struct journal_s /* The main journal lock, used by lock_journal() */ struct semaphore j_sem; - + /* Journal head: identifies the first unused block in the journal. */ unsigned long j_head; - + /* Journal tail: identifies the oldest still-used block in the * journal. */ unsigned long j_tail; @@ -588,8 +588,8 @@ struct journal_s unsigned int j_failed_commit; }; -/* - * Journal flag definitions +/* + * Journal flag definitions */ #define JFS_UNMOUNT 0x001 /* Journal thread is being destroyed */ #define JFS_ABORT 0x002 /* Journaling has been aborted for errors. */ @@ -597,7 +597,7 @@ struct journal_s #define JFS_FLUSHED 0x008 /* The journal superblock has been flushed */ #define JFS_LOADED 0x010 /* The journal superblock has been loaded */ -/* +/* * Function declarations for the journaling transaction and buffer * management */ @@ -627,7 +627,7 @@ extern void journal_insert_checkpoint(struct journal_head *, transaction_t *); extern void __journal_insert_checkpoint(struct journal_head *,transaction_t *); /* Buffer IO */ -extern int +extern int journal_write_metadata_buffer(transaction_t *transaction, struct journal_head *jh_in, struct journal_head **jh_out, @@ -641,7 +641,7 @@ extern void __wait_on_journal (journal_t *); * * We need to lock the journal during transaction state changes so that * nobody ever tries to take a handle on the running transaction while - * we are in the middle of moving it to the commit phase. + * we are in the middle of moving it to the commit phase. * * Note that the locking is completely interrupt unsafe. We never touch * journal structures from interrupts. @@ -675,7 +675,7 @@ static inline handle_t *journal_current_handle(void) /* The journaling code user interface: * * Create and destroy handles - * Register buffer modifications against the current transaction. + * Register buffer modifications against the current transaction. */ extern handle_t *journal_start(journal_t *, int nblocks); @@ -703,11 +703,11 @@ extern journal_t * journal_init_dev(kdev_t dev, kdev_t fs_dev, int start, int len, int bsize); extern journal_t * journal_init_inode (struct inode *); extern int journal_update_format (journal_t *); -extern int journal_check_used_features +extern int journal_check_used_features (journal_t *, unsigned long, unsigned long, unsigned long); -extern int journal_check_available_features +extern int journal_check_available_features (journal_t *, unsigned long, unsigned long, unsigned long); -extern int journal_set_features +extern int journal_set_features (journal_t *, unsigned long, unsigned long, unsigned long); extern int journal_create (journal_t *); extern int journal_load (journal_t *journal); @@ -785,7 +785,7 @@ do { \ * bit, when set, indicates that we have had a fatal error somewhere, * either inside the journaling layer or indicated to us by the client * (eg. ext3), and that we and should not commit any further - * transactions. + * transactions. */ static inline int is_journal_aborted(journal_t *journal) @@ -867,7 +867,7 @@ extern int journal_blocks_per_page(struct inode *inode); #define BJ_LogCtl 7 /* Buffer contains log descriptors */ #define BJ_Reserved 8 /* Buffer is reserved for access by journal */ #define BJ_Types 9 - + extern int jbd_blocks_per_page(struct inode *inode); #ifdef __KERNEL__ diff --git a/lib/ext2fs/kernel-list.h b/lib/ext2fs/kernel-list.h index 24e6ab4a..e07d06b6 100644 --- a/lib/ext2fs/kernel-list.h +++ b/lib/ext2fs/kernel-list.h @@ -29,7 +29,7 @@ struct list_head { #endif /* - * Insert a new entry between two known consecutive entries. + * Insert a new entry between two known consecutive entries. * * This is only for internal list manipulation where we know * the prev/next entries already! diff --git a/lib/ext2fs/link.c b/lib/ext2fs/link.c index b2834889..5ed63942 100644 --- a/lib/ext2fs/link.c +++ b/lib/ext2fs/link.c @@ -1,6 +1,6 @@ /* * link.c --- create links in a ext2fs directory - * + * * Copyright (C) 1993, 1994 Theodore Ts'o. * * %Begin-Header% @@ -26,7 +26,7 @@ struct link_struct { int done; unsigned int blocksize; struct ext2_super_block *sb; -}; +}; static int link_proc(struct ext2_dir_entry *dirent, int offset, @@ -99,7 +99,7 @@ static int link_proc(struct ext2_dir_entry *dirent, #ifdef __TURBOC__ #pragma argsused #endif -errcode_t ext2fs_link(ext2_filsys fs, ext2_ino_t dir, const char *name, +errcode_t ext2fs_link(ext2_filsys fs, ext2_ino_t dir, const char *name, ext2_ino_t ino, int flags) { errcode_t retval; diff --git a/lib/ext2fs/llseek.c b/lib/ext2fs/llseek.c index 5a5e560b..073cf91a 100644 --- a/lib/ext2fs/llseek.c +++ b/lib/ext2fs/llseek.c @@ -74,7 +74,7 @@ static ext2_loff_t my_llseek (int fd, ext2_loff_t offset, int origin) #ifndef __i386__ retval = _llseek(fd, ((unsigned long long) offset) >> 32, -#else +#else retval = syscall(__NR__llseek, fd, (unsigned long long) (offset >> 32), #endif ((unsigned long long) offset) & 0xffffffff, @@ -100,7 +100,7 @@ ext2_loff_t ext2fs_llseek (int fd, ext2_loff_t offset, int origin) errno = EINVAL; return -1; } - + result = my_llseek (fd, offset, origin); if (result == -1 && errno == ENOSYS) { /* diff --git a/lib/ext2fs/lookup.c b/lib/ext2fs/lookup.c index 1745f33a..9cb97f1b 100644 --- a/lib/ext2fs/lookup.c +++ b/lib/ext2fs/lookup.c @@ -1,6 +1,6 @@ /* * lookup.c --- ext2fs directory lookup operations - * + * * Copyright (C) 1993, 1994, 1994, 1995 Theodore Ts'o. * * %Begin-Header% @@ -23,7 +23,7 @@ struct lookup_struct { int len; ext2_ino_t *inode; int found; -}; +}; #ifdef __TURBOC__ #pragma argsused diff --git a/lib/ext2fs/mkdir.c b/lib/ext2fs/mkdir.c index e769ed50..88bc6fa2 100644 --- a/lib/ext2fs/mkdir.c +++ b/lib/ext2fs/mkdir.c @@ -1,6 +1,6 @@ /* * mkdir.c --- make a directory in the filesystem - * + * * Copyright (C) 1994, 1995 Theodore Ts'o. * * %Begin-Header% @@ -93,7 +93,7 @@ errcode_t ext2fs_mkdir(ext2_filsys fs, ext2_ino_t parent, ext2_ino_t inum, retval = ext2fs_write_dir_block(fs, blk, block); if (retval) goto cleanup; - retval = ext2fs_write_new_inode(fs, ino, &inode); + retval = ext2fs_write_new_inode(fs, ino, &inode); if (retval) goto cleanup; @@ -124,7 +124,7 @@ errcode_t ext2fs_mkdir(ext2_filsys fs, ext2_ino_t parent, ext2_ino_t inum, if (retval) goto cleanup; } - + /* * Update accounting.... */ diff --git a/lib/ext2fs/mkjournal.c b/lib/ext2fs/mkjournal.c index c112be9b..96b574eb 100644 --- a/lib/ext2fs/mkjournal.c +++ b/lib/ext2fs/mkjournal.c @@ -2,7 +2,7 @@ * mkjournal.c --- make a journal for a filesystem * * Copyright (C) 2000 Theodore Ts'o. - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. @@ -215,7 +215,7 @@ static int mkjournal_proc(ext2_filsys fs, struct mkjournal_struct *es = (struct mkjournal_struct *) priv_data; blk_t new_blk; errcode_t retval; - + if (*blocknr) { es->goal = *blocknr; return 0; @@ -265,7 +265,7 @@ static int mkjournal_proc(ext2_filsys fs, return (BLOCK_CHANGED | BLOCK_ABORT); else return BLOCK_CHANGED; - + } /* @@ -282,7 +282,7 @@ static errcode_t write_journal_inode(ext2_filsys fs, ext2_ino_t journal_ino, if ((retval = ext2fs_create_journal_superblock(fs, size, flags, &buf))) return retval; - + if ((retval = ext2fs_read_bitmaps(fs))) return retval; @@ -309,7 +309,7 @@ static errcode_t write_journal_inode(ext2_filsys fs, ext2_ino_t journal_ino, * the filesystem. Pick a group that has the largest number * of free blocks. */ - group = ext2fs_group_of_blk(fs, (fs->super->s_blocks_count - + group = ext2fs_group_of_blk(fs, (fs->super->s_blocks_count - fs->super->s_first_data_block) / 2); start = (group > 0) ? group-1 : group; end = ((group+1) < fs->group_desc_count) ? group+1 : group; @@ -393,7 +393,7 @@ errcode_t ext2fs_add_journal_device(ext2_filsys fs, ext2_filsys journal_dev) /* Make sure the device exists and is a block device */ if (stat(journal_dev->device_name, &st) < 0) return errno; - + if (!S_ISBLK(st.st_mode)) return EXT2_ET_JOURNAL_NOT_BLOCK; /* Must be a block device */ @@ -428,7 +428,7 @@ errcode_t ext2fs_add_journal_device(ext2_filsys fs, ext2_filsys journal_dev) /* Writeback the journal superblock */ if ((retval = io_channel_write_blk(journal_dev->io, start, -1024, buf))) return retval; - + fs->super->s_journal_inum = 0; fs->super->s_journal_dev = st.st_rdev; memcpy(fs->super->s_journal_uuid, jsb->s_uuid, @@ -460,7 +460,7 @@ errcode_t ext2fs_add_journal_inode(ext2_filsys fs, blk_t size, int flags) strcat(jfile, "/.journal"); /* - * If .../.journal already exists, make sure any + * If .../.journal already exists, make sure any * immutable or append-only flags are cleared. */ #if defined(HAVE_CHFLAGS) && defined(UF_NODUMP) @@ -482,7 +482,7 @@ errcode_t ext2fs_add_journal_inode(ext2_filsys fs, blk_t size, int flags) if ((retval = write_journal_file(fs, jfile, size, flags))) goto errout; - + /* Get inode number of the journal file */ if (fstat(fd, &st) < 0) goto errout; @@ -497,7 +497,7 @@ errcode_t ext2fs_add_journal_inode(ext2_filsys fs, blk_t size, int flags) #endif if (retval) goto errout; - + close(fd); journal_ino = st.st_ino; } else { @@ -511,7 +511,7 @@ errcode_t ext2fs_add_journal_inode(ext2_filsys fs, blk_t size, int flags) size, flags))) return retval; } - + fs->super->s_journal_inum = journal_ino; fs->super->s_journal_dev = 0; memset(fs->super->s_journal_uuid, 0, @@ -538,7 +538,7 @@ main(int argc, char **argv) exit(1); } device_name = argv[1]; - + retval = ext2fs_open (device_name, EXT2_FLAG_RW, 0, 0, unix_io_manager, &fs); if (retval) { @@ -558,6 +558,6 @@ main(int argc, char **argv) } ext2fs_close(fs); exit(0); - + } #endif diff --git a/lib/ext2fs/namei.c b/lib/ext2fs/namei.c index c380939d..2b28a54f 100644 --- a/lib/ext2fs/namei.c +++ b/lib/ext2fs/namei.c @@ -1,6 +1,6 @@ /* * namei.c --- ext2fs directory lookup operations - * + * * Copyright (C) 1993, 1994, 1994, 1995 Theodore Ts'o. * * %Begin-Header% @@ -36,7 +36,7 @@ static errcode_t follow_link(ext2_filsys fs, ext2_ino_t root, ext2_ino_t dir, #ifdef NAMEI_DEBUG printf("follow_link: root=%lu, dir=%lu, inode=%lu, lc=%d\n", root, dir, inode, link_count); - + #endif retval = ext2fs_read_inode (fs, inode, &ei); if (retval) return retval; @@ -152,13 +152,13 @@ errcode_t ext2fs_namei(ext2_filsys fs, ext2_ino_t root, ext2_ino_t cwd, { char *buf; errcode_t retval; - + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); retval = ext2fs_get_mem(fs->blocksize, &buf); if (retval) return retval; - + retval = open_namei(fs, root, cwd, name, strlen(name), 0, 0, buf, inode); @@ -171,13 +171,13 @@ errcode_t ext2fs_namei_follow(ext2_filsys fs, ext2_ino_t root, ext2_ino_t cwd, { char *buf; errcode_t retval; - + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); retval = ext2fs_get_mem(fs->blocksize, &buf); if (retval) return retval; - + retval = open_namei(fs, root, cwd, name, strlen(name), 1, 0, buf, inode); @@ -190,7 +190,7 @@ errcode_t ext2fs_follow_link(ext2_filsys fs, ext2_ino_t root, ext2_ino_t cwd, { char *buf; errcode_t retval; - + EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); retval = ext2fs_get_mem(fs->blocksize, &buf); diff --git a/lib/ext2fs/native.c b/lib/ext2fs/native.c index 85d09896..738c34bd 100644 --- a/lib/ext2fs/native.c +++ b/lib/ext2fs/native.c @@ -1,8 +1,8 @@ /* * native.c --- returns the ext2_flag for a native byte order - * + * * Copyright (C) 1996 Theodore Ts'o. - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. @@ -23,5 +23,5 @@ int ext2fs_native_flag(void) #endif } - - + + diff --git a/lib/ext2fs/newdir.c b/lib/ext2fs/newdir.c index c2ca9034..4e7b40d6 100644 --- a/lib/ext2fs/newdir.c +++ b/lib/ext2fs/newdir.c @@ -1,6 +1,6 @@ /* * newdir.c --- create a new directory block - * + * * Copyright (C) 1994, 1995 Theodore Ts'o. * * %Begin-Header% @@ -65,7 +65,7 @@ errcode_t ext2fs_new_dir_block(ext2_filsys fs, ext2_ino_t dir_ino, dir->name_len = 2 | filetype; dir->name[0] = '.'; dir->name[1] = '.'; - + } *block = buf; return 0; diff --git a/lib/ext2fs/openfs.c b/lib/ext2fs/openfs.c index 525693ec..841aa34b 100644 --- a/lib/ext2fs/openfs.c +++ b/lib/ext2fs/openfs.c @@ -1,8 +1,8 @@ /* * openfs.c --- open an ext2 filesystem - * + * * Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o. - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. @@ -59,10 +59,10 @@ blk_t ext2fs_descriptor_block_loc(ext2_filsys fs, blk_t group_block, dgrp_t i) } errcode_t ext2fs_open(const char *name, int flags, int superblock, - unsigned int block_size, io_manager manager, + unsigned int block_size, io_manager manager, ext2_filsys *ret_fs) { - return ext2fs_open2(name, 0, flags, superblock, block_size, + return ext2fs_open2(name, 0, flags, superblock, block_size, manager, ret_fs); } @@ -71,7 +71,7 @@ errcode_t ext2fs_open(const char *name, int flags, int superblock, * Superblock and block_size can be zero to use the default size. * * Valid flags for ext2fs_open() - * + * * EXT2_FLAG_RW - Open the filesystem for read/write. * EXT2_FLAG_FORCE - Open the filesystem even if some of the * features aren't supported. @@ -79,7 +79,7 @@ errcode_t ext2fs_open(const char *name, int flags, int superblock, */ errcode_t ext2fs_open2(const char *name, const char *io_options, int flags, int superblock, - unsigned int block_size, io_manager manager, + unsigned int block_size, io_manager manager, ext2_filsys *ret_fs) { ext2_filsys fs; @@ -93,13 +93,13 @@ errcode_t ext2fs_open2(const char *name, const char *io_options, struct ext2_group_desc *gdp; int j; #endif - + EXT2_CHECK_MAGIC(manager, EXT2_ET_MAGIC_IO_MANAGER); retval = ext2fs_get_mem(sizeof(struct struct_ext2_filsys), &fs); if (retval) return retval; - + memset(fs, 0, sizeof(struct struct_ext2_filsys)); fs->magic = EXT2_ET_MAGIC_EXT2FS_FILSYS; fs->flags = flags; @@ -115,7 +115,7 @@ errcode_t ext2fs_open2(const char *name, const char *io_options, *cp++ = 0; io_options = cp; } - + io_flags = 0; if (flags & EXT2_FLAG_RW) io_flags |= IO_FLAG_RW; @@ -124,7 +124,7 @@ errcode_t ext2fs_open2(const char *name, const char *io_options, retval = manager->open(fs->device_name, io_flags, &fs->io); if (retval) goto cleanup; - if (io_options && + if (io_options && (retval = io_channel_set_options(fs->io, io_options))) goto cleanup; fs->image_io = fs->io; @@ -189,7 +189,7 @@ errcode_t ext2fs_open2(const char *name, const char *io_options, goto cleanup; } #endif - + if (fs->super->s_magic != EXT2_SUPER_MAGIC) { retval = EXT2_ET_BAD_MAGIC; goto cleanup; @@ -231,7 +231,7 @@ errcode_t ext2fs_open2(const char *name, const char *io_options, goto cleanup; } } - + if ((fs->super->s_log_block_size + EXT2_MIN_BLOCK_LOG_SIZE) > EXT2_MAX_BLOCK_LOG_SIZE) { retval = EXT2_ET_CORRUPT_SUPERBLOCK; @@ -268,7 +268,7 @@ errcode_t ext2fs_open2(const char *name, const char *io_options, *ret_fs = fs; return 0; } - + /* * Read group descriptors */ @@ -336,7 +336,7 @@ cleanup: /* * Set/get the filesystem data I/O channel. - * + * * These functions are only valid if EXT2_FLAG_IMAGE_FILE is true. */ errcode_t ext2fs_get_data_io(ext2_filsys fs, io_channel *old_io) @@ -362,7 +362,7 @@ errcode_t ext2fs_rewrite_to_io(ext2_filsys fs, io_channel new_io) if ((fs->flags & EXT2_FLAG_IMAGE_FILE) == 0) return EXT2_ET_NOT_IMAGE_FILE; fs->io = fs->image_io = new_io; - fs->flags |= EXT2_FLAG_DIRTY | EXT2_FLAG_RW | + fs->flags |= EXT2_FLAG_DIRTY | EXT2_FLAG_RW | EXT2_FLAG_BB_DIRTY | EXT2_FLAG_IB_DIRTY; fs->flags &= ~EXT2_FLAG_IMAGE_FILE; return 0; diff --git a/lib/ext2fs/read_bb.c b/lib/ext2fs/read_bb.c index 875be9fc..112d07fb 100644 --- a/lib/ext2fs/read_bb.c +++ b/lib/ext2fs/read_bb.c @@ -38,16 +38,16 @@ struct read_bb_record { #pragma argsused #endif static int mark_bad_block(ext2_filsys fs, blk_t *block_nr, - e2_blkcnt_t blockcnt EXT2FS_ATTR((unused)), + e2_blkcnt_t blockcnt EXT2FS_ATTR((unused)), blk_t ref_block EXT2FS_ATTR((unused)), - int ref_offset EXT2FS_ATTR((unused)), + int ref_offset EXT2FS_ATTR((unused)), void *priv_data) { struct read_bb_record *rb = (struct read_bb_record *) priv_data; - + if (blockcnt < 0) return 0; - + if ((*block_nr < fs->super->s_first_data_block) || (*block_nr >= fs->super->s_blocks_count)) return 0; /* Ignore illegal blocks */ diff --git a/lib/ext2fs/read_bb_file.c b/lib/ext2fs/read_bb_file.c index 2ac71f46..60dec426 100644 --- a/lib/ext2fs/read_bb_file.c +++ b/lib/ext2fs/read_bb_file.c @@ -29,7 +29,7 @@ /* * Reads a list of bad blocks from a FILE * */ -errcode_t ext2fs_read_bb_FILE2(ext2_filsys fs, FILE *f, +errcode_t ext2fs_read_bb_FILE2(ext2_filsys fs, FILE *f, ext2_badblocks_list *bb_list, void *priv_data, void (*invalid)(ext2_filsys fs, @@ -76,7 +76,7 @@ struct compat_struct { }; static void call_compat_invalid(ext2_filsys fs, blk_t blk, - char *badstr EXT2FS_ATTR((unused)), + char *badstr EXT2FS_ATTR((unused)), void *priv_data) { struct compat_struct *st; @@ -90,7 +90,7 @@ static void call_compat_invalid(ext2_filsys fs, blk_t blk, /* * Reads a list of bad blocks from a FILE * */ -errcode_t ext2fs_read_bb_FILE(ext2_filsys fs, FILE *f, +errcode_t ext2fs_read_bb_FILE(ext2_filsys fs, FILE *f, ext2_badblocks_list *bb_list, void (*invalid)(ext2_filsys fs, blk_t blk)) { diff --git a/lib/ext2fs/res_gdt.c b/lib/ext2fs/res_gdt.c index 848a02a2..dda7c2b4 100644 --- a/lib/ext2fs/res_gdt.c +++ b/lib/ext2fs/res_gdt.c @@ -92,7 +92,7 @@ errcode_t ext2fs_create_resize_inode(ext2_filsys fs) goto out_inode; } else { blk_t goal = sb->s_first_data_block + fs->desc_blocks + - sb->s_reserved_gdt_blocks + 2 + + sb->s_reserved_gdt_blocks + 2 + fs->inode_blocks_per_group; retval = ext2fs_alloc_block(fs, goal, 0, &dindir_blk); diff --git a/lib/ext2fs/rw_bitmaps.c b/lib/ext2fs/rw_bitmaps.c index d4e94da6..341f834a 100644 --- a/lib/ext2fs/rw_bitmaps.c +++ b/lib/ext2fs/rw_bitmaps.c @@ -58,7 +58,7 @@ static errcode_t write_bitmaps(ext2_filsys fs, int do_inode, int do_block) memset(block_buf, 0xff, fs->blocksize); } if (do_inode) { - inode_nbytes = (size_t) + inode_nbytes = (size_t) ((EXT2_INODES_PER_GROUP(fs->super)+7) / 8); retval = ext2fs_get_mem(fs->blocksize, &inode_buf); if (retval) @@ -71,10 +71,10 @@ static errcode_t write_bitmaps(ext2_filsys fs, int do_inode, int do_block) goto skip_block_bitmap; if (csum_flag && fs->group_desc[i].bg_flags & - EXT2_BG_BLOCK_UNINIT) + EXT2_BG_BLOCK_UNINIT) goto skip_this_block_bitmap; - - retval = ext2fs_get_block_bitmap_range(fs->block_map, + + retval = ext2fs_get_block_bitmap_range(fs->block_map, blk_itr, block_nbytes << 3, block_buf); if (retval) return retval; @@ -103,10 +103,10 @@ static errcode_t write_bitmaps(ext2_filsys fs, int do_inode, int do_block) continue; if (csum_flag && fs->group_desc[i].bg_flags & - EXT2_BG_INODE_UNINIT) + EXT2_BG_INODE_UNINIT) goto skip_this_inode_bitmap; - - retval = ext2fs_get_inode_bitmap_range(fs->inode_map, + + retval = ext2fs_get_inode_bitmap_range(fs->inode_map, ino_itr, inode_nbytes << 3, inode_buf); if (retval) return retval; @@ -169,7 +169,7 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block) retval = ext2fs_allocate_block_bitmap(fs, buf, &fs->block_map); if (retval) goto cleanup; - retval = ext2fs_get_mem(do_image ? fs->blocksize : + retval = ext2fs_get_mem(do_image ? fs->blocksize : (unsigned) block_nbytes, &block_bitmap); if (retval) goto cleanup; @@ -183,7 +183,7 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block) retval = ext2fs_allocate_inode_bitmap(fs, buf, &fs->inode_map); if (retval) goto cleanup; - retval = ext2fs_get_mem(do_image ? fs->blocksize : + retval = ext2fs_get_mem(do_image ? fs->blocksize : (unsigned) inode_nbytes, &inode_bitmap); if (retval) goto cleanup; @@ -202,7 +202,7 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block) cnt = fs->blocksize << 3; if (cnt > ino_cnt) cnt = ino_cnt; - retval = ext2fs_set_inode_bitmap_range(fs->inode_map, + retval = ext2fs_set_inode_bitmap_range(fs->inode_map, ino_itr, cnt, inode_bitmap); if (retval) goto cleanup; @@ -212,7 +212,7 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block) } blk = (fs->image_header->offset_blockmap / fs->blocksize); - blk_cnt = EXT2_BLOCKS_PER_GROUP(fs->super) * + blk_cnt = EXT2_BLOCKS_PER_GROUP(fs->super) * fs->group_desc_count; while (block_nbytes > 0) { retval = io_channel_read_blk(fs->image_io, blk++, @@ -222,7 +222,7 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block) cnt = fs->blocksize << 3; if (cnt > blk_cnt) cnt = blk_cnt; - retval = ext2fs_set_block_bitmap_range(fs->block_map, + retval = ext2fs_set_block_bitmap_range(fs->block_map, blk_itr, cnt, block_bitmap); if (retval) goto cleanup; @@ -250,7 +250,7 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block) } else memset(block_bitmap, 0xff, block_nbytes); cnt = block_nbytes << 3; - retval = ext2fs_set_block_bitmap_range(fs->block_map, + retval = ext2fs_set_block_bitmap_range(fs->block_map, blk_itr, cnt, block_bitmap); if (retval) goto cleanup; @@ -272,7 +272,7 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block) } else memset(inode_bitmap, 0xff, inode_nbytes); cnt = inode_nbytes << 3; - retval = ext2fs_set_inode_bitmap_range(fs->inode_map, + retval = ext2fs_set_inode_bitmap_range(fs->inode_map, ino_itr, cnt, inode_bitmap); if (retval) goto cleanup; @@ -285,7 +285,7 @@ success_cleanup: if (block_bitmap) ext2fs_free_mem(&block_bitmap); return 0; - + cleanup: if (do_block) { ext2fs_free_mem(&fs->block_map); diff --git a/lib/ext2fs/swapfs.c b/lib/ext2fs/swapfs.c index 5fe32927..5ccc87f0 100644 --- a/lib/ext2fs/swapfs.c +++ b/lib/ext2fs/swapfs.c @@ -1,6 +1,6 @@ /* * swapfs.c --- swap ext2 filesystem data structures - * + * * Copyright (C) 1995, 1996, 2002 Theodore Ts'o. * * %Begin-Header% @@ -166,11 +166,11 @@ void ext2fs_swap_inode_full(ext2_filsys fs, struct ext2_inode_large *t, t->i_links_count = ext2fs_swab16(f->i_links_count); t->i_file_acl = ext2fs_swab32(f->i_file_acl); if (hostorder) - has_data_blocks = ext2fs_inode_data_blocks(fs, + has_data_blocks = ext2fs_inode_data_blocks(fs, (struct ext2_inode *) f); t->i_blocks = ext2fs_swab32(f->i_blocks); if (!hostorder) - has_data_blocks = ext2fs_inode_data_blocks(fs, + has_data_blocks = ext2fs_inode_data_blocks(fs, (struct ext2_inode *) t); if (hostorder && (f->i_flags & EXT4_EXTENTS_FL)) has_extents = 1; @@ -193,7 +193,7 @@ void ext2fs_swap_inode_full(ext2_filsys fs, struct ext2_inode_large *t, case EXT2_OS_LINUX: t->osd1.linux1.l_i_version = ext2fs_swab32(f->osd1.linux1.l_i_version); - t->osd2.linux2.l_i_blocks_hi = + t->osd2.linux2.l_i_blocks_hi = ext2fs_swab16(f->osd2.linux2.l_i_blocks_hi); t->osd2.linux2.l_i_file_acl_high = ext2fs_swab16(f->osd2.linux2.l_i_file_acl_high); diff --git a/lib/ext2fs/tdb.c b/lib/ext2fs/tdb.c index b7cf43d4..0c82a248 100644 --- a/lib/ext2fs/tdb.c +++ b/lib/ext2fs/tdb.c @@ -3,17 +3,17 @@ URL: svn://svnanon.samba.org/samba/branches/SAMBA_4_0/source/lib/tdb/common Rev: 23590 Last Changed Date: 2007-06-22 13:36:10 -0400 (Fri, 22 Jun 2007) */ - /* + /* trivial database library - standalone version Copyright (C) Andrew Tridgell 1999-2005 Copyright (C) Jeremy Allison 2000-2006 Copyright (C) Paul `Rusty' Russell 2000 - + ** NOTE! The following LGPL license applies to the tdb ** library. This does NOT imply that all of Samba is released ** under the LGPL - + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either @@ -327,11 +327,11 @@ const char *tdb_errorstr(struct tdb_context *tdb) this functions locks/unlocks 1 byte at the specified offset. On error, errno is also set so that errors are passed back properly - through tdb_open(). + through tdb_open(). note that a len of zero means lock to end of file */ -int tdb_brlock(struct tdb_context *tdb, tdb_off_t offset, +int tdb_brlock(struct tdb_context *tdb, tdb_off_t offset, int rw_type, int lck_type, int probe, size_t len) { struct flock fl; @@ -363,7 +363,7 @@ int tdb_brlock(struct tdb_context *tdb, tdb_off_t offset, if (!probe && lck_type != F_SETLK) { /* Ensure error code is set for log fun to examine. */ tdb->ecode = TDB_ERR_LOCK; - TDB_LOG((tdb, TDB_DEBUG_TRACE,"tdb_brlock failed (fd=%d) at offset %d rw_type=%d lck_type=%d len=%d\n", + TDB_LOG((tdb, TDB_DEBUG_TRACE,"tdb_brlock failed (fd=%d) at offset %d rw_type=%d lck_type=%d len=%d\n", tdb->fd, offset, rw_type, lck_type, (int)len)); } return TDB_ERRCODE(TDB_ERR_LOCK, -1); @@ -376,7 +376,7 @@ int tdb_brlock(struct tdb_context *tdb, tdb_off_t offset, upgrade a read lock to a write lock. This needs to be handled in a special way as some OSes (such as solaris) have too conservative deadlock detection and claim a deadlock when progress can be - made. For those OSes we may loop for a while. + made. For those OSes we may loop for a while. */ int tdb_brlock_upgrade(struct tdb_context *tdb, tdb_off_t offset, size_t len) { @@ -409,7 +409,7 @@ static int _tdb_lock(struct tdb_context *tdb, int list, int ltype, int op) ltype &= ~TDB_MARK_LOCK; /* a global lock allows us to avoid per chain locks */ - if (tdb->global_lock.count && + if (tdb->global_lock.count && (ltype == tdb->global_lock.ltype || ltype == F_RDLCK)) { return 0; } @@ -419,7 +419,7 @@ static int _tdb_lock(struct tdb_context *tdb, int list, int ltype, int op) } if (list < -1 || list >= (int)tdb->header.hash_size) { - TDB_LOG((tdb, TDB_DEBUG_ERROR,"tdb_lock: invalid list %d for ltype=%d\n", + TDB_LOG((tdb, TDB_DEBUG_ERROR,"tdb_lock: invalid list %d for ltype=%d\n", list, ltype)); return -1; } @@ -504,7 +504,7 @@ int tdb_unlock(struct tdb_context *tdb, int list, int ltype) ltype &= ~TDB_MARK_LOCK; /* a global lock allows us to avoid per chain locks */ - if (tdb->global_lock.count && + if (tdb->global_lock.count && (ltype == tdb->global_lock.ltype || ltype == F_RDLCK)) { return 0; } @@ -574,7 +574,7 @@ int tdb_unlock(struct tdb_context *tdb, int list, int ltype) } if (ret) - TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_unlock: An error occurred unlocking!\n")); + TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_unlock: An error occurred unlocking!\n")); return ret; } @@ -586,7 +586,7 @@ int tdb_transaction_lock(struct tdb_context *tdb, int ltype) if (tdb->have_transaction_lock || tdb->global_lock.count) { return 0; } - if (tdb->methods->tdb_brlock(tdb, TRANSACTION_LOCK, ltype, + if (tdb->methods->tdb_brlock(tdb, TRANSACTION_LOCK, ltype, F_SETLKW, 0, 1) == -1) { TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_lock: failed to get transaction lock\n")); tdb->ecode = TDB_ERR_LOCK; @@ -635,7 +635,7 @@ static int _tdb_lockall(struct tdb_context *tdb, int ltype, int op) /* a global lock of a different type exists */ return TDB_ERRCODE(TDB_ERR_LOCK, -1); } - + if (tdb->num_locks != 0) { /* can't combine global and chain locks */ return TDB_ERRCODE(TDB_ERR_LOCK, -1); @@ -680,7 +680,7 @@ static int _tdb_unlockall(struct tdb_context *tdb, int ltype) } if (!mark_lock && - tdb->methods->tdb_brlock(tdb, FREELIST_TOP, F_UNLCK, F_SETLKW, + tdb->methods->tdb_brlock(tdb, FREELIST_TOP, F_UNLCK, F_SETLKW, 0, 4*tdb->header.hash_size)) { TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_unlockall failed (%s)\n", strerror(errno))); return -1; @@ -831,7 +831,7 @@ int tdb_unlock_record(struct tdb_context *tdb, tdb_off_t off) /* check for an out of bounds access - if it is out of bounds then see if the database has been expanded by someone else and expand - if necessary + if necessary note that "len" is the minimum length needed for the db */ static int tdb_oob(struct tdb_context *tdb, tdb_off_t len, int probe) @@ -872,7 +872,7 @@ static int tdb_oob(struct tdb_context *tdb, tdb_off_t len, int probe) } /* write a lump of data at a specified offset */ -static int tdb_write(struct tdb_context *tdb, tdb_off_t off, +static int tdb_write(struct tdb_context *tdb, tdb_off_t off, const void *buf, tdb_len_t len) { if (len == 0) { @@ -910,7 +910,7 @@ void *tdb_convert(void *buf, u32 size) /* read a lump of data at a specified offset, maybe convert */ -static int tdb_read(struct tdb_context *tdb, tdb_off_t off, void *buf, +static int tdb_read(struct tdb_context *tdb, tdb_off_t off, void *buf, tdb_len_t len, int cv) { if (tdb->methods->tdb_oob(tdb, off + len, 0) != 0) { @@ -942,7 +942,7 @@ static int tdb_read(struct tdb_context *tdb, tdb_off_t off, void *buf, /* do an unlocked scan of the hash table heads to find the next non-zero head. The value will then be confirmed with the lock held -*/ +*/ static void tdb_next_hash_chain(struct tdb_context *tdb, u32 *chain) { u32 h = *chain; @@ -987,8 +987,8 @@ void tdb_mmap(struct tdb_context *tdb) #ifdef HAVE_MMAP if (!(tdb->flags & TDB_NOMMAP)) { - tdb->map_ptr = mmap(NULL, tdb->map_size, - PROT_READ|(tdb->read_only? 0:PROT_WRITE), + tdb->map_ptr = mmap(NULL, tdb->map_size, + PROT_READ|(tdb->read_only? 0:PROT_WRITE), MAP_SHARED|MAP_FILE, tdb->fd, 0); /* @@ -997,7 +997,7 @@ void tdb_mmap(struct tdb_context *tdb) if (tdb->map_ptr == MAP_FAILED) { tdb->map_ptr = NULL; - TDB_LOG((tdb, TDB_DEBUG_WARNING, "tdb_mmap failed for size %d (%s)\n", + TDB_LOG((tdb, TDB_DEBUG_WARNING, "tdb_mmap failed for size %d (%s)\n", tdb->map_size, strerror(errno))); } } else { @@ -1022,7 +1022,7 @@ static int tdb_expand_file(struct tdb_context *tdb, tdb_off_t size, tdb_off_t ad if (ftruncate(tdb->fd, size+addition) == -1) { char b = 0; if (pwrite(tdb->fd, &b, 1, (size+addition) - 1) != 1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "expand_file to %d failed (%s)\n", + TDB_LOG((tdb, TDB_DEBUG_FATAL, "expand_file to %d failed (%s)\n", size+addition, strerror(errno))); return -1; } @@ -1036,7 +1036,7 @@ static int tdb_expand_file(struct tdb_context *tdb, tdb_off_t size, tdb_off_t ad int n = addition>sizeof(buf)?sizeof(buf):addition; int ret = pwrite(tdb->fd, buf, n, size); if (ret != n) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "expand_file write of %d failed (%s)\n", + TDB_LOG((tdb, TDB_DEBUG_FATAL, "expand_file write of %d failed (%s)\n", n, strerror(errno))); return -1; } @@ -1262,7 +1262,7 @@ void tdb_io_init(struct tdb_context *tdb) - allow for nested calls to tdb_transaction_start(), re-using the existing transaction record. If the inner transaction is cancelled then a subsequent commit will fail - + - keep a mirrored copy of the tdb hash chain heads to allow for the fast hash heads scan on traverse, updating the mirrored copy in the transaction version of tdb_write @@ -1334,7 +1334,7 @@ struct tdb_transaction { read while in a transaction. We need to check first if the data is in our list of transaction elements, then if not do a real read */ -static int transaction_read(struct tdb_context *tdb, tdb_off_t off, void *buf, +static int transaction_read(struct tdb_context *tdb, tdb_off_t off, void *buf, tdb_len_t len, int cv) { struct tdb_transaction_el *el; @@ -1373,7 +1373,7 @@ static int transaction_read(struct tdb_context *tdb, tdb_off_t off, void *buf, len -= partial; off += partial; buf = (void *)(partial + (char *)buf); - + if (len != 0 && transaction_read(tdb, off, buf, len, cv) != 0) { goto fail; } @@ -1395,7 +1395,7 @@ fail: /* write while in a transaction */ -static int transaction_write(struct tdb_context *tdb, tdb_off_t off, +static int transaction_write(struct tdb_context *tdb, tdb_off_t off, const void *buf, tdb_len_t len) { struct tdb_transaction_el *el, *best_el=NULL; @@ -1403,7 +1403,7 @@ static int transaction_write(struct tdb_context *tdb, tdb_off_t off, if (len == 0) { return 0; } - + /* if the write is to a hash head, then update the transaction hash heads */ if (len == sizeof(tdb_off_t) && off >= FREELIST_TOP && @@ -1447,7 +1447,7 @@ static int transaction_write(struct tdb_context *tdb, tdb_off_t off, len -= partial; off += partial; buf = (const void *)(partial + (const char *)buf); - + if (len != 0 && transaction_write(tdb, off, buf, len) != 0) { goto fail; } @@ -1456,7 +1456,7 @@ static int transaction_write(struct tdb_context *tdb, tdb_off_t off, } /* see if we can append the new entry to an existing entry */ - if (best_el && best_el->offset + best_el->length == off && + if (best_el && best_el->offset + best_el->length == off && (off+len < tdb->transaction->old_map_size || off > tdb->transaction->old_map_size)) { unsigned char *data = best_el->data; @@ -1482,7 +1482,7 @@ static int transaction_write(struct tdb_context *tdb, tdb_off_t off, el = (struct tdb_transaction_el *)malloc(sizeof(*el)); if (el == NULL) { tdb->ecode = TDB_ERR_OOM; - tdb->transaction->transaction_error = 1; + tdb->transaction->transaction_error = 1; return -1; } el->next = NULL; @@ -1493,7 +1493,7 @@ static int transaction_write(struct tdb_context *tdb, tdb_off_t off, if (el->data == NULL) { free(el); tdb->ecode = TDB_ERR_OOM; - tdb->transaction->transaction_error = 1; + tdb->transaction->transaction_error = 1; return -1; } if (buf) { @@ -1545,7 +1545,7 @@ static int transaction_oob(struct tdb_context *tdb, tdb_off_t len, int probe) /* transaction version of tdb_expand(). */ -static int transaction_expand_file(struct tdb_context *tdb, tdb_off_t size, +static int transaction_expand_file(struct tdb_context *tdb, tdb_off_t size, tdb_off_t addition) { /* add a write to the transaction elements, so subsequent @@ -1560,7 +1560,7 @@ static int transaction_expand_file(struct tdb_context *tdb, tdb_off_t size, /* brlock during a transaction - ignore them */ -static int transaction_brlock(struct tdb_context *tdb, tdb_off_t offset, +static int transaction_brlock(struct tdb_context *tdb, tdb_off_t offset, int rw_type, int lck_type, int probe, size_t len) { return 0; @@ -1592,7 +1592,7 @@ int tdb_transaction_start(struct tdb_context *tdb) /* cope with nested tdb_transaction_start() calls */ if (tdb->transaction != NULL) { tdb->transaction->nesting++; - TDB_LOG((tdb, TDB_DEBUG_TRACE, "tdb_transaction_start: nesting %d\n", + TDB_LOG((tdb, TDB_DEBUG_TRACE, "tdb_transaction_start: nesting %d\n", tdb->transaction->nesting)); return 0; } @@ -1629,7 +1629,7 @@ int tdb_transaction_start(struct tdb_context *tdb) SAFE_FREE(tdb->transaction); return -1; } - + /* get a read lock from the freelist to the end of file. This is upgraded to a write lock during the commit */ if (tdb_brlock(tdb, FREELIST_TOP, F_RDLCK, F_SETLKW, 0, 0) == -1) { @@ -1665,7 +1665,7 @@ int tdb_transaction_start(struct tdb_context *tdb) /* by calling this transaction write here, we ensure that we don't grow the transaction linked list due to hash table updates */ - if (transaction_write(tdb, FREELIST_TOP, tdb->transaction->hash_heads, + if (transaction_write(tdb, FREELIST_TOP, tdb->transaction->hash_heads, TDB_HASHTABLE_SIZE(tdb)) != 0) { TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_start: failed to prime hash table\n")); tdb->ecode = TDB_ERR_IO; @@ -1674,7 +1674,7 @@ int tdb_transaction_start(struct tdb_context *tdb) } return 0; - + fail: tdb_brlock(tdb, FREELIST_TOP, F_UNLCK, F_SETLKW, 0, 0); tdb_transaction_unlock(tdb); @@ -1688,7 +1688,7 @@ fail: cancel the current transaction */ int tdb_transaction_cancel(struct tdb_context *tdb) -{ +{ if (tdb->transaction == NULL) { TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_cancel: no transaction\n")); return -1; @@ -1698,7 +1698,7 @@ int tdb_transaction_cancel(struct tdb_context *tdb) tdb->transaction->transaction_error = 1; tdb->transaction->nesting--; return 0; - } + } tdb->map_size = tdb->transaction->old_map_size; @@ -1735,7 +1735,7 @@ int tdb_transaction_cancel(struct tdb_context *tdb) tdb_transaction_unlock(tdb); SAFE_FREE(tdb->transaction->hash_heads); SAFE_FREE(tdb->transaction); - + return 0; } @@ -1743,7 +1743,7 @@ int tdb_transaction_cancel(struct tdb_context *tdb) sync to disk */ static int transaction_sync(struct tdb_context *tdb, tdb_off_t offset, tdb_len_t length) -{ +{ if (fsync(tdb->fd) != 0) { tdb->ecode = TDB_ERR_IO; TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction: fsync failed\n")); @@ -1752,7 +1752,7 @@ static int transaction_sync(struct tdb_context *tdb, tdb_off_t offset, tdb_len_t #ifdef MS_SYNC if (tdb->map_ptr) { tdb_off_t moffset = offset & ~(tdb->page_size-1); - if (msync(moffset + (char *)tdb->map_ptr, + if (msync(moffset + (char *)tdb->map_ptr, length + (offset - moffset), MS_SYNC) != 0) { tdb->ecode = TDB_ERR_IO; TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction: msync failed - %s\n", @@ -1788,7 +1788,7 @@ static tdb_len_t tdb_recovery_size(struct tdb_context *tdb) allocate the recovery area, or use an existing recovery area if it is large enough */ -static int tdb_recovery_allocate(struct tdb_context *tdb, +static int tdb_recovery_allocate(struct tdb_context *tdb, tdb_len_t *recovery_size, tdb_off_t *recovery_offset, tdb_len_t *recovery_max_size) @@ -1804,7 +1804,7 @@ static int tdb_recovery_allocate(struct tdb_context *tdb, rec.rec_len = 0; - if (recovery_head != 0 && + if (recovery_head != 0 && methods->tdb_read(tdb, recovery_head, &rec, sizeof(rec), DOCONV()) == -1) { TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_recovery_allocate: failed to read recovery record\n")); return -1; @@ -1839,7 +1839,7 @@ static int tdb_recovery_allocate(struct tdb_context *tdb, *recovery_offset = tdb->map_size; recovery_head = *recovery_offset; - if (methods->tdb_expand_file(tdb, tdb->transaction->old_map_size, + if (methods->tdb_expand_file(tdb, tdb->transaction->old_map_size, (tdb->map_size - tdb->transaction->old_map_size) + sizeof(rec) + *recovery_max_size) == -1) { TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_recovery_allocate: failed to create recovery area\n")); @@ -1856,7 +1856,7 @@ static int tdb_recovery_allocate(struct tdb_context *tdb, /* write the recovery header offset and sync - we can sync without a race here as the magic ptr in the recovery record has not been set */ CONVERT(recovery_head); - if (methods->tdb_write(tdb, TDB_RECOVERY_HEAD, + if (methods->tdb_write(tdb, TDB_RECOVERY_HEAD, &recovery_head, sizeof(tdb_off_t)) == -1) { TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_recovery_allocate: failed to write recovery head\n")); return -1; @@ -1869,7 +1869,7 @@ static int tdb_recovery_allocate(struct tdb_context *tdb, /* setup the recovery data that will be used on a crash during commit */ -static int transaction_setup_recovery(struct tdb_context *tdb, +static int transaction_setup_recovery(struct tdb_context *tdb, tdb_off_t *magic_offset) { struct tdb_transaction_el *el; @@ -1884,7 +1884,7 @@ static int transaction_setup_recovery(struct tdb_context *tdb, /* check that the recovery area has enough space */ - if (tdb_recovery_allocate(tdb, &recovery_size, + if (tdb_recovery_allocate(tdb, &recovery_size, &recovery_offset, &recovery_max_size) == -1) { return -1; } @@ -1979,7 +1979,7 @@ static int transaction_setup_recovery(struct tdb_context *tdb, commit the current transaction */ int tdb_transaction_commit(struct tdb_context *tdb) -{ +{ const struct tdb_methods *methods; tdb_off_t magic_offset = 0; u32 zero = 0; @@ -1999,7 +1999,7 @@ int tdb_transaction_commit(struct tdb_context *tdb) if (tdb->transaction->nesting != 0) { tdb->transaction->nesting--; return 0; - } + } /* check for a null transaction */ if (tdb->transaction->elements == NULL) { @@ -2008,7 +2008,7 @@ int tdb_transaction_commit(struct tdb_context *tdb) } methods = tdb->transaction->io_methods; - + /* if there are any locks pending then the caller has not nested their locks properly, so fail the transaction */ if (tdb->num_locks || tdb->global_lock.count) { @@ -2047,8 +2047,8 @@ int tdb_transaction_commit(struct tdb_context *tdb) /* expand the file to the new size if needed */ if (tdb->map_size != tdb->transaction->old_map_size) { - if (methods->tdb_expand_file(tdb, tdb->transaction->old_map_size, - tdb->map_size - + if (methods->tdb_expand_file(tdb, tdb->transaction->old_map_size, + tdb->map_size - tdb->transaction->old_map_size) == -1) { tdb->ecode = TDB_ERR_IO; TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_commit: expansion failed\n")); @@ -2066,12 +2066,12 @@ int tdb_transaction_commit(struct tdb_context *tdb) if (methods->tdb_write(tdb, el->offset, el->data, el->length) == -1) { TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_commit: write failed during commit\n")); - + /* we've overwritten part of the data and possibly expanded the file, so we need to run the crash recovery code */ tdb->methods = methods; - tdb_transaction_recover(tdb); + tdb_transaction_recover(tdb); tdb_transaction_cancel(tdb); tdb_brlock(tdb, GLOBAL_LOCK, F_UNLCK, F_SETLKW, 0, 1); @@ -2080,9 +2080,9 @@ int tdb_transaction_commit(struct tdb_context *tdb) return -1; } tdb->transaction->elements = el->next; - free(el->data); + free(el->data); free(el); - } + } if (!(tdb->flags & TDB_NOSYNC)) { /* ensure the new data is on disk */ @@ -2151,9 +2151,9 @@ int tdb_transaction_recover(struct tdb_context *tdb) } /* read the recovery record */ - if (tdb->methods->tdb_read(tdb, recovery_head, &rec, + if (tdb->methods->tdb_read(tdb, recovery_head, &rec, sizeof(rec), DOCONV()) == -1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to read recovery record\n")); + TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to read recovery record\n")); tdb->ecode = TDB_ERR_IO; return -1; } @@ -2173,7 +2173,7 @@ int tdb_transaction_recover(struct tdb_context *tdb) data = (unsigned char *)malloc(rec.data_len); if (data == NULL) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to allocate recovery data\n")); + TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to allocate recovery data\n")); tdb->ecode = TDB_ERR_OOM; return -1; } @@ -2181,7 +2181,7 @@ int tdb_transaction_recover(struct tdb_context *tdb) /* read the full recovery data */ if (tdb->methods->tdb_read(tdb, recovery_head + sizeof(rec), data, rec.data_len, 0) == -1) { - TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to read recovery data\n")); + TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to read recovery data\n")); tdb->ecode = TDB_ERR_IO; return -1; } @@ -2218,24 +2218,24 @@ int tdb_transaction_recover(struct tdb_context *tdb) if (tdb_ofs_write(tdb, TDB_RECOVERY_HEAD, &zero) == -1) { TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to remove recovery head\n")); tdb->ecode = TDB_ERR_IO; - return -1; + return -1; } } /* remove the recovery magic */ - if (tdb_ofs_write(tdb, recovery_head + offsetof(struct list_struct, magic), + if (tdb_ofs_write(tdb, recovery_head + offsetof(struct list_struct, magic), &zero) == -1) { TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to remove recovery magic\n")); tdb->ecode = TDB_ERR_IO; - return -1; + return -1; } - + /* reduce the file size to the old size */ tdb_munmap(tdb); if (ftruncate(tdb->fd, recovery_eof) != 0) { TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction_recover: failed to reduce to recovery size\n")); tdb->ecode = TDB_ERR_IO; - return -1; + return -1; } tdb->map_size = recovery_eof; tdb_mmap(tdb); @@ -2246,7 +2246,7 @@ int tdb_transaction_recover(struct tdb_context *tdb) return -1; } - TDB_LOG((tdb, TDB_DEBUG_TRACE, "tdb_transaction_recover: recovered %d byte database\n", + TDB_LOG((tdb, TDB_DEBUG_TRACE, "tdb_transaction_recover: recovered %d byte database\n", recovery_eof)); /* all done */ @@ -2264,7 +2264,7 @@ static int tdb_rec_free_read(struct tdb_context *tdb, tdb_off_t off, struct list if (rec->magic == TDB_MAGIC) { /* this happens when a app is showdown while deleting a record - we should not completely fail when this happens */ - TDB_LOG((tdb, TDB_DEBUG_WARNING, "tdb_rec_free_read non-free magic 0x%x at offset=%d - fixing\n", + TDB_LOG((tdb, TDB_DEBUG_WARNING, "tdb_rec_free_read non-free magic 0x%x at offset=%d - fixing\n", rec->magic, off)); rec->magic = TDB_FREE_MAGIC; if (tdb->methods->tdb_write(tdb, off, rec, sizeof(*rec)) == -1) @@ -2274,7 +2274,7 @@ static int tdb_rec_free_read(struct tdb_context *tdb, tdb_off_t off, struct list if (rec->magic != TDB_FREE_MAGIC) { /* Ensure ecode is set for log fn. */ tdb->ecode = TDB_ERR_CORRUPT; - TDB_LOG((tdb, TDB_DEBUG_WARNING, "tdb_rec_free_read bad magic 0x%x at offset=%d\n", + TDB_LOG((tdb, TDB_DEBUG_WARNING, "tdb_rec_free_read bad magic 0x%x at offset=%d\n", rec->magic, off)); return TDB_ERRCODE(TDB_ERR_CORRUPT, -1); } @@ -2359,7 +2359,7 @@ left: if (left > TDB_DATA_START(tdb->header.hash_size)) { struct list_struct l; tdb_off_t leftsize; - + /* Read in tailer and jump back to header */ if (tdb_ofs_read(tdb, left, &leftsize) == -1) { TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_free: left offset read failed at %u\n", left)); @@ -2417,7 +2417,7 @@ update: } -/* +/* the core of tdb_allocate - called when we have decided which free list entry to use */ @@ -2433,22 +2433,22 @@ static tdb_off_t tdb_allocate_ofs(struct tdb_context *tdb, tdb_len_t length, tdb if (rec->rec_len > length + MIN_REC_SIZE) { /* Length of left piece */ length = TDB_ALIGN(length, TDB_ALIGNMENT); - + /* Right piece to go on free list */ newrec.rec_len = rec->rec_len - (sizeof(*rec) + length); newrec_ptr = rec_ptr + sizeof(*rec) + length; - + /* And left record is shortened */ rec->rec_len = length; } else { newrec_ptr = 0; } - + /* Remove allocated record from the free list */ if (tdb_ofs_write(tdb, last_ptr, &rec->next) == -1) { return 0; } - + /* Update header: do this before we drop alloc lock, otherwise tdb_free() might try to merge with us, thinking we're free. @@ -2457,7 +2457,7 @@ static tdb_off_t tdb_allocate_ofs(struct tdb_context *tdb, tdb_len_t length, tdb if (tdb_rec_write(tdb, rec_ptr, rec) == -1) { return 0; } - + /* Did we create new block? */ if (newrec_ptr) { /* Update allocated record tailer (we @@ -2465,13 +2465,13 @@ static tdb_off_t tdb_allocate_ofs(struct tdb_context *tdb, tdb_len_t length, tdb if (update_tailer(tdb, rec_ptr, rec) == -1) { return 0; } - + /* Free new record */ if (tdb_free(tdb, newrec_ptr, &newrec) == -1) { return 0; } } - + /* all done - return the new record offset */ return rec_ptr; } @@ -2507,7 +2507,7 @@ tdb_off_t tdb_allocate(struct tdb_context *tdb, tdb_len_t length, struct list_st bestfit.last_ptr = 0; bestfit.rec_len = 0; - /* + /* this is a best fit allocation strategy. Originally we used a first fit strategy, but it suffered from massive fragmentation issues when faced with a slowly increasing record size. @@ -2655,7 +2655,7 @@ static int tdb_next_lock(struct tdb_context *tdb, struct tdb_traverse_lock *tloc common for the use of tdb with ldb, where large hashes are used. In that case we spend most of our time in tdb_brlock(), locking empty hash chains. - + To avoid this, we do an unlocked pre-check to see if the hash chain is empty before starting to look inside it. If it is empty then we can avoid that @@ -2663,7 +2663,7 @@ static int tdb_next_lock(struct tdb_context *tdb, struct tdb_traverse_lock *tloc the value we get back, as we read it without a lock, so instead we get the lock and re-fetch the value below. - + Notice that not doing this optimisation on the first hash chain is critical. We must guarantee that we have done at least one fcntl lock at the @@ -2673,7 +2673,7 @@ static int tdb_next_lock(struct tdb_context *tdb, struct tdb_traverse_lock *tloc could possibly miss those with this trick, but we could miss them anyway without this trick, so the semantics don't change. - + With a non-indexed ldb search this trick gains us a factor of around 80 in speed on a linux 2.6.x system (testing using ldbtest). @@ -2727,7 +2727,7 @@ static int tdb_next_lock(struct tdb_context *tdb, struct tdb_traverse_lock *tloc /* Try to clean dead ones from old traverses */ current = tlock->off; tlock->off = rec->next; - if (!(tdb->read_only || tdb->traverse_read) && + if (!(tdb->read_only || tdb->traverse_read) && tdb_do_delete(tdb, current, rec) != 0) goto fail; } @@ -2749,7 +2749,7 @@ static int tdb_next_lock(struct tdb_context *tdb, struct tdb_traverse_lock *tloc if fn is NULL then it is not called a non-zero return value from fn() indicates that the traversal should stop */ -static int tdb_traverse_internal(struct tdb_context *tdb, +static int tdb_traverse_internal(struct tdb_context *tdb, tdb_traverse_func fn, void *private_data, struct tdb_traverse_lock *tl) { @@ -2769,7 +2769,7 @@ static int tdb_traverse_internal(struct tdb_context *tdb, while ((ret = tdb_next_lock(tdb, tl, &rec)) > 0) { count++; /* now read the full record */ - key.dptr = tdb_alloc_read(tdb, tl->off + sizeof(rec), + key.dptr = tdb_alloc_read(tdb, tl->off + sizeof(rec), rec.key_len + rec.data_len); if (!key.dptr) { ret = -1; @@ -2813,7 +2813,7 @@ out: /* a write style traverse - temporarily marks the db read only */ -int tdb_traverse_read(struct tdb_context *tdb, +int tdb_traverse_read(struct tdb_context *tdb, tdb_traverse_func fn, void *private_data) { struct tdb_traverse_lock tl = { NULL, 0, 0, F_RDLCK }; @@ -2838,7 +2838,7 @@ int tdb_traverse_read(struct tdb_context *tdb, a write style traverse - needs to get the transaction lock to prevent deadlocks */ -int tdb_traverse(struct tdb_context *tdb, +int tdb_traverse(struct tdb_context *tdb, tdb_traverse_func fn, void *private_data) { struct tdb_traverse_lock tl = { NULL, 0, 0, F_WRLCK }; @@ -2847,7 +2847,7 @@ int tdb_traverse(struct tdb_context *tdb, if (tdb->read_only || tdb->traverse_read) { return tdb_traverse_read(tdb, fn, private_data); } - + if (tdb_transaction_lock(tdb, F_WRLCK)) { return -1; } @@ -2953,7 +2953,7 @@ static tdb_off_t tdb_dump_record(struct tdb_context *tdb, int hash, struct list_struct rec; tdb_off_t tailer_ofs, tailer; - if (tdb->methods->tdb_read(tdb, offset, (char *)&rec, + if (tdb->methods->tdb_read(tdb, offset, (char *)&rec, sizeof(rec), DOCONV()) == -1) { printf("ERROR: failed to read record at %u\n", offset); return 0; @@ -3030,7 +3030,7 @@ int tdb_printfreelist(struct tdb_context *tdb) printf("freelist top=[0x%08x]\n", rec_ptr ); while (rec_ptr) { - if (tdb->methods->tdb_read(tdb, rec_ptr, (char *)&rec, + if (tdb->methods->tdb_read(tdb, rec_ptr, (char *)&rec, sizeof(rec), DOCONV()) == -1) { tdb_unlock(tdb, -1, F_WRLCK); return -1; @@ -3042,14 +3042,14 @@ int tdb_printfreelist(struct tdb_context *tdb) return -1; } - printf("entry offset=[0x%08x], rec.rec_len = [0x%08x (%d)] (end = 0x%08x)\n", + printf("entry offset=[0x%08x], rec.rec_len = [0x%08x (%d)] (end = 0x%08x)\n", rec_ptr, rec.rec_len, rec.rec_len, rec_ptr + rec.rec_len); total_free += rec.rec_len; /* move to the next record */ rec_ptr = rec.next; } - printf("total rec_len = [0x%08x (%d)]\n", (int)total_free, + printf("total rec_len = [0x%08x (%d)]\n", (int)total_free, (int)total_free); return tdb_unlock(tdb, -1, F_WRLCK); @@ -3066,7 +3066,7 @@ TDB_DATA tdb_null; void tdb_increment_seqnum_nonblock(struct tdb_context *tdb) { tdb_off_t seqnum=0; - + if (!(tdb->flags & TDB_SEQNUM)) { return; } @@ -3109,7 +3109,7 @@ static tdb_off_t tdb_find(struct tdb_context *tdb, TDB_DATA key, u32 hash, struct list_struct *r) { tdb_off_t rec_ptr; - + /* read in the hash top */ if (tdb_ofs_read(tdb, TDB_HASH_TOP(hash), &rec_ptr) == -1) return 0; @@ -3173,7 +3173,7 @@ static int tdb_update_hash(struct tdb_context *tdb, TDB_DATA key, u32 hash, TDB_ rec.data_len = dbuf.dsize; return tdb_rec_write(tdb, rec_ptr, &rec); } - + return 0; } @@ -3243,7 +3243,7 @@ int tdb_parse_record(struct tdb_context *tdb, TDB_DATA key, return ret; } -/* check if an entry in the database exists +/* check if an entry in the database exists note that 1 is returned if the key is found and 0 is returned if not found this doesn't match the conventions in the rest of this module, but is @@ -3252,7 +3252,7 @@ int tdb_parse_record(struct tdb_context *tdb, TDB_DATA key, static int tdb_exists_hash(struct tdb_context *tdb, TDB_DATA key, u32 hash) { struct list_struct rec; - + if (tdb_find_lock_hash(tdb, key, hash, F_RDLCK, &rec) == 0) return 0; tdb_unlock(tdb, BUCKET(rec.full_hash), F_RDLCK); @@ -3305,7 +3305,7 @@ static int tdb_count_dead(struct tdb_context *tdb, u32 hash) int res = 0; tdb_off_t rec_ptr; struct list_struct rec; - + /* read in the hash top */ if (tdb_ofs_read(tdb, TDB_HASH_TOP(hash), &rec_ptr) == -1) return 0; @@ -3334,7 +3334,7 @@ static int tdb_purge_dead(struct tdb_context *tdb, u32 hash) if (tdb_lock(tdb, -1, F_WRLCK) == -1) { return -1; } - + /* read in the hash top */ if (tdb_ofs_read(tdb, TDB_HASH_TOP(hash), &rec_ptr) == -1) goto fail; @@ -3426,7 +3426,7 @@ static tdb_off_t tdb_find_dead(struct tdb_context *tdb, u32 hash, struct list_struct *r, tdb_len_t length) { tdb_off_t rec_ptr; - + /* read in the hash top */ if (tdb_ofs_read(tdb, TDB_HASH_TOP(hash), &rec_ptr) == -1) return 0; @@ -3449,7 +3449,7 @@ static tdb_off_t tdb_find_dead(struct tdb_context *tdb, u32 hash, } /* store an element in the database, replacing any existing element - with the same key + with the same key return 0 on success, -1 on failure */ @@ -3585,7 +3585,7 @@ int tdb_store(struct tdb_context *tdb, TDB_DATA key, TDB_DATA dbuf, int flag) tdb_increment_seqnum(tdb); } - SAFE_FREE(p); + SAFE_FREE(p); tdb_unlock(tdb, BUCKET(hash), F_WRLCK); return ret; } @@ -3625,7 +3625,7 @@ int tdb_append(struct tdb_context *tdb, TDB_DATA key, TDB_DATA new_dbuf) dbuf.dsize += new_dbuf.dsize; ret = tdb_store(tdb, key, dbuf, 0); - + failed: tdb_unlock(tdb, BUCKET(hash), F_WRLCK); SAFE_FREE(dbuf.dptr); @@ -3720,7 +3720,7 @@ static unsigned int default_tdb_hash(TDB_DATA *key) for (value = 0x238F13AF * key->dsize, i=0; i < key->dsize; i++) value = (value + (key->dptr[i] << (i*5 % 24))); - return (1103515243 * value + 12345); + return (1103515243 * value + 12345); } @@ -3774,7 +3774,7 @@ static int tdb_already_open(dev_t device, ino_t ino) { struct tdb_context *i; - + for (i = tdbs; i; i = i->next) { if (i->device == device && i->inode == ino) { return 1; @@ -3784,13 +3784,13 @@ static int tdb_already_open(dev_t device, return 0; } -/* open the database, creating it if necessary +/* open the database, creating it if necessary The open_flags and mode are passed straight to the open call on the database file. A flags value of O_WRONLY is invalid. The hash size is advisory, use zero for a default value. - Return is NULL on error, in which case errno is also set. Don't + Return is NULL on error, in which case errno is also set. Don't try to call tdb_error or tdb_errname, just do strerror(errno). @param name may be NULL for internal databases. */ @@ -3849,7 +3849,7 @@ struct tdb_context *tdb_open_ex(const char *name, int hash_size, int tdb_flags, errno = EINVAL; goto fail; } - + if (hash_size == 0) hash_size = DEFAULT_HASH_SIZE; if ((open_flags & O_ACCMODE) == O_RDONLY) { @@ -3983,7 +3983,7 @@ struct tdb_context *tdb_open_ex(const char *name, int hash_size, int tdb_flags, if (!tdb) return NULL; - + if (tdb->map_ptr) { if (tdb->flags & TDB_INTERNAL) SAFE_FREE(tdb->map_ptr); @@ -4091,7 +4091,7 @@ int tdb_reopen(struct tdb_context *tdb) TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_reopen: open failed (%s)\n", strerror(errno))); goto fail; } - if ((tdb->flags & TDB_CLEAR_IF_FIRST) && + if ((tdb->flags & TDB_CLEAR_IF_FIRST) && (tdb->methods->tdb_brlock(tdb, ACTIVE_LOCK, F_RDLCK, F_SETLKW, 0, 1) == -1)) { TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_reopen: failed to obtain active lock\n")); goto fail; diff --git a/lib/ext2fs/tdb.h b/lib/ext2fs/tdb.h index 447d6a16..bfcd9436 100644 --- a/lib/ext2fs/tdb.h +++ b/lib/ext2fs/tdb.h @@ -1,17 +1,17 @@ #ifndef __TDB_H__ #define __TDB_H__ -/* +/* Unix SMB/CIFS implementation. trivial database library Copyright (C) Andrew Tridgell 1999-2004 - + ** NOTE! The following LGPL license applies to the tdb ** library. This does NOT imply that all of Samba is released ** under the LGPL - + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either @@ -51,12 +51,12 @@ extern "C" { #define TDB_ERRCODE(code, ret) ((tdb->ecode = (code)), ret) /* error codes */ -enum TDB_ERROR {TDB_SUCCESS=0, TDB_ERR_CORRUPT, TDB_ERR_IO, TDB_ERR_LOCK, +enum TDB_ERROR {TDB_SUCCESS=0, TDB_ERR_CORRUPT, TDB_ERR_IO, TDB_ERR_LOCK, TDB_ERR_OOM, TDB_ERR_EXISTS, TDB_ERR_NOLOCK, TDB_ERR_LOCK_TIMEOUT, TDB_ERR_NOEXIST, TDB_ERR_EINVAL, TDB_ERR_RDONLY}; /* debugging uses one of the following levels */ -enum tdb_debug_level {TDB_DEBUG_FATAL = 0, TDB_DEBUG_ERROR, +enum tdb_debug_level {TDB_DEBUG_FATAL = 0, TDB_DEBUG_ERROR, TDB_DEBUG_WARNING, TDB_DEBUG_TRACE}; typedef struct TDB_DATA { diff --git a/lib/ext2fs/tdbtool.c b/lib/ext2fs/tdbtool.c index 0366cdac..130fc588 100644 --- a/lib/ext2fs/tdbtool.c +++ b/lib/ext2fs/tdbtool.c @@ -1,4 +1,4 @@ -/* +/* Unix SMB/CIFS implementation. Samba database functions Copyright (C) Andrew Tridgell 1999-2000 @@ -10,12 +10,12 @@ it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -130,7 +130,7 @@ static void print_data(const char *buf,int len) printf("%02X ",(int)buf[i]); i++; if (i%8 == 0) printf(" "); - if (i%16 == 0) { + if (i%16 == 0) { print_asc(&buf[i-16],8); printf(" "); print_asc(&buf[i-8],8); printf("\n"); if (i<len) printf("[%03X] ",i); @@ -138,18 +138,18 @@ static void print_data(const char *buf,int len) } if (i%16) { int n; - + n = 16 - (i%16); printf(" "); if (n>8) printf(" "); while (n--) printf(" "); - + n = i%16; if (n > 8) n = 8; print_asc(&buf[i-(i%16)],n); printf(" "); n = (i%16) - n; - if (n>0) print_asc(&buf[i-n],n); - printf("\n"); + if (n>0) print_asc(&buf[i-n],n); + printf("\n"); } } @@ -171,7 +171,7 @@ static void help(void) " delete key : delete a record by key\n" " list : print the database hash table and freelist\n" " free : print the database freelist\n" -" ! command : execute system command\n" +" ! command : execute system command\n" " 1 | first : print the first record\n" " n | next : print the next record\n" " q | quit : terminate\n" @@ -266,11 +266,11 @@ static void show_tdb(char *keyname, size_t keylen) terror("fetch failed"); return; } - + print_rec(tdb, key, dbuf, NULL); - + free( dbuf.dptr ); - + return; } @@ -314,23 +314,23 @@ static void move_rec(char *keyname, size_t keylen, char* tdbname) terror("fetch failed"); return; } - + print_rec(tdb, key, dbuf, NULL); - + dst_tdb = tdb_open(tdbname, 0, 0, O_RDWR, 0600); if ( !dst_tdb ) { terror("unable to open destination tdb"); return; } - + if ( tdb_store( dst_tdb, key, dbuf, TDB_REPLACE ) == -1 ) { terror("failed to move record"); } else printf("record moved\n"); - + tdb_close( dst_tdb ); - + return; } @@ -399,7 +399,7 @@ static void first_record(TDB_CONTEXT *the_tdb, TDB_DATA *pkey) { TDB_DATA dbuf; *pkey = tdb_firstkey(the_tdb); - + dbuf = tdb_fetch(the_tdb, *pkey); if (!dbuf.dptr) terror("fetch failed"); else { @@ -411,9 +411,9 @@ static void next_record(TDB_CONTEXT *the_tdb, TDB_DATA *pkey) { TDB_DATA dbuf; *pkey = tdb_nextkey(the_tdb, *pkey); - + dbuf = tdb_fetch(the_tdb, *pkey); - if (!dbuf.dptr) + if (!dbuf.dptr) terror("fetch failed"); else print_rec(the_tdb, *pkey, dbuf, NULL); @@ -536,7 +536,7 @@ static char *convert_string(char *instring, size_t *sizep) size_t length = 0; char *outp, *inp; char temp[3]; - + outp = inp = instring; diff --git a/lib/ext2fs/test_io.c b/lib/ext2fs/test_io.c index c2f5449e..39b39bfb 100644 --- a/lib/ext2fs/test_io.c +++ b/lib/ext2fs/test_io.c @@ -40,7 +40,7 @@ #define EXT2_CHECK_MAGIC(struct, code) \ if ((struct)->magic != (code)) return (code) - + struct test_private_data { int magic; io_channel real; @@ -70,7 +70,7 @@ static errcode_t test_write_blk64(io_channel channel, unsigned long long block, static errcode_t test_flush(io_channel channel); static errcode_t test_write_byte(io_channel channel, unsigned long offset, int count, const void *buf); -static errcode_t test_set_option(io_channel channel, const char *option, +static errcode_t test_set_option(io_channel channel, const char *option, const char *arg); static errcode_t test_get_stats(io_channel channel, io_stats *stats); @@ -232,7 +232,7 @@ static errcode_t test_open(const char *name, int flags, io_channel *channel) data->flags = 0; if ((value = safe_getenv("TEST_IO_FLAGS")) != NULL) data->flags = strtoul(value, NULL, 0); - + data->block = 0; if ((value = safe_getenv("TEST_IO_BLOCK")) != NULL) data->block = strtoul(value, NULL, 0); @@ -244,7 +244,7 @@ static errcode_t test_open(const char *name, int flags, io_channel *channel) data->write_abort_count = 0; if ((value = safe_getenv("TEST_IO_WRITE_ABORT")) != NULL) data->write_abort_count = strtoul(value, NULL, 0); - + *channel = io; return 0; @@ -267,13 +267,13 @@ static errcode_t test_close(io_channel channel) if (--channel->refcount > 0) return 0; - + if (data->real) retval = io_channel_close(data->real); if (data->outfile && data->outfile != stderr) fclose(data->outfile); - + ext2fs_free_mem(&channel->private_data); if (channel->name) ext2fs_free_mem(&channel->name); @@ -326,7 +326,7 @@ static errcode_t test_read_blk(io_channel channel, unsigned long block, test_dump_block(channel, data, block, buf); if (--data->read_abort_count == 0) test_abort(channel, block); - } + } return retval; } @@ -380,7 +380,7 @@ static errcode_t test_read_blk64(io_channel channel, unsigned long long block, test_dump_block(channel, data, block, buf); if (--data->read_abort_count == 0) test_abort(channel, block); - } + } return retval; } @@ -439,22 +439,22 @@ static errcode_t test_flush(io_channel channel) { struct test_private_data *data; errcode_t retval = 0; - + EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL); data = (struct test_private_data *) channel->private_data; EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_TEST_IO_CHANNEL); if (data->real) retval = io_channel_flush(data->real); - + if (data->flags & TEST_FLAG_FLUSH) fprintf(data->outfile, "Test_io: flush() returned %s\n", retval ? error_message(retval) : "OK"); - + return retval; } -static errcode_t test_set_option(io_channel channel, const char *option, +static errcode_t test_set_option(io_channel channel, const char *option, const char *arg) { struct test_private_data *data; @@ -466,10 +466,10 @@ static errcode_t test_set_option(io_channel channel, const char *option, if (data->flags & TEST_FLAG_SET_OPTION) - fprintf(data->outfile, "Test_io: set_option(%s, %s) ", + fprintf(data->outfile, "Test_io: set_option(%s, %s) ", option, arg); if (data->real && data->real->manager->set_option) { - retval = (data->real->manager->set_option)(data->real, + retval = (data->real->manager->set_option)(data->real, option, arg); if (data->flags & TEST_FLAG_SET_OPTION) fprintf(data->outfile, "returned %s\n", diff --git a/lib/ext2fs/tst_badblocks.c b/lib/ext2fs/tst_badblocks.c index 2453f472..358da209 100644 --- a/lib/ext2fs/tst_badblocks.c +++ b/lib/ext2fs/tst_badblocks.c @@ -2,7 +2,7 @@ * This testing program makes sure the badblocks implementation works. * * Copyright (C) 1996 by Theodore Ts'o. - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. @@ -42,7 +42,7 @@ blk_t test4a[] = { 11, 0, 12, 1, 13, 1, - 14, 0, + 14, 0, 80, 0, 45, 0, 66, 1, @@ -60,7 +60,7 @@ blk_t test5a[] = { 1, DEL_BLK, 0 }; - + static int test_fail = 0; static int test_expected_fail = 0; @@ -70,7 +70,7 @@ static errcode_t create_test_list(blk_t *vec, badblocks_list *ret) errcode_t retval; badblocks_list bb; int i; - + retval = ext2fs_badblocks_list_create(&bb, 5); if (retval) { com_err("create_test_list", retval, "while creating list"); @@ -95,7 +95,7 @@ static void print_list(badblocks_list bb, int verify) badblocks_iterate iter; blk_t blk; int i, ok; - + retval = ext2fs_badblocks_list_iterate_begin(bb, &iter); if (retval) { com_err("print_list", retval, "while setting up iterator"); @@ -156,7 +156,7 @@ static void do_test_seq(badblocks_list bb, blk_t *vec) ext2fs_badblocks_list_del(bb, vec[i]); match = ext2fs_badblocks_list_test(bb, vec[i]); printf("Removing block %u --- now %s\n", vec[i], - ext2fs_badblocks_list_test(bb, vec[i]) ? + ext2fs_badblocks_list_test(bb, vec[i]) ? "present" : "absent"); if (match) { printf("FAILURE!\n"); @@ -254,7 +254,7 @@ int file_test_invalid(badblocks_list bb) printf("Expected test failure didn't happen!\n"); test_fail++; } - + if (ext2fs_badblocks_equal(bb, new_bb)) { printf("Block bitmap matched after reading and writing.\n"); @@ -278,7 +278,7 @@ int main(int argc, char **argv) if (retval == 0) print_list(bb1, 1); printf("\n"); - + printf("test2: "); retval = create_test_list(test2, &bb2); if (retval == 0) @@ -290,7 +290,7 @@ int main(int argc, char **argv) if (retval == 0) print_list(bb3, 1); printf("\n"); - + printf("test4: "); retval = create_test_list(test4, &bb4); if (retval == 0) { @@ -315,31 +315,31 @@ int main(int argc, char **argv) if (bb1 && bb2 && bb3 && bb4 && bb5) { printf("Comparison tests:\n"); equal = ext2fs_badblocks_equal(bb1, bb2); - printf("bb1 and bb2 are %sequal.\n", equal ? "" : "NOT "); + printf("bb1 and bb2 are %sequal.\n", equal ? "" : "NOT "); if (equal) test_fail++; equal = ext2fs_badblocks_equal(bb1, bb3); - printf("bb1 and bb3 are %sequal.\n", equal ? "" : "NOT "); + printf("bb1 and bb3 are %sequal.\n", equal ? "" : "NOT "); if (!equal) test_fail++; - + equal = ext2fs_badblocks_equal(bb1, bb4); - printf("bb1 and bb4 are %sequal.\n", equal ? "" : "NOT "); + printf("bb1 and bb4 are %sequal.\n", equal ? "" : "NOT "); if (equal) test_fail++; equal = ext2fs_badblocks_equal(bb4, bb5); - printf("bb4 and bb5 are %sequal.\n", equal ? "" : "NOT "); + printf("bb4 and bb5 are %sequal.\n", equal ? "" : "NOT "); if (!equal) test_fail++; printf("\n"); } - + file_test(bb4); file_test_invalid(bb4); - + if (test_fail == 0) printf("ext2fs library badblocks tests checks out OK!\n"); diff --git a/lib/ext2fs/tst_bitops.c b/lib/ext2fs/tst_bitops.c index eede295b..6febe685 100644 --- a/lib/ext2fs/tst_bitops.c +++ b/lib/ext2fs/tst_bitops.c @@ -2,7 +2,7 @@ * This testing program makes sure the bitops functions work * * Copyright (C) 2001 by Theodore Ts'o. - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. @@ -97,7 +97,7 @@ int main(int argc, char **argv) } } printf("ext2fs_clear_bit test succeed.\n"); - + /* Do bigarray test */ bigarray = malloc(1 << 29); @@ -150,7 +150,7 @@ int main(int argc, char **argv) } } printf("ext2fs_clear_bit test succeed.\n"); - + bigarray[BIG_TEST_BIT >> 3] = 0; diff --git a/lib/ext2fs/tst_byteswap.c b/lib/ext2fs/tst_byteswap.c index d73fb419..ba79c7c6 100644 --- a/lib/ext2fs/tst_byteswap.c +++ b/lib/ext2fs/tst_byteswap.c @@ -2,7 +2,7 @@ * This testing program makes sure the byteswap functions work * * Copyright (C) 2000 by Theodore Ts'o. - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. @@ -66,7 +66,7 @@ int main(int argc, char **argv) } i += 2; } while (test1[i] != 0); - + printf("Testing ext2fs_swab32\n"); i = 0; do { @@ -87,6 +87,6 @@ int main(int argc, char **argv) if (!errors) printf("No errors found in the byteswap implementation!\n"); - + return errors; } diff --git a/lib/ext2fs/tst_getsectsize.c b/lib/ext2fs/tst_getsectsize.c index 9967b615..cb1b8c65 100644 --- a/lib/ext2fs/tst_getsectsize.c +++ b/lib/ext2fs/tst_getsectsize.c @@ -1,8 +1,8 @@ /* * tst_getsize.c --- this function tests the getsize function - * + * * Copyright (C) 1997 by Theodore Ts'o. - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. @@ -29,7 +29,7 @@ int main(int argc, char **argv) { int sectsize; int retval; - + if (argc < 2) { fprintf(stderr, "Usage: %s device\n", argv[0]); exit(1); diff --git a/lib/ext2fs/tst_getsize.c b/lib/ext2fs/tst_getsize.c index 17f900cc..f9fc9d73 100644 --- a/lib/ext2fs/tst_getsize.c +++ b/lib/ext2fs/tst_getsize.c @@ -1,8 +1,8 @@ /* * tst_getsize.c --- this function tests the getsize function - * + * * Copyright (C) 1997 by Theodore Ts'o. - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. diff --git a/lib/ext2fs/tst_iscan.c b/lib/ext2fs/tst_iscan.c index d7fdc12d..b0c7fc30 100644 --- a/lib/ext2fs/tst_iscan.c +++ b/lib/ext2fs/tst_iscan.c @@ -1,8 +1,8 @@ /* * tst_inode.c --- this function tests the inode scan function - * + * * Copyright (C) 1996 by Theodore Ts'o. - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. @@ -75,7 +75,7 @@ static void setup(void) test_io_cb_read_blk = test_read_blk; - + retval = ext2fs_initialize("test fs", 0, ¶m, test_io_manager, &test_fs); if (retval) { @@ -110,7 +110,7 @@ static void setup(void) "While allocating bad inode bitmap"); exit(1); } - + retval = ext2fs_badblocks_list_create(&test_badblocks, 5); if (retval) { com_err("setup", retval, "while creating badblocks list"); diff --git a/lib/ext2fs/tst_super_size.c b/lib/ext2fs/tst_super_size.c index 476b1a6e..47fa5bac 100644 --- a/lib/ext2fs/tst_super_size.c +++ b/lib/ext2fs/tst_super_size.c @@ -2,7 +2,7 @@ * This testing program makes sure superblock size is 1024 bytes long * * Copyright (C) 2007 by Theodore Ts'o. - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. @@ -25,4 +25,4 @@ int main(int argc, char **argv) } exit(0); } - + diff --git a/lib/ext2fs/tst_types.c b/lib/ext2fs/tst_types.c index 78de7bcf..fbe35dcb 100644 --- a/lib/ext2fs/tst_types.c +++ b/lib/ext2fs/tst_types.c @@ -2,7 +2,7 @@ * This testing program makes sure the ext2_types header file * * Copyright (C) 2006 by Theodore Ts'o. - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c index eedbcdb3..d77e59db 100644 --- a/lib/ext2fs/unix_io.c +++ b/lib/ext2fs/unix_io.c @@ -4,7 +4,7 @@ * * Implements a one-block write-through cache. * - * Includes support for Windows NT support under Cygwin. + * Includes support for Windows NT support under Cygwin. * * Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, * 2002 by Theodore Ts'o. @@ -83,7 +83,7 @@ static errcode_t unix_write_blk(io_channel channel, unsigned long block, static errcode_t unix_flush(io_channel channel); static errcode_t unix_write_byte(io_channel channel, unsigned long offset, int size, const void *data); -static errcode_t unix_set_option(io_channel channel, const char *option, +static errcode_t unix_set_option(io_channel channel, const char *option, const char *arg); static errcode_t unix_get_stats(io_channel channel, io_stats *stats) ; @@ -169,7 +169,7 @@ static errcode_t raw_read_blk(io_channel channel, goto error_out; } return 0; - + error_out: memset((char *) buf+actual, 0, size-actual); if (channel->read_error) @@ -258,14 +258,14 @@ static errcode_t raw_write_blk(io_channel channel, retval = errno ? errno : EXT2_ET_LLSEEK_FAILED; goto error_out; } - + actual = write(data->dev, buf, size); if (actual != size) { retval = EXT2_ET_SHORT_WRITE; goto error_out; } return 0; - + error_out: if (channel->write_error) retval = (channel->write_error)(channel, block, count, buf, @@ -285,7 +285,7 @@ static errcode_t alloc_cache(io_channel channel, errcode_t retval; struct unix_cache *cache; int i; - + data->access_time = 0; for (i=0, cache = data->cache; i < CACHE_SIZE; i++, cache++) { cache->block = 0; @@ -304,7 +304,7 @@ static void free_cache(struct unix_private_data *data) { struct unix_cache *cache; int i; - + data->access_time = 0; for (i=0, cache = data->cache; i < CACHE_SIZE; i++, cache++) { cache->block = 0; @@ -329,7 +329,7 @@ static struct unix_cache *find_cached_block(struct unix_private_data *data, { struct unix_cache *cache, *unused_cache, *oldest_cache; int i; - + unused_cache = oldest_cache = 0; for (i=0, cache = data->cache; i < CACHE_SIZE; i++, cache++) { if (!cache->in_use) { @@ -376,18 +376,18 @@ static errcode_t flush_cached_blocks(io_channel channel, struct unix_cache *cache; errcode_t retval, retval2; int i; - + retval2 = 0; for (i=0, cache = data->cache; i < CACHE_SIZE; i++, cache++) { if (!cache->in_use) continue; - + if (invalidate) cache->in_use = 0; - + if (!cache->dirty) continue; - + retval = raw_write_blk(channel, data, cache->block, 1, cache->buf); if (retval) @@ -465,7 +465,7 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel) * block devices are wrongly getting hit by the filesize * limit. This workaround isn't perfect, since it won't work * if glibc wasn't built against 2.2 header files. (Sigh.) - * + * */ if ((flags & IO_FLAG_RW) && (uname(&ut) == 0) && @@ -476,7 +476,7 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel) (fstat(data->dev, &st) == 0) && (S_ISBLK(st.st_mode))) { struct rlimit rlim; - + rlim.rlim_cur = rlim.rlim_max = (unsigned long) RLIM_INFINITY; setrlimit(RLIMIT_FSIZE, &rlim); getrlimit(RLIMIT_FSIZE, &rlim); @@ -541,7 +541,7 @@ static errcode_t unix_set_blksize(io_channel channel, int blksize) if ((retval = flush_cached_blocks(channel, data, 0))) return retval; #endif - + channel->block_size = blksize; free_cache(data); if ((retval = alloc_cache(channel, data))) @@ -602,7 +602,7 @@ static errcode_t unix_read_blk64(io_channel channel, unsigned long long block, #endif if ((retval = raw_read_blk(channel, data, block, i, cp))) return retval; - + /* Save the results in the cache */ for (j=0; j < i; j++) { count--; @@ -637,7 +637,7 @@ static errcode_t unix_write_blk64(io_channel channel, unsigned long long block, #ifdef NO_IO_CACHE return raw_write_blk(channel, data, block, count, buf); -#else +#else /* * If we're doing an odd-sized write or a very large write, * flush out the cache completely and then do a direct write. @@ -656,7 +656,7 @@ static errcode_t unix_write_blk64(io_channel channel, unsigned long long block, writethrough = channel->flags & CHANNEL_FLAGS_WRITETHROUGH; if (writethrough) retval = raw_write_blk(channel, data, block, count, buf); - + cp = buf; while (count > 0) { cache = find_cached_block(data, block, &reuse); @@ -701,7 +701,7 @@ static errcode_t unix_write_byte(io_channel channel, unsigned long offset, if (lseek(data->dev, offset + data->offset, SEEK_SET) < 0) return errno; - + actual = write(data->dev, buf, size); if (actual != size) return EXT2_ET_SHORT_WRITE; @@ -710,13 +710,13 @@ static errcode_t unix_write_byte(io_channel channel, unsigned long offset, } /* - * Flush data buffers to disk. + * Flush data buffers to disk. */ static errcode_t unix_flush(io_channel channel) { struct unix_private_data *data; errcode_t retval = 0; - + EXT2_CHECK_MAGIC(channel, EXT2_ET_MAGIC_IO_CHANNEL); data = (struct unix_private_data *) channel->private_data; EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_UNIX_IO_CHANNEL); @@ -728,7 +728,7 @@ static errcode_t unix_flush(io_channel channel) return retval; } -static errcode_t unix_set_option(io_channel channel, const char *option, +static errcode_t unix_set_option(io_channel channel, const char *option, const char *arg) { struct unix_private_data *data; diff --git a/lib/ext2fs/unlink.c b/lib/ext2fs/unlink.c index a48b8775..ffe8dbe9 100644 --- a/lib/ext2fs/unlink.c +++ b/lib/ext2fs/unlink.c @@ -1,6 +1,6 @@ /* * unlink.c --- delete links in a ext2fs directory - * + * * Copyright (C) 1993, 1994, 1997 Theodore Ts'o. * * %Begin-Header% @@ -25,7 +25,7 @@ struct link_struct { int flags; struct ext2_dir_entry *prev; int done; -}; +}; #ifdef __TURBOC__ #pragma argsused @@ -89,7 +89,7 @@ errcode_t ext2fs_unlink(ext2_filsys fs, ext2_ino_t dir, ls.done = 0; ls.prev = 0; - retval = ext2fs_dir_iterate(fs, dir, DIRENT_FLAG_INCLUDE_EMPTY, + retval = ext2fs_dir_iterate(fs, dir, DIRENT_FLAG_INCLUDE_EMPTY, 0, unlink_proc, &ls); if (retval) return retval; diff --git a/lib/ext2fs/valid_blk.c b/lib/ext2fs/valid_blk.c index 29ff27a7..d0367e71 100644 --- a/lib/ext2fs/valid_blk.c +++ b/lib/ext2fs/valid_blk.c @@ -2,12 +2,12 @@ * valid_blk.c --- does the inode have valid blocks? * * Copyright 1997 by Theodore Ts'o - * + * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public * License. * %End-Header% - * + * */ #include <stdio.h> @@ -33,7 +33,7 @@ int ext2fs_inode_has_valid_blocks(struct ext2_inode *inode) if (!LINUX_S_ISDIR(inode->i_mode) && !LINUX_S_ISREG(inode->i_mode) && !LINUX_S_ISLNK(inode->i_mode)) return 0; - + /* * If the symbolic link is a "fast symlink", then the symlink * target is stored in the block entries. diff --git a/lib/fpopen.c b/lib/fpopen.c index 47346e1d..0df25e4e 100644 --- a/lib/fpopen.c +++ b/lib/fpopen.c @@ -46,7 +46,7 @@ FILE *fpopen(const char *cmd, const char *mode) errno = EFAULT; return NULL; } - + switch (*mode) { case 'r': do_stdin = 0; @@ -91,7 +91,7 @@ FILE *fpopen(const char *cmd, const char *mode) */ if (pipe(fds) < 0) return NULL; - + /* Fork and execute the correct program. */ if ((pid = fork()) < 0) { perror("fork"); diff --git a/lib/ss/error.c b/lib/ss/error.c index 14c0570f..9a4b5269 100644 --- a/lib/ss/error.c +++ b/lib/ss/error.c @@ -18,13 +18,13 @@ #include "ss_internal.h" #include <stdarg.h> - + char * ss_name(sci_idx) int sci_idx; { register char *ret_val; register ss_data *infop; - + infop = ss_info(sci_idx); if (infop->current_request == (char const *)NULL) { ret_val = malloc((unsigned) @@ -38,7 +38,7 @@ char * ss_name(sci_idx) else { register char *cp; register char const *cp1; - ret_val = malloc((unsigned)sizeof(char) * + ret_val = malloc((unsigned)sizeof(char) * (strlen(infop->subsystem_name)+ strlen(infop->current_request)+ 4)); diff --git a/lib/ss/get_readline.c b/lib/ss/get_readline.c index 70099b09..16679a30 100644 --- a/lib/ss/get_readline.c +++ b/lib/ss/get_readline.c @@ -25,7 +25,7 @@ static void ss_release_readline(ss_data *info) #ifdef HAVE_DLOPEN if (!info->readline_handle) return; - + info->readline = 0; info->add_history = 0; info->redisplay = 0; @@ -46,7 +46,7 @@ void ss_get_readline(int sci_idx) const char **t, *libpath = 0; char *tmp, *cp, *next; char **(**completion_func)(const char *, int, int); - + if (info->readline_handle) return; @@ -55,7 +55,7 @@ void ss_get_readline(int sci_idx) libpath = DEFAULT_LIBPATH; if (*libpath == 0 || !strcmp(libpath, "none")) return; - + tmp = malloc(strlen(libpath)+1); if (!tmp) return; @@ -94,4 +94,4 @@ void ss_get_readline(int sci_idx) #endif } - + diff --git a/lib/ss/listen.c b/lib/ss/listen.c index 05d0dc06..bd7c8c09 100644 --- a/lib/ss/listen.c +++ b/lib/ss/listen.c @@ -3,7 +3,7 @@ * * $Header$ * $Locker$ - * + * * Copyright 1987, 1988 by MIT Student Information Processing Board * * Permission to use, copy, modify, and distribute this software and @@ -56,7 +56,7 @@ int ss_listen (int sci_idx) jmp_buf old_jmpb; ss_data *old_info = current_info; char *line; - + current_info = info = ss_info(sci_idx); sig_cont = (sigret_t (*)(int)) 0; info->abort = 0; @@ -81,7 +81,7 @@ int ss_listen (int sci_idx) line = input; else line = NULL; - + input[BUFSIZ-1] = 0; } if (line == NULL) { @@ -89,7 +89,7 @@ int ss_listen (int sci_idx) (void) signal(SIGCONT, sig_cont); goto egress; } - + cp = strchr(line, '\n'); if (cp) { *cp = '\0'; @@ -130,11 +130,11 @@ void ss_abort_subsystem(int sci_idx, int code) { ss_info(sci_idx)->abort = 1; ss_info(sci_idx)->exit_status = code; - + } -void ss_quit(int argc __SS_ATTR((unused)), - const char * const *argv __SS_ATTR((unused)), +void ss_quit(int argc __SS_ATTR((unused)), + const char * const *argv __SS_ATTR((unused)), int sci_idx, pointer infop __SS_ATTR((unused))) { ss_abort_subsystem(sci_idx, 0); @@ -151,7 +151,7 @@ static char *cmd_generator(const char *text, int state) static char const * const * name; ss_request_entry *request; char *ret; - + if (state == 0) { len = strlen(text); rqtbl = current_info->rqt_tables; @@ -187,7 +187,7 @@ static char *cmd_generator(const char *text, int state) return 0; } -char **ss_rl_completion(const char *text, int start, +char **ss_rl_completion(const char *text, int start, int end __SS_ATTR((unused))) { if ((start == 0) && current_info->rl_completion_matches) diff --git a/lib/ss/pager.c b/lib/ss/pager.c index a7a2a092..ca05519c 100644 --- a/lib/ss/pager.c +++ b/lib/ss/pager.c @@ -71,10 +71,10 @@ char *ss_safe_getenv(const char *arg) */ #ifndef NO_FORK -int ss_pager_create(void) +int ss_pager_create(void) { int filedes[2]; - + if (pipe(filedes) != 0) return(-1); @@ -110,7 +110,7 @@ void ss_page_stdin() { int i; sigset_t mask; - + for (i = 3; i < 32; i++) (void) close(i); (void) signal(SIGINT, SIG_DFL); diff --git a/lib/ss/requests.c b/lib/ss/requests.c index 80133688..2e061000 100644 --- a/lib/ss/requests.c +++ b/lib/ss/requests.c @@ -18,7 +18,7 @@ #define DECLARE(name) void name(int argc,const char * const *argv, \ int sci_idx, void *infop) - + /* * ss_self_identify -- assigned by default to the "." request */ @@ -36,7 +36,7 @@ void ss_self_identify(int argc __SS_ATTR((unused)), */ void ss_subsystem_name(int argc __SS_ATTR((unused)), const char * const *argv __SS_ATTR((unused)), - int sci_idx, + int sci_idx, void *infop __SS_ATTR((unused))) { printf("%s\n", ss_info(sci_idx)->subsystem_name); @@ -47,7 +47,7 @@ void ss_subsystem_name(int argc __SS_ATTR((unused)), */ void ss_subsystem_version(int argc __SS_ATTR((unused)), const char * const *argv __SS_ATTR((unused)), - int sci_idx, + int sci_idx, void *infop __SS_ATTR((unused))) { printf("%s\n", ss_info(sci_idx)->subsystem_version); diff --git a/lib/ss/test_ss.c b/lib/ss/test_ss.c index 36e899d3..aba7cbcd 100644 --- a/lib/ss/test_ss.c +++ b/lib/ss/test_ss.c @@ -1,6 +1,6 @@ /* * test_ss.c - * + * * Copyright 1987, 1988 by MIT Student Information Processing Board * * Permission to use, copy, modify, and distribute this software and @@ -11,7 +11,7 @@ * M.I.T. S.I.P.B. make no representations about the suitability of * this software for any purpose. It is provided "as is" without * express or implied warranty. - + */ #include <unistd.h> diff --git a/lib/uuid/clear.c b/lib/uuid/clear.c index f3a1005b..2d91fee9 100644 --- a/lib/uuid/clear.c +++ b/lib/uuid/clear.c @@ -1,6 +1,6 @@ /* * clear.c -- Clear a UUID - * + * * Copyright (C) 1996, 1997 Theodore Ts'o. * * %Begin-Header% @@ -16,7 +16,7 @@ * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. - * + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF diff --git a/lib/uuid/compare.c b/lib/uuid/compare.c index a9c505c7..f28a7267 100644 --- a/lib/uuid/compare.c +++ b/lib/uuid/compare.c @@ -2,7 +2,7 @@ * compare.c --- compare whether or not two UUID's are the same * * Returns 0 if the two UUID's are different, and 1 if they are the same. - * + * * Copyright (C) 1996, 1997 Theodore Ts'o. * * %Begin-Header% @@ -18,7 +18,7 @@ * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. - * + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF diff --git a/lib/uuid/copy.c b/lib/uuid/copy.c index 963bc818..ead33aa2 100644 --- a/lib/uuid/copy.c +++ b/lib/uuid/copy.c @@ -1,6 +1,6 @@ /* * copy.c --- copy UUIDs - * + * * Copyright (C) 1996, 1997 Theodore Ts'o. * * %Begin-Header% @@ -16,7 +16,7 @@ * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. - * + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF diff --git a/lib/uuid/gen_uuid.c b/lib/uuid/gen_uuid.c index 152a6c09..a3052d4b 100644 --- a/lib/uuid/gen_uuid.c +++ b/lib/uuid/gen_uuid.c @@ -16,7 +16,7 @@ * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. - * + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF @@ -144,7 +144,7 @@ static int get_random_fd(void) fd = open("/dev/random", O_RDONLY | O_NONBLOCK); if (fd >= 0) { i = fcntl(fd, F_GETFD); - if (i >= 0) + if (i >= 0) fcntl(fd, F_SETFD, i | FD_CLOEXEC); } #endif @@ -187,7 +187,7 @@ static void get_random_bytes(void *buf, int nbytes) lose_counter = 0; } } - + /* * We do this all the time, but this is the only source of * randomness if /dev/random/urandom is out to lunch. @@ -199,7 +199,7 @@ static void get_random_bytes(void *buf, int nbytes) jrand_seed[2] = jrand_seed[2] ^ syscall(__NR_gettid); for (cp = buf, i = 0; i < nbytes; i++) *cp++ ^= (jrand48(tmp_seed) >> 7) & 0xFF; - memcpy(jrand_seed, tmp_seed, + memcpy(jrand_seed, tmp_seed, sizeof(jrand_seed)-sizeof(unsigned short)); #endif @@ -230,7 +230,7 @@ static int get_node_id(unsigned char *node_id) /* * BSD 4.4 defines the size of an ifreq to be * max(sizeof(ifreq), sizeof(ifreq.ifr_name)+ifreq.ifr_addr.sa_len - * However, under earlier systems, sa_len isn't present, so the size is + * However, under earlier systems, sa_len isn't present, so the size is * just sizeof(struct ifreq) */ #ifdef HAVE_SA_LEN @@ -377,7 +377,7 @@ try_again: adjustment = 0; last = tv; } - + clock_reg = tv.tv_usec*10 + adjustment; clock_reg += ((uint64_t) tv.tv_sec)*10000000; clock_reg += (((uint64_t) 0x01B21DD2) << 32) + 0x13814000; @@ -459,7 +459,7 @@ static int get_uuid_via_daemon(int op, uuid_t out, int *num) access_ret = access(uuidd_path, X_OK); if (access_ret == 0 && start_attempts++ < 5) { if ((pid = fork()) == 0) { - execl(uuidd_path, "uuidd", "-qT", "300", + execl(uuidd_path, "uuidd", "-qT", "300", (char *) NULL); exit(1); } diff --git a/lib/uuid/isnull.c b/lib/uuid/isnull.c index 54a83003..931e7e7d 100644 --- a/lib/uuid/isnull.c +++ b/lib/uuid/isnull.c @@ -1,6 +1,6 @@ /* * isnull.c --- Check whether or not the UUID is null - * + * * Copyright (C) 1996, 1997 Theodore Ts'o. * * %Begin-Header% @@ -16,7 +16,7 @@ * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. - * + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF diff --git a/lib/uuid/pack.c b/lib/uuid/pack.c index 348d4321..097516d2 100644 --- a/lib/uuid/pack.c +++ b/lib/uuid/pack.c @@ -1,6 +1,6 @@ /* * Internal routine for packing UUID's - * + * * Copyright (C) 1996, 1997 Theodore Ts'o. * * %Begin-Header% @@ -16,7 +16,7 @@ * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. - * + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF @@ -48,7 +48,7 @@ void uuid_pack(const struct uuid *uu, uuid_t ptr) out[1] = (unsigned char) tmp; tmp >>= 8; out[0] = (unsigned char) tmp; - + tmp = uu->time_mid; out[5] = (unsigned char) tmp; tmp >>= 8; diff --git a/lib/uuid/parse.c b/lib/uuid/parse.c index 07b894d1..074383ef 100644 --- a/lib/uuid/parse.c +++ b/lib/uuid/parse.c @@ -1,6 +1,6 @@ /* * parse.c --- UUID parsing - * + * * Copyright (C) 1996, 1997 Theodore Ts'o. * * %Begin-Header% @@ -16,7 +16,7 @@ * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. - * + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF @@ -73,7 +73,7 @@ int uuid_parse(const char *in, uuid_t uu) buf[1] = *cp++; uuid.node[i] = strtoul(buf, NULL, 16); } - + uuid_pack(&uuid, uu); return 0; } diff --git a/lib/uuid/tst_uuid.c b/lib/uuid/tst_uuid.c index 01606d7c..e03138f7 100644 --- a/lib/uuid/tst_uuid.c +++ b/lib/uuid/tst_uuid.c @@ -16,7 +16,7 @@ * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. - * + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF diff --git a/lib/uuid/unpack.c b/lib/uuid/unpack.c index 9502fc2a..beaaff3c 100644 --- a/lib/uuid/unpack.c +++ b/lib/uuid/unpack.c @@ -1,6 +1,6 @@ /* * Internal routine for unpacking UUID - * + * * Copyright (C) 1996, 1997 Theodore Ts'o. * * %Begin-Header% @@ -16,7 +16,7 @@ * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. - * + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF @@ -49,7 +49,7 @@ void uuid_unpack(const uuid_t in, struct uuid *uu) tmp = *ptr++; tmp = (tmp << 8) | *ptr++; uu->time_mid = tmp; - + tmp = *ptr++; tmp = (tmp << 8) | *ptr++; uu->time_hi_and_version = tmp; diff --git a/lib/uuid/unparse.c b/lib/uuid/unparse.c index c0e08ef4..a95bbb04 100644 --- a/lib/uuid/unparse.c +++ b/lib/uuid/unparse.c @@ -1,6 +1,6 @@ /* * unparse.c -- convert a UUID to string - * + * * Copyright (C) 1996, 1997 Theodore Ts'o. * * %Begin-Header% @@ -16,7 +16,7 @@ * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. - * + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF @@ -36,10 +36,10 @@ #include "uuidP.h" -static const char *fmt_lower = +static const char *fmt_lower = "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x"; -static const char *fmt_upper = +static const char *fmt_upper = "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X"; #ifdef UUID_UNPARSE_DEFAULT_UPPER diff --git a/lib/uuid/uuid.h b/lib/uuid/uuid.h index 1c241e3e..ca846da0 100644 --- a/lib/uuid/uuid.h +++ b/lib/uuid/uuid.h @@ -1,6 +1,6 @@ /* * Public include file for the UUID library - * + * * Copyright (C) 1996, 1997, 1998 Theodore Ts'o. * * %Begin-Header% @@ -16,7 +16,7 @@ * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. - * + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF diff --git a/lib/uuid/uuidP.h b/lib/uuid/uuidP.h index adf233da..d0e24c69 100644 --- a/lib/uuid/uuidP.h +++ b/lib/uuid/uuidP.h @@ -1,6 +1,6 @@ /* * uuid.h -- private header file for uuids - * + * * Copyright (C) 1996, 1997 Theodore Ts'o. * * %Begin-Header% @@ -16,7 +16,7 @@ * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. - * + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF diff --git a/lib/uuid/uuid_time.c b/lib/uuid/uuid_time.c index fc1d2665..f25f5c90 100644 --- a/lib/uuid/uuid_time.c +++ b/lib/uuid/uuid_time.c @@ -2,7 +2,7 @@ * uuid_time.c --- Interpret the time field from a uuid. This program * violates the UUID abstraction barrier by reaching into the guts * of a UUID and interpreting it. - * + * * Copyright (C) 1998, 1999 Theodore Ts'o. * * %Begin-Header% @@ -18,7 +18,7 @@ * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior * written permission. - * + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF @@ -61,7 +61,7 @@ time_t uuid_time(const uuid_t uu, struct timeval *ret_tv) uint64_t clock_reg; uuid_unpack(uu, &uuid); - + high = uuid.time_mid | ((uuid.time_hi_and_version & 0xFFF) << 16); clock_reg = uuid.time_low | ((uint64_t) high << 32); @@ -79,7 +79,7 @@ int uuid_type(const uuid_t uu) { struct uuid uuid; - uuid_unpack(uu, &uuid); + uuid_unpack(uu, &uuid); return ((uuid.time_hi_and_version >> 12) & 0xF); } @@ -88,7 +88,7 @@ int uuid_variant(const uuid_t uu) struct uuid uuid; int var; - uuid_unpack(uu, &uuid); + uuid_unpack(uu, &uuid); var = uuid.clock_seq; if ((var & 0x8000) == 0) @@ -115,7 +115,7 @@ static const char *variant_string(int variant) } } - + int main(int argc, char **argv) { @@ -165,7 +165,7 @@ main(int argc, char **argv) } printf("UUID time is: (%ld, %ld): %s\n", tv.tv_sec, tv.tv_usec, ctime(&time_reg)); - + return 0; } #endif |