コード例 #1
0
ファイル: namei.c プロジェクト: xiandaicxsj/copyKvm
/***** Creates a directory entry (name is already formatted). */
static int msdos_add_entry(struct inode *dir, const unsigned char *name,
			   int is_dir, int is_hid, int cluster,
			   struct timespec *ts, struct fat_slot_info *sinfo)
{
	struct msdos_dir_entry de;
	__le16 time, date;
	int err;

	memcpy(de.name, name, MSDOS_NAME);
	de.attr = is_dir ? ATTR_DIR : ATTR_ARCH;
	if (is_hid)
		de.attr |= ATTR_HIDDEN;
	de.lcase = 0;
	fat_date_unix2dos(ts->tv_sec, &time, &date);
	de.cdate = de.adate = 0;
	de.ctime = 0;
	de.ctime_cs = 0;
	de.time = time;
	de.date = date;
	de.start = cpu_to_le16(cluster);
	de.starthi = cpu_to_le16(cluster >> 16);
	de.size = 0;

	err = fat_add_entries(dir, &de, 1, sinfo);
	if (err)
		return err;

	dir->i_ctime = dir->i_mtime = *ts;
	if (IS_DIRSYNC(dir))
		(void)fat_sync_inode(dir);
	else
		mark_inode_dirty(dir);

	return 0;
}
/***** Creates a directory entry (name is already formatted). */
static int msdos_add_entry(struct inode *dir, const char *name,
			   struct buffer_head **bh,
			   struct msdos_dir_entry **de,
			   loff_t *ino,
			   int is_dir, int is_hid)
{
	struct super_block *sb = dir->i_sb;
	int res;

	if ((res = fat_add_entries(dir, 1, bh, de, ino))<0)
		return res;
	/*
	 * XXX all times should be set by caller upon successful completion.
	 */
	dir->i_ctime = dir->i_mtime = CURRENT_TIME;
	mark_inode_dirty(dir);
	memcpy((*de)->name,name,MSDOS_NAME);
	(*de)->attr = is_dir ? ATTR_DIR : ATTR_ARCH;
	if (is_hid)
		(*de)->attr |= ATTR_HIDDEN;
	(*de)->start = 0;
	(*de)->starthi = 0;
	fat_date_unix2dos(dir->i_mtime,&(*de)->time,&(*de)->date);
	(*de)->size = 0;
	fat_mark_buffer_dirty(sb, *bh);
	return 0;
}