75{
76 static int curr_num = 0;
78
79 if (
fs->root_cluster) {
80 DIR_ENT d2;
84
85 clu_num =
fs->root_cluster;
87 while (clu_num > 0 && clu_num != -1) {
90 got = 1;
91 break;
92 }
95 if ((
i %
fs->cluster_size) == 0) {
96 prev = clu_num;
98 break;
100 }
101 }
102 if (!got) {
103
104
105 if (!prev)
106 die(
"Root directory has no cluster allocated!");
107 for (clu_num = prev + 1; clu_num != prev; clu_num++) {
109
110 if (clu_num >=
fs->data_clusters + 2)
111 clu_num = 2;
114 break;
115 }
116 if (clu_num == prev)
117 die(
"Root directory full and no free cluster");
121
122 memset(&d2, 0,
sizeof(d2));
124 for (
i = 0;
i <
fs->cluster_size;
i +=
sizeof(DIR_ENT))
126 }
127 memset(de, 0,
sizeof(DIR_ENT));
128 if (gen_name) {
129 while (1) {
130 char expanded[12];
133 clu_num =
fs->root_cluster;
136 while (clu_num > 0 && clu_num != -1) {
137 fs_read(offset2,
sizeof(DIR_ENT), &d2);
139 !
strncmp((
const char *)d2.name, (
const char *)de->name,
141 break;
142 i +=
sizeof(DIR_ENT);
143 offset2 += sizeof(DIR_ENT);
144 if ((
i %
fs->cluster_size) == 0) {
146 clu_num == -1)
147 break;
149 }
150 }
151 if (clu_num == 0 || clu_num == -1)
152 break;
153 if (++curr_num >= 10000)
154 die(
"Unable to create unique name");
155 }
156 } else {
158 }
159 } else {
161 int next_free = 0, scan;
162
165
169 break;
170 else
171 next_free++;
172 if (next_free ==
fs->root_entries)
173 die(
"Root directory is full.");
174 offset =
fs->root_start + next_free *
sizeof(DIR_ENT);
175 memset(de, 0,
sizeof(DIR_ENT));
176 if (gen_name) {
177 while (1) {
178 char expanded[12];
181 for (scan = 0; scan <
fs->root_entries; scan++)
182 if (scan != next_free &&
185 break;
186 if (scan ==
fs->root_entries)
187 break;
188 if (++curr_num >= 10000)
189 die(
"Unable to create unique name");
190 }
191 } else {
193 }
195 }
198}
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
static HRESULT get_owner(VARIANT *user, VARIANT *domain, VARIANT *retval)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
#define memcpy(s1, s2, n)
#define sprintf(buf, format,...)
const char * root_entries[]
uint32_t next_cluster(DOS_FS *fs, uint32_t cluster)
void set_owner(DOS_FS *fs, uint32_t cluster, DOS_FILE *owner)
off_t cluster_start(DOS_FS *fs, uint32_t cluster)
void get_fat(FAT_ENTRY *entry, void *fat, uint32_t cluster, DOS_FS *fs)
void set_fat(DOS_FS *fs, uint32_t cluster, int32_t new)
void fs_read(off_t pos, int size, void *data)
void fs_write(off_t pos, int size, void *data)